diff --git a/src/__screenshot_tests__/__image_snapshots__/display-media-card-screenshot-test-tsx-display-media-card-with-asset-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/display-media-card-screenshot-test-tsx-display-media-card-with-asset-1-snap.png new file mode 100644 index 0000000000..b016768908 Binary files /dev/null and b/src/__screenshot_tests__/__image_snapshots__/display-media-card-screenshot-test-tsx-display-media-card-with-asset-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/media-card-screenshot-test-tsx-media-card-with-asset-in-desktop-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/media-card-screenshot-test-tsx-media-card-with-asset-in-desktop-1-snap.png new file mode 100644 index 0000000000..b72014fbba Binary files /dev/null and b/src/__screenshot_tests__/__image_snapshots__/media-card-screenshot-test-tsx-media-card-with-asset-in-desktop-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/media-card-screenshot-test-tsx-media-card-with-asset-in-mobile-ios-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/media-card-screenshot-test-tsx-media-card-with-asset-in-mobile-ios-1-snap.png new file mode 100644 index 0000000000..e04db4af4c Binary files /dev/null and b/src/__screenshot_tests__/__image_snapshots__/media-card-screenshot-test-tsx-media-card-with-asset-in-mobile-ios-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/naked-card-screenshot-test-tsx-naked-card-with-asset-in-desktop-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/naked-card-screenshot-test-tsx-naked-card-with-asset-in-desktop-1-snap.png new file mode 100644 index 0000000000..4d144ee1f7 Binary files /dev/null and b/src/__screenshot_tests__/__image_snapshots__/naked-card-screenshot-test-tsx-naked-card-with-asset-in-desktop-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/naked-card-screenshot-test-tsx-naked-card-with-asset-in-mobile-ios-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/naked-card-screenshot-test-tsx-naked-card-with-asset-in-mobile-ios-1-snap.png new file mode 100644 index 0000000000..b1f480abb4 Binary files /dev/null and b/src/__screenshot_tests__/__image_snapshots__/naked-card-screenshot-test-tsx-naked-card-with-asset-in-mobile-ios-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-in-desktop-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-in-desktop-1-snap.png index 465af3229a..a5c00d6241 100644 Binary files a/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-in-desktop-1-snap.png and b/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-in-desktop-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-width-is-never-smaller-than-140-px-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-width-is-never-smaller-than-140-px-1-snap.png index b63f592894..f87f257301 100644 Binary files a/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-width-is-never-smaller-than-140-px-1-snap.png and b/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-width-is-never-smaller-than-140-px-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-with-asset-in-desktop-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-with-asset-in-desktop-1-snap.png new file mode 100644 index 0000000000..a5ef9434f9 Binary files /dev/null and b/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-with-asset-in-desktop-1-snap.png differ diff --git a/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-with-asset-in-mobile-ios-1-snap.png b/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-with-asset-in-mobile-ios-1-snap.png new file mode 100644 index 0000000000..7fe5158630 Binary files /dev/null and b/src/__screenshot_tests__/__image_snapshots__/poster-card-screenshot-test-tsx-poster-card-with-asset-in-mobile-ios-1-snap.png differ diff --git a/src/__screenshot_tests__/display-media-card-screenshot-test.tsx b/src/__screenshot_tests__/display-media-card-screenshot-test.tsx index a477cf7721..9f5e05fdac 100644 --- a/src/__screenshot_tests__/display-media-card-screenshot-test.tsx +++ b/src/__screenshot_tests__/display-media-card-screenshot-test.tsx @@ -47,3 +47,16 @@ test('DisplayMediaCard with video', async () => { expect(image).toMatchImageSnapshot(); }); + +test('DisplayMediaCard with asset', async () => { + await openStoryPage({ + id: 'components-cards-display-media-card--default', + args: {asset: 'circle with icon'}, + }); + + const displayMediaCard = await screen.findByTestId('display-media-card'); + + const image = await displayMediaCard.screenshot(); + + expect(image).toMatchImageSnapshot(); +}); diff --git a/src/__screenshot_tests__/media-card-screenshot-test.tsx b/src/__screenshot_tests__/media-card-screenshot-test.tsx index b6eaf143de..7f1ed49da8 100644 --- a/src/__screenshot_tests__/media-card-screenshot-test.tsx +++ b/src/__screenshot_tests__/media-card-screenshot-test.tsx @@ -88,3 +88,17 @@ test('MediaCard with top actions', async () => { expect(image).toMatchImageSnapshot(); }); + +test.each(TESTABLE_DEVICES)('MediaCard with asset in %s', async (device) => { + const page = await openStoryPage({ + id: 'components-cards-media-card--default', + device, + args: { + asset: 'circle with icon', + }, + }); + + const image = await page.screenshot({fullPage: true}); + + expect(image).toMatchImageSnapshot(); +}); diff --git a/src/__screenshot_tests__/naked-card-screenshot-test.tsx b/src/__screenshot_tests__/naked-card-screenshot-test.tsx index 26c9e17c7b..f9cd121e9b 100644 --- a/src/__screenshot_tests__/naked-card-screenshot-test.tsx +++ b/src/__screenshot_tests__/naked-card-screenshot-test.tsx @@ -103,6 +103,21 @@ test('NakedCard with top actions', async () => { expect(image).toMatchImageSnapshot(); }); +test.each(TESTABLE_DEVICES)('NakedCard with asset in %s', async (device) => { + await openStoryPage({ + id: 'components-cards-nakedcard--default', + device, + args: { + asset: 'circle with icon', + }, + }); + + const nakedCard = await screen.findByTestId('naked-card'); + const image = await nakedCard.screenshot({captureBeyondViewport: true}); + + expect(image).toMatchImageSnapshot(); +}); + test.each(TESTABLE_DEVICES)('SmallNakedCard in %s', async (device) => { await openStoryPage({ id: 'components-cards-nakedcard--small', diff --git a/src/__screenshot_tests__/poster-card-screenshot-test.tsx b/src/__screenshot_tests__/poster-card-screenshot-test.tsx index d022cf97c9..52ed81cb83 100644 --- a/src/__screenshot_tests__/poster-card-screenshot-test.tsx +++ b/src/__screenshot_tests__/poster-card-screenshot-test.tsx @@ -111,3 +111,17 @@ test('PosterCard with video', async () => { expect(image).toMatchImageSnapshot(); }); + +test.each(TESTABLE_DEVICES)('PosterCard with asset in %s', async (device) => { + await openStoryPage({ + id: 'components-cards-poster-card--default', + device, + args: {asset: 'circle with icon'}, + }); + + const posterCard = await screen.findByTestId('poster-card'); + + const image = await posterCard.screenshot(); + + expect(image).toMatchImageSnapshot(); +}); diff --git a/src/__stories__/display-media-card-story.tsx b/src/__stories__/display-media-card-story.tsx index 716ee6c2c3..961def3f91 100644 --- a/src/__stories__/display-media-card-story.tsx +++ b/src/__stories__/display-media-card-story.tsx @@ -32,7 +32,7 @@ const BACKGROUND_VIDEO_SRC = beachVideo; const BACKGROUND_VIDEO_POSTER_SRC = beachImg; type DisplayMediaCardArgs = { - asset: 'icon' | 'circle + icon' | 'image' | 'circle + image'; + asset: 'circle with icon' | 'circle with image' | 'none'; headlineType: TagType; background: 'image' | 'video'; headline: string; @@ -47,7 +47,7 @@ type DisplayMediaCardArgs = { }; export const Default: StoryComponent = ({ - asset = 'icon', + asset, headline, headlineType, background, @@ -61,13 +61,13 @@ export const Default: StoryComponent = ({ aspectRatio, }) => { let icon; - if (asset === 'circle + icon') { + if (asset === 'circle with icon') { icon = ( ); - } else if (asset === 'circle + image') { + } else if (asset === 'circle with image') { icon = ; } @@ -186,7 +186,7 @@ export const Default: StoryComponent = ({ Default.storyName = 'Display Media card'; Default.args = { - asset: 'icon', + asset: 'none', headlineType: 'promo', background: 'image', headline: 'Priority', @@ -201,7 +201,7 @@ Default.args = { }; Default.argTypes = { asset: { - options: ['circle + icon', 'circle + image', 'none'], + options: ['circle with icon', 'circle with image', 'none'], control: {type: 'select'}, }, headlineType: { diff --git a/src/__stories__/media-card-story.tsx b/src/__stories__/media-card-story.tsx index 4cefb4994f..6d1d4a4ba9 100644 --- a/src/__stories__/media-card-story.tsx +++ b/src/__stories__/media-card-story.tsx @@ -29,7 +29,7 @@ const VIDEO_SRC = confettiVideo; const IMAGE_SRC = tennisImg; type Args = { - asset: 'icon' | 'circle + icon' | 'image' | 'circle + image'; + asset: 'circle with icon' | 'circle with image' | 'none'; media: 'image' | 'video'; headlineType: TagType; headline: string; @@ -58,13 +58,13 @@ export const Default: StoryComponent = ({ asset, }) => { let icon; - if (asset === 'circle + icon') { + if (asset === 'circle with icon') { icon = ( ); - } else if (asset === 'circle + image') { + } else if (asset === 'circle with image') { icon = ; } @@ -125,7 +125,7 @@ export const Default: StoryComponent = ({ Default.storyName = 'Media card'; Default.args = { - asset: 'icon', + asset: 'none', media: 'image', headlineType: 'promo', headline: 'Priority', @@ -140,7 +140,7 @@ Default.args = { }; Default.argTypes = { asset: { - options: ['circle + icon', 'circle + image', 'none'], + options: ['circle with icon', 'circle with image', 'none'], control: {type: 'select'}, }, media: { diff --git a/src/__stories__/naked-card-story.tsx b/src/__stories__/naked-card-story.tsx index 63df641ae3..f8cb76c20a 100644 --- a/src/__stories__/naked-card-story.tsx +++ b/src/__stories__/naked-card-story.tsx @@ -12,11 +12,14 @@ import { Stack, Text2, Inline, + Circle, + skinVars, } from '..'; import {Placeholder} from '../placeholder'; import tennisImg from './images/tennis.jpg'; import confettiVideo from './videos/confetti.mp4'; import {SmallNakedCard} from '../card'; +import avatarImg from './images/avatar.jpg'; import type {TagType} from '..'; @@ -31,6 +34,7 @@ const VIDEO_SRC = confettiVideo; const IMAGE_SRC = tennisImg; type Args = { + asset: 'circle with icon' | 'circle with image' | 'none'; media: 'image' | 'circular image' | 'video'; headlineType: TagType; headline: string; @@ -56,7 +60,19 @@ export const Default: StoryComponent = ({ closable, withTopAction, media, + asset, }) => { + let icon; + if (asset === 'circle with icon') { + icon = ( + + + + ); + } else if (asset === 'circle with image') { + icon = ; + } + const button = actions.includes('button') ? ( Action @@ -95,6 +111,7 @@ export const Default: StoryComponent = ({ ) } + icon={icon} {...interactiveActions} extra={withExtra ? : undefined} onClose={closable ? () => {} : undefined} @@ -119,6 +136,7 @@ export const Default: StoryComponent = ({ Default.storyName = 'NakedCard'; Default.args = { + asset: 'none', media: 'image', headlineType: 'promo', headline: 'Priority', @@ -132,6 +150,10 @@ Default.args = { withTopAction: false, }; Default.argTypes = { + asset: { + options: ['circle with icon', 'circle with image', 'none'], + control: {type: 'select'}, + }, media: { options: ['image', 'circular image', 'video'], control: {type: 'select'}, diff --git a/src/__stories__/poster-card-story.tsx b/src/__stories__/poster-card-story.tsx index 2e78319a63..5d9738d726 100644 --- a/src/__stories__/poster-card-story.tsx +++ b/src/__stories__/poster-card-story.tsx @@ -29,7 +29,7 @@ const BACKGROUND_VIDEO_SRC = beachVideo; const BACKGROUND_VIDEO_POSTER_SRC = beachImg; type PosterCardArgs = { - asset: 'icon' | 'circle + icon' | 'image' | 'circle + image'; + asset: 'circle with icon' | 'circle with image' | 'none'; background: 'image' | 'video'; headlineType: TagType; headline: string; @@ -45,7 +45,7 @@ type PosterCardArgs = { }; export const Default: StoryComponent = ({ - asset = 'icon', + asset, background, headline, headlineType, @@ -60,13 +60,13 @@ export const Default: StoryComponent = ({ aspectRatio, }) => { let icon; - if (asset === 'circle + icon') { + if (asset === 'circle with icon') { icon = ( ); - } else if (asset === 'circle + image') { + } else if (asset === 'circle with image') { icon = ; } @@ -165,7 +165,7 @@ export const Default: StoryComponent = ({ Default.storyName = 'Poster card'; Default.args = { - asset: 'icon', + asset: 'none', headlineType: 'promo', background: 'image', headline: 'Priority', @@ -181,7 +181,7 @@ Default.args = { }; Default.argTypes = { asset: { - options: ['circle + icon', 'circle + image', 'none'], + options: ['circle with icon', 'circle with image', 'none'], control: {type: 'select'}, }, headlineType: { diff --git a/src/card.tsx b/src/card.tsx index ec6e30c186..1382a372bd 100644 --- a/src/card.tsx +++ b/src/card.tsx @@ -427,6 +427,7 @@ type MaybeTouchableCard = ExclusifyUnion | T>; interface MediaCardBaseProps { media: RendersElement | RendersElement; + icon?: React.ReactElement; headline?: string | RendersNullableElement; pretitle?: string; pretitleLinesMax?: number; @@ -435,7 +436,6 @@ interface MediaCardBaseProps { subtitle?: string; subtitleLinesMax?: number; description?: string; - icon?: React.ReactElement; descriptionLinesMax?: number; extra?: React.ReactNode; actions?: Array; @@ -458,6 +458,7 @@ export const MediaCard = React.forwardRef( ( { media, + icon, headline, pretitle, pretitleLinesMax, @@ -466,7 +467,6 @@ export const MediaCard = React.forwardRef( title, titleLinesMax, description, - icon, descriptionLinesMax, extra, actions, @@ -536,6 +536,7 @@ export const NakedCard = React.forwardRef( ( { media, + icon, headline, pretitle, pretitleLinesMax, @@ -594,6 +595,15 @@ export const NakedCard = React.forwardRef( buttonLink={buttonLink} /> + {icon && ( + + {icon} + + )} @@ -1271,15 +1281,19 @@ export const PosterCard = React.forwardRef( -
{icon ? ( - + {icon} ) : ( @@ -1290,7 +1304,7 @@ export const PosterCard = React.forwardRef( /> )} (
- +