Skip to content

Commit 129c918

Browse files
authored
Merge pull request #463 from mashmatrix/support-slds-2-media-object
Update `MediaObject` for SLDS2
2 parents b3383e4 + 3cb63b5 commit 129c918

File tree

2 files changed

+54
-13
lines changed

2 files changed

+54
-13
lines changed

src/scripts/MediaObject.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,23 @@ import classnames from 'classnames';
77
export type MediaObjectProps = {
88
figureLeft?: ReactNode;
99
figureRight?: ReactNode;
10-
figureCenter?: ReactNode;
10+
centered?: boolean;
1111
children?: ReactNode;
1212
} & HTMLAttributes<HTMLDivElement>;
1313

1414
/**
1515
*
1616
*/
1717
export const MediaObject: FC<MediaObjectProps> = (props) => {
18-
const {
19-
className,
20-
figureLeft,
21-
figureRight,
22-
figureCenter,
23-
children,
24-
...rprops
25-
} = props;
26-
const mediaClassNames = classnames('slds-media', className);
18+
const { className, figureLeft, figureRight, centered, children, ...rprops } =
19+
props;
20+
const mediaClassNames = classnames(
21+
'slds-media',
22+
{ 'slds-media_center': centered },
23+
className
24+
);
2725
return (
2826
<div className={mediaClassNames} {...rprops}>
29-
{figureCenter ? (
30-
<div className='slds-media__figure'>{figureCenter}</div>
31-
) : undefined}
3227
{figureLeft ? (
3328
<div className='slds-media__figure'>{figureLeft}</div>
3429
) : undefined}

stories/MediaObject.stories.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ export const Figure: ComponentStoryObj<typeof MediaObject> = {
5050
},
5151
};
5252

53+
/**
54+
*
55+
*/
56+
export const FigureCenter: ComponentStoryObj<typeof MediaObject> = {
57+
name: 'Figure (Center)',
58+
args: {
59+
figureLeft: image1,
60+
centered: true,
61+
children: mediaContent,
62+
},
63+
parameters: {
64+
info: 'Vertically centered Media Object with figure in left',
65+
},
66+
};
67+
5368
/**
5469
*
5570
*/
@@ -64,6 +79,21 @@ export const FigureReverse: ComponentStoryObj<typeof MediaObject> = {
6479
},
6580
};
6681

82+
/**
83+
*
84+
*/
85+
export const FigureReverseCenter: ComponentStoryObj<typeof MediaObject> = {
86+
name: 'Figure - Reverse (Center)',
87+
args: {
88+
figureRight: image2,
89+
centered: true,
90+
children: mediaContent,
91+
},
92+
parameters: {
93+
info: 'Vertically centered Media Object with figure in right',
94+
},
95+
};
96+
6797
/**
6898
*
6999
*/
@@ -78,3 +108,19 @@ export const FigureBothSide: ComponentStoryObj<typeof MediaObject> = {
78108
info: 'Media Object with figure in left and right',
79109
},
80110
};
111+
112+
/**
113+
*
114+
*/
115+
export const FigureBothSideCenter: ComponentStoryObj<typeof MediaObject> = {
116+
name: 'Figure - Both Side (Center)',
117+
args: {
118+
figureLeft: image1,
119+
figureRight: image2,
120+
centered: true,
121+
children: mediaContent,
122+
},
123+
parameters: {
124+
info: 'Vertically centered Media Object with figure in left and right',
125+
},
126+
};

0 commit comments

Comments
 (0)