Skip to content

Commit 8398647

Browse files
author
André Dias (he/him)
authored
react-card - CardPreview top padding fix (#20030)
1 parent 9b1ea8c commit 8398647

5 files changed

Lines changed: 18 additions & 3 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "CardPreview removes own top margin when the first element in a Card",
4+
"packageName": "@fluentui/react-card",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react-card/src/components/Card.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const GridviewCard = () => (
9696
maxWidth: '368px',
9797
}}
9898
>
99-
<CardPreview style={{ marginTop: '-12px' }}>
99+
<CardPreview>
100100
<img src="./sales_template.png" alt="Preview of a sales slide deck" />
101101
</CardPreview>
102102
<CardHeader

packages/react-card/src/components/Card/useCardStyles.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ const useStyles = makeStyles({
2020
padding: '12px',
2121
gap: '12px',
2222
borderRadius: theme.borderRadiusMedium,
23+
24+
'> .fluentui-react-card-preview': {
25+
marginLeft: '-12px',
26+
marginRight: '-12px',
27+
'&:first-child': {
28+
marginTop: '-12px',
29+
},
30+
},
2331
}),
2432

2533
interactive: theme => ({

packages/react-card/src/components/CardPreview/__snapshots__/CardPreview.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`CardPreview renders a default state 1`] = `
44
<div>
55
<div
6-
class=""
6+
class="fluentui-react-card-preview"
77
>
88
Default CardPreview
99
<div

packages/react-card/src/components/CardPreview/useCardPreviewStyles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const useStyles = makeStyles({
3030
*/
3131
export const useCardPreviewStyles = (state: CardPreviewState): CardPreviewState => {
3232
const styles = useStyles();
33-
state.className = mergeClasses(styles.root, state.className);
33+
state.className = mergeClasses('fluentui-react-card-preview', styles.root, state.className);
3434

3535
if (state.logo) {
3636
state.logo.className = mergeClasses(styles.logo, state.logo.className);

0 commit comments

Comments
 (0)