Skip to content

Commit a5b864b

Browse files
authored
Update ToggleSwitch.features.stories.tsx stories to no longer use styled-components (#6414)
1 parent 87843c2 commit a5b864b

File tree

2 files changed

+53
-25
lines changed

2 files changed

+53
-25
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.Row {
2+
display: flex;
3+
align-items: flex-start;
4+
gap: var(--base-size-16);
5+
}
6+
7+
.ColGrow {
8+
flex-grow: 1;
9+
}
10+
11+
.ToggleLabel {
12+
font-weight: var(--base-text-weight-semibold);
13+
font-size: var(--text-body-size-medium);
14+
display: block;
15+
}
16+
17+
.SwitchLabel {
18+
font-weight: var(--base-text-weight-semibold);
19+
font-size: var(--text-title-size-small);
20+
display: block;
21+
}
22+
23+
.SwitchCaption {
24+
color: var(--fgColor-muted);
25+
font-size: var(--text-body-size-medium);
26+
display: block;
27+
}

packages/react/src/ToggleSwitch/ToggleSwitch.features.stories.tsx

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,78 @@
11
import React from 'react'
22
import ToggleSwitch from './ToggleSwitch'
3-
import {Box, Text} from '..'
43
import {action} from 'storybook/actions'
54
import ToggleSwitchStoryWrapper from './ToggleSwitchStoryWrapper'
5+
import {clsx} from 'clsx'
6+
import styles from './ToggleSwitch.features.stories.module.css'
67

78
export default {
89
title: 'Components/ToggleSwitch/Features',
910
}
1011

1112
export const Small = () => (
1213
<ToggleSwitchStoryWrapper>
13-
<Text id="toggle" fontWeight={'bold'} fontSize={1}>
14+
<span id="toggle" className={styles.ToggleLabel}>
1415
Toggle label
15-
</Text>
16+
</span>
1617
<ToggleSwitch size="small" aria-labelledby="toggle" />
1718
</ToggleSwitchStoryWrapper>
1819
)
1920

2021
export const WithCaption = () => (
21-
<Box display="flex" alignItems={'start'}>
22-
<Box flexGrow={1}>
23-
<Text fontSize={2} fontWeight="bold" id="switchLabel" display="block">
22+
<div className={styles.Row}>
23+
<div className={styles.ColGrow}>
24+
<span className={styles.SwitchLabel} id="switchLabel">
2425
Notifications
25-
</Text>
26-
<Text color="fg.subtle" fontSize={1} id="switchCaption" display="block">
26+
</span>
27+
<span className={styles.SwitchCaption} id="switchCaption">
2728
Notifications will be delivered via email and the GitHub notification center
28-
</Text>
29-
</Box>
29+
</span>
30+
</div>
3031
<ToggleSwitch aria-labelledby="switchLabel" aria-describedby="switchCaption" />
31-
</Box>
32+
</div>
3233
)
3334

3435
export const Disabled = () => (
3536
<ToggleSwitchStoryWrapper>
36-
<Text id="toggle" fontWeight={'bold'} fontSize={1}>
37+
<span id="toggle" className={styles.ToggleLabel}>
3738
Toggle label
38-
</Text>
39+
</span>
3940
<ToggleSwitch disabled aria-labelledby="toggle" />
4041
</ToggleSwitchStoryWrapper>
4142
)
4243

4344
export const Checked = () => (
4445
<ToggleSwitchStoryWrapper>
45-
<Text id="toggle" fontWeight={'bold'} fontSize={1}>
46+
<span id="toggle" className={styles.ToggleLabel}>
4647
Toggle label
47-
</Text>
48+
</span>
4849
<ToggleSwitch checked aria-labelledby="toggle" />
4950
</ToggleSwitchStoryWrapper>
5051
)
5152

5253
export const CheckedDisabled = () => (
5354
<ToggleSwitchStoryWrapper>
54-
<Text id="toggle" fontWeight={'bold'} fontSize={1}>
55+
<span id="toggle" className={styles.ToggleLabel}>
5556
Toggle label
56-
</Text>
57+
</span>
5758
<ToggleSwitch checked disabled aria-labelledby="toggle" />
5859
</ToggleSwitchStoryWrapper>
5960
)
6061

6162
export const Loading = () => (
6263
<ToggleSwitchStoryWrapper>
63-
<Text id="toggle" fontWeight={'bold'} fontSize={1}>
64+
<span id="toggle" className={styles.ToggleLabel}>
6465
Toggle label
65-
</Text>
66+
</span>
6667
<ToggleSwitch loading aria-labelledby="toggle" />
6768
</ToggleSwitchStoryWrapper>
6869
)
6970

7071
export const LabelEnd = () => (
7172
<ToggleSwitchStoryWrapper>
72-
<Text id="toggle" fontWeight={'bold'} fontSize={1}>
73+
<span id="toggle" className={styles.ToggleLabel}>
7374
Toggle label
74-
</Text>
75+
</span>
7576
<ToggleSwitch statusLabelPosition="end" aria-labelledby="toggle" />
7677
</ToggleSwitchStoryWrapper>
7778
)
@@ -89,12 +90,12 @@ export const Controlled = () => {
8990

9091
return (
9192
<>
92-
<Box display="flex" maxWidth="300px">
93-
<Box flexGrow={1} fontSize={2} fontWeight="bold" id="switchLabel">
93+
<div className={styles.Row} style={{maxWidth: '300px'}}>
94+
<span className={clsx(styles.ColGrow, styles.SwitchLabel)} id="switchLabel">
9495
Notifications
95-
</Box>
96+
</span>
9697
<ToggleSwitch onClick={onClick} onChange={handleSwitchChange} checked={isOn} aria-labelledby="switchLabel" />
97-
</Box>
98+
</div>
9899
<p>The switch is {isOn ? 'on' : 'off'}</p>
99100
</>
100101
)

0 commit comments

Comments
 (0)