Skip to content

Commit a88fd46

Browse files
authored
Update FormControl.features.stories.tsx to no longer use styled-components (#6454)
1 parent 3bd237c commit a88fd46

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.GridContainer {
2+
display: grid;
3+
}
4+
5+
.GapContainer {
6+
display: grid;
7+
gap: var(--stack-gap-normal);
8+
}
9+
10+
.FlexColumnGapContainer {
11+
display: flex;
12+
flex-direction: column;
13+
gap: var(--stack-gap-normal);
14+
}
15+
16+
.RequiredFieldsNote {
17+
font-size: var(--text-body-size-medium);
18+
}
19+
20+
.ColorCircle {
21+
display: block;
22+
width: 14px;
23+
height: 14px;
24+
border-radius: var(--borderRadius-large);
25+
margin: auto;
26+
border: var(--borderWidth-default) solid;
27+
box-sizing: border-box;
28+
}

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

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type {Meta} from '@storybook/react-vite'
33
import {
44
Autocomplete,
55
BaseStyles,
6-
Box,
76
Button,
87
Checkbox,
98
CheckboxGroup,
@@ -22,6 +21,7 @@ import {
2221
import {MarkGithubIcon, TriangleDownIcon} from '@primer/octicons-react'
2322
import type {ItemInput} from '../deprecated/ActionList/List'
2423
import {Stack} from '../Stack'
24+
import classes from './FormControl.features.stories.module.css'
2525

2626
export default {
2727
title: 'Components/FormControl/Features',
@@ -78,7 +78,7 @@ export const WithComplexInputs = () => {
7878
}
7979

8080
return (
81-
<Box display="grid">
81+
<div className={classes.GridContainer}>
8282
<FormControl>
8383
<FormControl.Label id="form-label">TextInputWithTokens</FormControl.Label>
8484
<TextInputWithTokens onTokenRemove={onTokenRemove} tokens={tokens} />
@@ -117,7 +117,7 @@ export const WithComplexInputs = () => {
117117
<FormControl.Label>Textarea</FormControl.Label>
118118
<Textarea />
119119
</FormControl>
120-
</Box>
120+
</div>
121121
)
122122
}
123123

@@ -149,7 +149,7 @@ export const FormControlWithCustomInput = () => {
149149
}, [value])
150150

151151
return (
152-
<Box display="grid">
152+
<div className={classes.GridContainer}>
153153
<FormControl>
154154
<FormControl.Label htmlFor="custom-input">GitHub handle</FormControl.Label>
155155
<CustomTextInput
@@ -194,13 +194,13 @@ export const FormControlWithCustomInput = () => {
194194
<FormControl.Caption id="custom-checkbox-two-caption">Hint text for checkbox two</FormControl.Caption>
195195
</FormControl>
196196
</CheckboxGroup>
197-
</Box>
197+
</div>
198198
)
199199
}
200200

201201
export const WithCheckboxAndRadioInputs = () => {
202202
return (
203-
<Box display="grid" sx={{gap: 3}}>
203+
<div className={classes.GapContainer}>
204204
<CheckboxGroup>
205205
<CheckboxGroup.Label>Checkboxes</CheckboxGroup.Label>
206206
<FormControl>
@@ -232,7 +232,7 @@ export const WithCheckboxAndRadioInputs = () => {
232232
<FormControl.Label>Radio three</FormControl.Label>
233233
</FormControl>
234234
</RadioGroup>
235-
</Box>
235+
</div>
236236
)
237237
}
238238

@@ -280,16 +280,11 @@ export const ValidationExample = () => {
280280
function getColorCircle(color: string) {
281281
return function () {
282282
return (
283-
<Box
284-
sx={{
283+
<span
284+
className={classes.ColorCircle}
285+
style={{
285286
backgroundColor: color,
286287
borderColor: color,
287-
width: 14,
288-
height: 14,
289-
borderRadius: 10,
290-
margin: 'auto',
291-
borderWidth: '1px',
292-
borderStyle: 'solid',
293288
}}
294289
/>
295290
)
@@ -379,7 +374,7 @@ export const WithLeadingVisual = () => (
379374
)
380375

381376
export const DisabledInputs = () => (
382-
<Box sx={{display: 'flex', flexDirection: 'column', gap: '1rem'}}>
377+
<div className={classes.FlexColumnGapContainer}>
383378
<FormControl disabled>
384379
<FormControl.Label>Disabled checkbox</FormControl.Label>
385380
<Checkbox />
@@ -397,18 +392,18 @@ export const DisabledInputs = () => (
397392
<Select.Option value="pvc">Primer ViewComponents</Select.Option>
398393
</Select>
399394
</FormControl>
400-
</Box>
395+
</div>
401396
)
402397

403398
export const CustomRequired = () => (
404-
<Box sx={{display: 'flex', flexDirection: 'column', gap: '1rem'}}>
399+
<div className={classes.FlexColumnGapContainer}>
405400
<FormControl required={true}>
406401
<FormControl.Label requiredText="(required)">Form Input Label</FormControl.Label>
407402
<FormControl.Caption>This is a form field with a custom required indicator</FormControl.Caption>
408403
<TextInput />
409404
</FormControl>
410405

411-
<Text sx={{fontSize: 1}}>Required fields are marked with an asterisk (*)</Text>
406+
<Text className={classes.RequiredFieldsNote}>Required fields are marked with an asterisk (*)</Text>
412407
<FormControl required={true}>
413408
<FormControl.Label requiredIndicator={false}>Form Input Label</FormControl.Label>
414409
<FormControl.Caption>
@@ -424,7 +419,7 @@ export const CustomRequired = () => (
424419
<FormControl.Caption>This is a form field that is marked as optional, it is not required</FormControl.Caption>
425420
<TextInput />
426421
</FormControl>
427-
</Box>
422+
</div>
428423
)
429424

430425
export const WithCaption = () => (

0 commit comments

Comments
 (0)