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(DisplayMediaCard, PosterCard): add extra #1131

Merged
merged 7 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/__screenshot_tests__/display-media-card-screenshot-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ test('DisplayMediaCard with asset', async () => {
expect(image).toMatchImageSnapshot();
});

test('DisplayMediaCard with extra content', async () => {
await openStoryPage({
id: 'components-cards-displaymediacard--default',
args: {withExtra: true},
});

const displayMediaCard = await screen.findByTestId('display-media-card');

const image = await displayMediaCard.screenshot();

expect(image).toMatchImageSnapshot();
});

test.each`
background | inverse
${'image'} | ${false}
Expand Down
13 changes: 13 additions & 0 deletions src/__screenshot_tests__/poster-card-screenshot-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ test('PosterCard with custom background color inverse', async () => {
expect(image).toMatchImageSnapshot();
});

test('PosterCard with extra content', async () => {
await openStoryPage({
id: 'components-cards-postercard--default',
args: {withExtra: true},
});

const posterCard = await screen.findByTestId('poster-card');

const image = await posterCard.screenshot();

expect(image).toMatchImageSnapshot();
});

test.each`
background | inverse
${'image'} | ${false}
Expand Down
5 changes: 5 additions & 0 deletions src/__stories__/display-media-card-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Carousel,
IconStarFilled,
IconStarRegular,
Placeholder,
} from '..';
import usingVrImg from './images/using-vr.jpg';
import avatarImg from './images/avatar.jpg';
Expand All @@ -40,6 +41,7 @@ type DisplayMediaCardArgs = {
pretitle: string;
title: string;
description: string;
withExtra: boolean;
closable: boolean;
withTopAction: boolean;
actions: 'button' | 'link' | 'button and link' | 'button and secondary button' | 'onPress';
Expand All @@ -57,6 +59,7 @@ export const Default: StoryComponent<DisplayMediaCardArgs> = ({
pretitle,
title,
description,
withExtra,
actions = 'button',
closable,
withTopAction,
Expand Down Expand Up @@ -145,6 +148,7 @@ export const Default: StoryComponent<DisplayMediaCardArgs> = ({
aria-label="Display media card label"
width={width}
aspectRatio={aspectRatio}
extra={withExtra ? <Placeholder /> : undefined}
dataAttributes={{testid: 'display-media-card'}}
/>
</Box>
Expand All @@ -161,6 +165,7 @@ Default.args = {
pretitle: 'Pretitle',
title: 'Title',
description: 'This is a description for the card',
withExtra: false,
actions: 'button',
closable: false,
withTopAction: false,
Expand Down
5 changes: 5 additions & 0 deletions src/__stories__/poster-card-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Carousel,
IconStarFilled,
IconStarRegular,
Placeholder,
} from '..';
import {PosterCard} from '../card';
import usingVrImg from './images/using-vr.jpg';
Expand Down Expand Up @@ -41,6 +42,7 @@ type PosterCardArgs = {
title: string;
subtitle: string;
description: string;
withExtra: boolean;
ariaLabel: string;
closable: boolean;
actions: 'onPress' | 'href' | 'to' | 'none';
Expand All @@ -64,6 +66,7 @@ export const Default: StoryComponent<PosterCardArgs> = ({
title,
subtitle,
description,
withExtra,
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have half of our stories using withExtra and the other half extra. Which one should we use?

Copy link
Contributor Author

@yceballost yceballost May 29, 2024

Choose a reason for hiding this comment

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

also we have some "icon" instead of "withIcon" (in tag story for example)

perhaps it is better to create a task to solve these "purity details" across all stories.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've created an issue for this: https://jira.tid.es/browse/WEB-1891

ariaLabel,
closable,
actions,
Expand Down Expand Up @@ -144,6 +147,7 @@ export const Default: StoryComponent<PosterCardArgs> = ({
title={title}
subtitle={subtitle}
description={description}
extra={withExtra ? <Placeholder /> : undefined}
aria-label={ariaLabel}
width={width}
height={height}
Expand All @@ -168,6 +172,7 @@ Default.args = {
title: 'Title',
subtitle: 'Subtitle',
description: 'This is a description for the card',
withExtra: false,
ariaLabel: '',
closable: false,
actions: 'none',
Expand Down
5 changes: 4 additions & 1 deletion src/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ interface CommonDisplayCardProps {
descriptionLinesMax?: number;
'aria-label'?: string;
aspectRatio?: AspectRatio | number;
extra?: React.ReactNode;
}

type DisplayMediaCardBaseProps = {
Expand Down Expand Up @@ -1086,7 +1087,6 @@ type DisplayMediaCardProps = DisplayMediaCardBaseProps &
>;

type DisplayDataCardProps = CommonDisplayCardProps & {
extra?: React.ReactNode;
isInverse?: boolean;
} & ExclusifyUnion<
| TouchableProps
Expand Down Expand Up @@ -1343,6 +1343,7 @@ interface PosterCardBaseProps {
subtitleLinesMax?: number;
description?: string;
descriptionLinesMax?: number;
extra?: React.ReactNode;
}

interface PosterCardWithImageProps extends PosterCardBaseProps {
Expand Down Expand Up @@ -1396,6 +1397,7 @@ export const PosterCard = React.forwardRef<HTMLDivElement, PosterCardProps>(
subtitleLinesMax,
description,
descriptionLinesMax,
extra,
variant,
isInverse,
backgroundColor,
Expand Down Expand Up @@ -1593,6 +1595,7 @@ export const PosterCard = React.forwardRef<HTMLDivElement, PosterCardProps>(
</Text2>
</div>
)}
{extra}
Copy link
Member

Choose a reason for hiding this comment

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

I guess it is expected to not have any spacings between the extra an the other elements.

Please add some screenshot tests to verify

Copy link
Contributor Author

@yceballost yceballost May 30, 2024

Choose a reason for hiding this comment

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

Yes, the extra props let this spacing to be the responsibility of the designer

I didn't include screenshots because we don't have screenshots in displayDataCard for extra. But I will do it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

</div>
</Box>
</Box>
Expand Down
Loading