Skip to content

Commit 94f410d

Browse files
CopilotHotell
andauthored
docs(react-badge): clarify brand-background demo in ColorAndAppearance story (#36570)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hotell <1223799+Hotell@users.noreply.github.com>
1 parent a03842a commit 94f410d

1 file changed

Lines changed: 33 additions & 11 deletions

File tree

packages/react-components/react-badge/stories/src/Badge/BadgeColorVsAppearance.stories.tsx

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,23 @@ const useStyles = makeStyles({
1212
},
1313
badge: {
1414
display: 'flex',
15+
alignItems: 'center',
1516
gap: tokens.spacingHorizontalS,
1617
},
1718
brand: {
1819
display: 'flex',
20+
alignItems: 'center',
21+
gap: tokens.spacingHorizontalS,
1922
backgroundColor: tokens.colorBrandBackground,
20-
padding: tokens.spacingHorizontalXXS,
23+
padding: `${tokens.spacingVerticalS} ${tokens.spacingHorizontalM}`,
24+
borderRadius: tokens.borderRadiusMedium,
25+
},
26+
brandLabel: {
27+
color: tokens.colorNeutralForegroundOnBrand,
28+
fontFamily: tokens.fontFamilyBase,
29+
fontSize: tokens.fontSizeBase200,
30+
lineHeight: tokens.lineHeightBase200,
31+
fontWeight: tokens.fontWeightSemibold,
2132
},
2233
});
2334

@@ -36,20 +47,29 @@ const Badges = (props: BadgeProps) => {
3647
'warning',
3748
];
3849

50+
const isSubtleOnBrandOnly = appearance === 'ghost' || appearance === 'outline';
51+
3952
return (
4053
<div className={styles.badge}>
4154
{colors.map(color => {
42-
const BadgeWrapper =
43-
color === 'subtle' && (appearance === 'ghost' || appearance === 'outline')
44-
? ({ children }: { children: React.ReactNode }) => <div className={styles.brand}>{children}</div>
45-
: React.Fragment;
55+
// `ghost-subtle` and `outline-subtle` are only meant to be used on a branded background,
56+
// so they are rendered within an explicit "brand surface" demo container instead of the
57+
// ambient story background.
58+
if (color === 'subtle' && isSubtleOnBrandOnly) {
59+
return (
60+
<div key={`${appearance}-${color}`} className={styles.brand}>
61+
<span className={styles.brandLabel}>On brand background:</span>
62+
<Badge appearance={appearance} color={color} icon={<PasteIcon />}>
63+
999+
64+
</Badge>
65+
</div>
66+
);
67+
}
4668

4769
return (
48-
<BadgeWrapper key={`${appearance}-${color}`}>
49-
<Badge appearance={appearance} color={color} icon={<PasteIcon />}>
50-
999+
51-
</Badge>
52-
</BadgeWrapper>
70+
<Badge key={`${appearance}-${color}`} appearance={appearance} color={color} icon={<PasteIcon />}>
71+
999+
72+
</Badge>
5373
);
5474
})}
5575
</div>
@@ -76,7 +96,9 @@ export const ColorAndAppearance = (): JSXElement => {
7696
ColorAndAppearance.parameters = {
7797
docs: {
7898
description: {
79-
story: 'Note: `ghost-subtle` and `outline-subtle` are intended only for use on brand background.',
99+
story:
100+
'`ghost-subtle` and `outline-subtle` are intended only for use on a branded background — ' +
101+
'the boxed "On brand background:" examples above demonstrate the intended usage context.',
80102
},
81103
},
82104
};

0 commit comments

Comments
 (0)