Skip to content

Commit 3916d46

Browse files
authored
Organize storybook TOC for react-theme (#26185)
* Separated different theme areas in storybook * yarn change * Update change/@fluentui-react-theme-04b2a905-c203-47f1-b3f1-493a4d6e50a7.json
1 parent 9f8fe44 commit 3916d46

19 files changed

+207
-158
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "Updated storybook docs",
4+
"packageName": "@fluentui/react-theme",
5+
"email": "gcox@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Meta, Canvas } from '@storybook/addon-docs';
2+
import { BorderRadii } from './ThemeBorderRadii.stories';
3+
4+
<Meta title="Theme/Border Radii" />
5+
6+
<h1 class="sbdocs-title">Border Radii</h1>
7+
8+
<Canvas withSource="none">
9+
<BorderRadii />
10+
</Canvas>

packages/react-components/react-theme/stories/Theme/colors/ColorRamp.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const ColorRampItem: React.FunctionComponent<ColorRampItemProps> = props
6060
justifyContent: 'space-between',
6161
padding: '1.5vh',
6262
background: props.value,
63-
width: '300px',
63+
width: '200px',
6464
boxSizing: 'border-box',
6565
alignItems: 'center',
6666
height: '100%',

packages/react-components/react-theme/stories/Theme/colors/ThemeColors.stories.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { ColorRampItem } from './ColorRamp.stories';
1212

1313
// FIXME: hardcoded theme
1414
const theme = {
15-
light: webLightTheme,
16-
dark: webDarkTheme,
15+
webLight: webLightTheme,
16+
webDark: webDarkTheme,
1717
teamsLight: teamsLightTheme,
1818
teamsDark: teamsDarkTheme,
19-
highContrast: teamsHighContrastTheme,
19+
teamsHighContrast: teamsHighContrastTheme,
2020
};
2121

2222
const colorPalette = {
@@ -97,7 +97,7 @@ const ColorButton: React.FunctionComponent<
9797
/>
9898
);
9999

100-
const neutralTokens = (Object.keys(theme.light) as Array<keyof Theme>).filter(tokenName =>
100+
const neutralTokens = (Object.keys(theme.webLight) as Array<keyof Theme>).filter(tokenName =>
101101
tokenName.match(/^color(?!Palette).*/),
102102
);
103103

@@ -109,7 +109,7 @@ export const Colors = () => {
109109
const tokens: Array<keyof Theme> =
110110
activeColor === 'neutral'
111111
? neutralTokens
112-
: (Object.keys(theme.light) as Array<keyof Theme>).filter(tokenName =>
112+
: (Object.keys(theme.webLight) as Array<keyof Theme>).filter(tokenName =>
113113
tokenName.startsWith(`colorPalette${activeColor}`),
114114
);
115115

@@ -123,7 +123,7 @@ export const Colors = () => {
123123
setColor={setColor}
124124
setPreviewColor={setPreviewColor}
125125
style={{
126-
background: theme.light.colorNeutralForeground1,
126+
background: theme.webLight.colorNeutralForeground1,
127127
}}
128128
/>
129129
{(Object.keys(colorPalette) as GlobalSharedColors[]).map(colorName => (
@@ -134,7 +134,7 @@ export const Colors = () => {
134134
setColor={setColor}
135135
setPreviewColor={setPreviewColor}
136136
style={{
137-
background: theme.light[`colorPalette${colorName}BorderActive` as keyof Theme],
137+
background: theme.webLight[`colorPalette${colorName}BorderActive` as keyof Theme],
138138
}}
139139
/>
140140
))}
@@ -164,7 +164,7 @@ export const Colors = () => {
164164
Teams Dark
165165
</h3>
166166
<h3 key="hrHC" style={{ padding: '1em', margin: 0 }}>
167-
High Contrast
167+
Teams High Contrast
168168
</h3>
169169
{tokens.map(name => [
170170
<div
@@ -173,11 +173,11 @@ export const Colors = () => {
173173
>
174174
{name}
175175
</div>,
176-
<ColorRampItem key={`${name}Light`} value={theme.light[name]} />,
177-
<ColorRampItem key={`${name}Dark`} value={theme.dark[name]} />,
176+
<ColorRampItem key={`${name}Light`} value={theme.webLight[name]} />,
177+
<ColorRampItem key={`${name}Dark`} value={theme.webDark[name]} />,
178178
<ColorRampItem key={`${name}TeamsLight`} value={theme.teamsLight[name]} />,
179179
<ColorRampItem key={`${name}TeamsDark`} value={theme.teamsDark[name]} />,
180-
<ColorRampItem key={`${name}HC`} value={theme.highContrast[name]} />,
180+
<ColorRampItem key={`${name}HC`} value={theme.teamsHighContrast[name]} />,
181181
])}
182182
</div>
183183
</>
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import { Meta, Canvas } from '@storybook/addon-docs';
22
import { Colors } from './ThemeColors.stories.tsx';
3-
import { Shadows } from './ThemeShadows.stories';
43

5-
<Meta title="Theme/Color" />
4+
<Meta title="Theme/Colors" />
65

76
<h1 class="sbdocs-title"> Colors </h1>
87

98
<Canvas withSource="none">
109
<Colors />
1110
</Canvas>
12-
13-
## Shadows
14-
15-
<Canvas withSource="none">
16-
<Shadows />
17-
</Canvas>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import * as React from 'react';
2+
import { makeStyles, teamsLightTheme } from '@fluentui/react-components';
3+
import type { FontFamilyTokens, FontSizeTokens, FontWeightTokens, LineHeightTokens } from '@fluentui/react-components';
4+
5+
const theme = teamsLightTheme;
6+
7+
const useStyles = makeStyles({
8+
propGrid: {
9+
display: 'grid',
10+
gridTemplateColumns: 'auto 1fr',
11+
gridTemplateRows: '1fr',
12+
rowGap: '10px',
13+
columnGap: '10px',
14+
fontFamily: theme.fontFamilyBase,
15+
alignContent: 'center',
16+
alignItems: 'center',
17+
},
18+
});
19+
20+
export const FontFamily = () => {
21+
const styles = useStyles();
22+
23+
const fontFamilies = Object.keys(theme).filter(tokenName =>
24+
tokenName.startsWith('fontFamily'),
25+
) as (keyof FontFamilyTokens)[];
26+
27+
return (
28+
<div className={styles.propGrid}>
29+
{fontFamilies.map(fontFamily => [
30+
<div key={fontFamily}>{fontFamily}</div>,
31+
<div key={`${fontFamily}-value`} style={{ fontFamily: `${theme[fontFamily]}` }}>
32+
{theme[fontFamily]}Font family {fontFamily}
33+
</div>,
34+
])}
35+
</div>
36+
);
37+
};
38+
39+
export const FontSize = () => {
40+
const styles = useStyles();
41+
42+
const fontSizes = Object.keys(theme).filter(tokenName =>
43+
tokenName.startsWith('fontSize'),
44+
) as (keyof FontSizeTokens)[];
45+
46+
return (
47+
<div className={styles.propGrid}>
48+
{fontSizes.map(fontSize => (
49+
<>
50+
<div key={fontSize}>{fontSize}</div>
51+
<div key={`${fontSize}-value`} style={{ fontSize: theme[fontSize], lineHeight: theme[fontSize] }}>
52+
{fontSize}
53+
</div>
54+
</>
55+
))}
56+
</div>
57+
);
58+
};
59+
60+
export const LineHeight = () => {
61+
const styles = useStyles();
62+
63+
const lineHeightKeys = Object.keys(theme).filter(tokenName =>
64+
tokenName.startsWith('lineHeight'),
65+
) as (keyof LineHeightTokens)[];
66+
67+
return (
68+
<div className={styles.propGrid}>
69+
{lineHeightKeys.map(lineHeight => [
70+
<div key={lineHeight}>{lineHeight}</div>,
71+
<div key={`${lineHeight}-value`} style={{ lineHeight: theme[lineHeight], backgroundColor: '#eee' }}>
72+
{lineHeight}
73+
</div>,
74+
])}
75+
</div>
76+
);
77+
};
78+
79+
export const FontWeight = () => {
80+
const styles = useStyles();
81+
82+
const fontWeights = Object.keys(theme).filter(tokenName =>
83+
tokenName.startsWith('fontWeight'),
84+
) as (keyof FontWeightTokens)[];
85+
86+
return (
87+
<div className={styles.propGrid}>
88+
{fontWeights.map(fontWeight => [
89+
<div key={fontWeight}>{fontWeight}</div>,
90+
<div key={`${fontWeight}-value`} style={{ fontWeight: theme[fontWeight] }}>
91+
Font weight {fontWeight}
92+
</div>,
93+
])}
94+
</div>
95+
);
96+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Meta, Canvas } from '@storybook/addon-docs';
2+
import { FontFamily, FontSize, FontWeight, LineHeight } from './ThemeFonts.stories';
3+
4+
<Meta title="Theme/Fonts" />
5+
6+
<h1 class="sbdocs-title">Fonts</h1>
7+
8+
### Font family
9+
10+
<Canvas withSource="none">
11+
<FontFamily />
12+
</Canvas>
13+
14+
### Font size
15+
16+
<Canvas withSource="none">
17+
<FontSize />
18+
</Canvas>
19+
20+
### Font weight
21+
22+
<Canvas withSource="none">
23+
<FontWeight />
24+
</Canvas>
25+
26+
### Line height
27+
28+
<Canvas withSource="none">
29+
<LineHeight />
30+
</Canvas>

packages/react-components/react-theme/stories/Theme/motion-size/index.stories.mdx

-39
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Meta, Canvas } from '@storybook/addon-docs';
2+
import { MotionCurves, MotionDuration } from './ThemeMotion.stories';
3+
4+
<Meta title="Theme/Motion" />
5+
6+
<h1 class="sbdocs-title">Motion</h1>
7+
8+
### Curves
9+
10+
<Canvas withSource="none">
11+
<MotionCurves />
12+
</Canvas>
13+
14+
### Durations
15+
16+
<Canvas withSource="none">
17+
<MotionDuration />
18+
</Canvas>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Meta, Canvas } from '@storybook/addon-docs';
2+
import { Shadows } from './ThemeShadows.stories';
3+
4+
<Meta title="Theme/Shadows" />
5+
6+
<h1 class="sbdocs-title"> Shadow </h1>
7+
8+
<Canvas withSource="none">
9+
<Shadows />
10+
</Canvas>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Meta, Canvas } from '@storybook/addon-docs';
2+
import { Spacing } from './ThemeSpacing.stories';
3+
4+
<Meta title="Theme/Spacing" />
5+
6+
<h1 class="sbdocs-title">Spacing</h1>
7+
8+
<Canvas withSource="none">
9+
<Spacing />
10+
</Canvas>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Meta, Canvas } from '@storybook/addon-docs';
2+
import { StrokeWidths } from './ThemeStrokeWidths.stories';
3+
4+
<Meta title="Theme/Stroke Widths" />
5+
6+
<h1 class="sbdocs-title">Stroke Widths</h1>
7+
8+
<Canvas withSource="none">
9+
<StrokeWidths />
10+
</Canvas>

0 commit comments

Comments
 (0)