Skip to content

Commit 1d59236

Browse files
stefankpCopilotrezrah
authored
Fix missing form-control color tokens in the ESM build (#1417)
* Fix ESM build dropping form-control color tokens The `--brand-control-*` color tokens only reached CSS through a shared side-effect import in the forms barrel (`src/forms/index.ts`), which the ESM build's tree-shaking dropped. As a result, consumers importing from `@primer/react-brand/esm` without the global `lib/css/main.css` lost all form-control borders and boxes (checkboxes and radios rendered invisible). Co-locate the control `colors-with-modes.css` import in each form component (TextInput, Textarea, Select, Checkbox, Radio, FormControl), matching the established Button pattern, so the tokens ride along in the component modules that are unavoidably included when the components are used. Remove the now-redundant barrel import. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: afd2ea59-8442-4214-bd4b-ecc92d8987a5 * Update .changeset/fix-esm-control-color-tokens.md Co-authored-by: Rez <13340707+rezrah@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Rez <13340707+rezrah@users.noreply.github.com> Copilot-Session: afd2ea59-8442-4214-bd4b-ecc92d8987a5
1 parent 9b8ccce commit 1d59236

8 files changed

Lines changed: 11 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react-brand': patch
3+
---
4+
5+
Fixed missing styles for ESM form controls, where the dependent design tokens were missing . Affects `TextInput`, `Textarea`, `Select`, `Checkbox`, `Radio`, and `FormControl`.

packages/react/src/forms/Checkbox/Checkbox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {BaseProps} from '../../component-helpers'
66
import type {FormValidationStatus} from '../form-types'
77
import useLayoutEffect from '../../hooks/useIsomorphicLayoutEffect'
88

9+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css'
910
import styles from './Checkbox.module.css'
1011
import {useProvidedRefOrCreate} from '../../hooks/useRef'
1112

packages/react/src/forms/FormControl/FormControl.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {Textarea} from '../Textarea'
1313
import {Radio} from '../Radio'
1414
import {Text} from '../../Text'
1515

16+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css'
1617
import styles from './FormControl.module.css'
1718

1819
export type FormControlProps = BaseProps<HTMLElement> & {

packages/react/src/forms/Radio/Radio.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {useProvidedRefOrCreate} from '../../hooks/useRef'
55

66
import type {BaseProps} from '../../component-helpers'
77

8+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css'
89
import styles from './Radio.module.css'
910

1011
export type RadioProps = {

packages/react/src/forms/Select/Select.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {clsx} from 'clsx'
44
import type {BaseProps} from '../../component-helpers'
55
import type {FormInputSizes, FormValidationStatus} from '../form-types'
66

7+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css'
78
import styles from './Select.module.css'
89

910
export type SelectProps = {

packages/react/src/forms/TextInput/TextInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {BaseProps} from '../../component-helpers'
66
import type {FormInputSizes, FormValidationStatus} from '../form-types'
77
import {Text} from '../../Text'
88

9+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css'
910
import styles from './TextInput.module.css'
1011
import type {Icon} from '@primer/octicons-react'
1112

packages/react/src/forms/Textarea/Textarea.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {clsx} from 'clsx'
44
import type {BaseProps} from '../../component-helpers'
55
import type {FormInputSizes, FormValidationStatus} from '../form-types'
66

7+
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css'
78
import styles from './Textarea.module.css'
89

910
export const DEFAULT_TEXTAREA_ROWS = 7

packages/react/src/forms/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/**
2-
* Shared form (control) design tokens
3-
*/
4-
import '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css'
5-
61
export * from './Checkbox'
72
export * from './Textarea'
83
export * from './TextInput'

0 commit comments

Comments
 (0)