Skip to content

Commit

Permalink
fix: add tag on card list item
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardodouradol committed Aug 19, 2024
1 parent 2121e3d commit f2d8198
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
7 changes: 7 additions & 0 deletions packages/ocean-core/src/components/_card-list-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
}
}

&__wrapper {
align-items: center;
display: flex;
flex-direction: row;
width: 100%;
}

&__content {
display: flex;
flex-direction: column;
Expand Down
33 changes: 21 additions & 12 deletions packages/ocean-react/src/CardListItem/CardListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type CardListItemProps = {
* Whether the card list item is full width.
*/
fullWidth?: boolean;
/*
* The tag or element to be displayed in the tag area of the item.
*/
tag?: string | React.ReactElement;
/*
* The function to call when the card list item is clicked.
*/
Expand All @@ -57,6 +61,7 @@ const CardListItem = forwardRef<HTMLDivElement, CardListItemProps>(
fullWidth = false,
onClick,
loading,
tag,
...rest
},
ref
Expand Down Expand Up @@ -102,19 +107,23 @@ const CardListItem = forwardRef<HTMLDivElement, CardListItemProps>(
{leadingIcon && (
<div className="ods-card-list-item__leading-icon">{leadingIcon}</div>
)}
<div className="ods-card-list-item__content">
<div className="ods-card-list-item__content__title">{title}</div>
{description && (
<div className="ods-card-list-item__content__description">
{description}
</div>
)}
{caption && size === 'medium' && (
<div className="ods-card-list-item__content__caption">
{caption}
</div>
)}
<div className="ods-card-list-item__wrapper">
<div className="ods-card-list-item__content">
<div className="ods-card-list-item__content__title">{title}</div>
{description && (
<div className="ods-card-list-item__content__description">
{description}
</div>
)}
{caption && size === 'medium' && (
<div className="ods-card-list-item__content__caption">
{caption}
</div>
)}
</div>
{tag && <div className="ods-card-list-item__content__tag">{tag}</div>}
</div>

{actionIcon && (
<div className="ods-card-list-item__action">{actionIcon}</div>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { PlaceholderOutline } from '@useblu/ocean-icons-react';
import CardListItem from '../CardListItem';
import Tag from '../../Tag';

<Meta title="Components/CardListItem" component={CardListItem} />

Expand All @@ -24,6 +25,7 @@ import { CardListItem } from '@useblu/ocean-react';
caption="Caption"
leadingIcon={<PlaceholderOutline />}
actionIcon={<PlaceholderOutline />}
tag=<Tag>Tag</Tag>
/>
</Story>
</Canvas>
Expand Down Expand Up @@ -70,6 +72,7 @@ If that's not sufficient, you can check the [implementation of the component](ht
disabled: false,
size: 'medium',
onClick: () => null,
tags: <Tag>Tag</Tag>,
fullWidth: false,
}}
>
Expand Down

0 comments on commit f2d8198

Please sign in to comment.