Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add content-list #468

Merged
merged 10 commits into from
Aug 2, 2023
Merged

feat: add content-list #468

merged 10 commits into from
Aug 2, 2023

Conversation

@yuberdysheva yuberdysheva force-pushed the yuberdysheva/add-content-items branch from 6c1239a to 706baae Compare July 31, 2023 11:29
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@yuberdysheva yuberdysheva force-pushed the yuberdysheva/add-content-items branch from 0fe3eb3 to 760ef6a Compare August 1, 2023 13:32
const iconData = getMediaImage(iconThemed);

return (
<div className={b('item')} key={title || text}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we dont have title or text we dont have key, and we'll have error with this example
contentList = [{icon: '...'}, {icon: '...'}], {icon: '...'}]]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use import {v4 as uuidv4} from 'uuid'; for key

@@ -72,6 +75,7 @@ const Content = (props: ContentBlockProps & ClassNameProps) => {
/>
</div>
)}
{contentList && <ContentList contentList={contentList} size={size} />}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just check the length of the array and not even render the component if it's empty?

NikitaCG
NikitaCG previously approved these changes Aug 1, 2023
@@ -72,6 +75,7 @@ const Content = (props: ContentBlockProps & ClassNameProps) => {
/>
</div>
)}
{contentList?.length && <ContentList contentList={contentList} size={size} />}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if contentList is empty array, 0 will be rendered here

@@ -21,6 +30,7 @@ const MediaContent = (props: MediaContentProps) => {
links={links}
theme="default"
buttons={allButtons}
contentList={contentList}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contentList -> items

const b = block('content-list');

interface ContentListProps {
contentList: ContentItemProps[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contentList -> items

@@ -75,7 +75,7 @@ const Content = (props: ContentBlockProps & ClassNameProps) => {
/>
</div>
)}
{list?.length && <ContentList list={list} size={size} />}
{list?.length && Boolean(list.length) && <ContentList list={list} size={size} />}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list?.length ? <ContentList list={list} size={size} /> : null

@yuberdysheva yuberdysheva merged commit 07e2a96 into main Aug 2, 2023
3 checks passed
@yuberdysheva yuberdysheva deleted the yuberdysheva/add-content-items branch August 2, 2023 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants