Skip to content

Commit

Permalink
feat(PTIECBC03-4665): media-card circle
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoaraujo-tlf committed Jul 18, 2023
1 parent 8fc368a commit ce14917
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 0 deletions.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/__stories__/media-card-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ import {
Image,
Tag,
IconMobileDeviceRegular,
Circle,
skinVars,
} from '..';
import ResponsiveLayout from '../responsive-layout';
import {Placeholder} from '../placeholder';
import tennisImg from './images/tennis.jpg';
import confettiVideo from './videos/confetti.mp4';
import avatarImg from './images/avatar.jpg'

import type {TagType} from '..';

Expand All @@ -26,6 +29,7 @@ const VIDEO_SRC = confettiVideo;
const IMAGE_SRC = tennisImg;

type Args = {
asset: 'icon' | 'circle + icon' | 'image' | 'circle + image';
media: 'image' | 'video';
headlineType: TagType;
headline: string;
Expand All @@ -51,7 +55,19 @@ export const Default: StoryComponent<Args> = ({
closable,
withTopAction,
media,
asset
}) => {
let icon;
if(asset === 'circle + icon') {
icon = (
<Circle size={40} backgroundColor={skinVars.colors.brandLow}>
<IconMobileDeviceRegular color={skinVars.colors.brand} />
</Circle>
);
} else if(asset === 'circle + image'){
icon = <Circle size={40} backgroundImage={avatarImg} />
}

const button = actions.includes('button') ? (
<ButtonPrimary small href="https://google.com">
Action
Expand Down Expand Up @@ -79,6 +95,7 @@ export const Default: StoryComponent<Args> = ({
title={title}
subtitle={subtitle}
description={description}
icon={icon}
media={
media === 'video' ? (
<Video src={VIDEO_SRC} aspectRatio="16:9" dataAttributes={{qsysid: 'video'}} />
Expand Down Expand Up @@ -108,6 +125,7 @@ export const Default: StoryComponent<Args> = ({

Default.storyName = 'Media card';
Default.args = {
asset: 'icon',
media: 'image',
headlineType: 'promo',
headline: 'Priority',
Expand All @@ -121,6 +139,10 @@ Default.args = {
withTopAction: false,
};
Default.argTypes = {
asset: {
options: ['circle + icon', 'circle + image', 'none'],
control: {type: 'select'}
},
media: {
options: ['image', 'video'],
control: {type: 'select'},
Expand Down
16 changes: 16 additions & 0 deletions src/card.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ export const mediaCardContent = style([
},
]);

export const mediaCardIcon = style([
{
position: 'absolute',
zIndex: 1,
},
{
'@media': {
[mq.desktopOrBigger]: {
paddingLeft: 24,
paddingTop: 24,
paddingBottom: 32,
},
},
},
]);

export const dataCard = style([
sprinkles({
display: 'flex',
Expand Down
9 changes: 9 additions & 0 deletions src/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ interface MediaCardBaseProps {
subtitle?: string;
subtitleLinesMax?: number;
description?: string;
icon?: React.ReactElement
descriptionLinesMax?: number;
extra?: React.ReactNode;
actions?: Array<CardAction>;
Expand Down Expand Up @@ -437,6 +438,7 @@ export const MediaCard = React.forwardRef<HTMLDivElement, MediaCardProps>(
title,
titleLinesMax,
description,
icon,
descriptionLinesMax,
extra,
actions,
Expand Down Expand Up @@ -486,6 +488,13 @@ export const MediaCard = React.forwardRef<HTMLDivElement, MediaCardProps>(
buttonLink={buttonLink}
/>
</div>
{icon ? (
<Box className={styles.mediaCardIcon} paddingX={16} paddingY={16}>
{icon}
</Box>
): (
<Box paddingBottom={actions?.length || onClose ? 64 : 0} />
)}
</div>
</BaseTouchable>
</Boxed>
Expand Down

0 comments on commit ce14917

Please sign in to comment.