@codecademy/gamut 68.6.1-alpha.e6c390.0 → 68.6.1-alpha.f6b2ce.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-tools/.cursor-plugin/plugin.json +1 -1
- package/agent-tools/DESIGN.Codecademy.md +239 -191
- package/agent-tools/DESIGN.LXStudio.md +236 -184
- package/agent-tools/DESIGN.Percipio.md +232 -182
- package/agent-tools/DESIGN.md +1 -1
- package/agent-tools/commands/gamut-review.md +176 -87
- package/agent-tools/guidelines/components/animations.md +74 -0
- package/agent-tools/guidelines/components/buttons.md +74 -23
- package/agent-tools/guidelines/components/card.md +19 -0
- package/agent-tools/guidelines/components/coachmark.md +21 -0
- package/agent-tools/guidelines/components/data-table.md +79 -0
- package/agent-tools/guidelines/components/forms.md +106 -0
- package/agent-tools/guidelines/components/loading-states.md +17 -0
- package/agent-tools/guidelines/components/menu.md +58 -0
- package/agent-tools/guidelines/components/overview.md +97 -17
- package/agent-tools/guidelines/components/radial-progress.md +13 -0
- package/agent-tools/guidelines/components/select.md +23 -0
- package/agent-tools/guidelines/components/tooltips.md +22 -0
- package/agent-tools/guidelines/components/video.md +29 -0
- package/agent-tools/guidelines/foundations/color.md +140 -58
- package/agent-tools/guidelines/foundations/modes.md +39 -17
- package/agent-tools/guidelines/foundations/spacing.md +78 -37
- package/agent-tools/guidelines/foundations/typography.md +69 -37
- package/agent-tools/guidelines/overview-icons.md +19 -0
- package/agent-tools/guidelines/overview-illustrations.md +7 -0
- package/agent-tools/guidelines/overview-patterns.md +7 -0
- package/agent-tools/guidelines/overview.md +69 -23
- package/agent-tools/guidelines/setup.md +59 -18
- package/agent-tools/rules/accessibility.mdc +22 -13
- package/agent-tools/skills/gamut-accessibility/SKILL.md +97 -112
- package/agent-tools/skills/gamut-color-mode/SKILL.md +79 -29
- package/agent-tools/skills/gamut-components/SKILL.md +46 -0
- package/agent-tools/skills/gamut-forms/SKILL.md +101 -0
- package/agent-tools/skills/gamut-style-utilities/SKILL.md +111 -0
- package/agent-tools/skills/gamut-system-props/SKILL.md +70 -26
- package/agent-tools/skills/gamut-testing/SKILL.md +106 -62
- package/agent-tools/skills/gamut-theming/SKILL.md +34 -86
- package/agent-tools/skills/gamut-typography/SKILL.md +36 -80
- package/bin/commands/plugin/install.mjs +96 -56
- package/bin/commands/plugin/list.mjs +11 -43
- package/bin/commands/plugin/remove.mjs +30 -38
- package/bin/commands/plugin/update.mjs +15 -5
- package/bin/gamut.mjs +17 -13
- package/bin/lib/design.mjs +71 -0
- package/bin/lib/io.mjs +14 -0
- package/package.json +6 -6
- package/bin/lib/figma.mjs +0 -49
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gamut-forms
|
|
3
|
+
description: Implementing or auditing Gamut forms — GridForm, ConnectedForm, FormGroup, labels, validation. When invoked, read guidelines/components/forms.md first. Pair with gamut-accessibility for non-form widgets.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Gamut forms
|
|
7
|
+
|
|
8
|
+
## Read first
|
|
9
|
+
|
|
10
|
+
When this skill applies, read [`guidelines/components/forms.md`](../../guidelines/components/forms.md) before writing code.
|
|
11
|
+
|
|
12
|
+
Canonical wiring for `FormGroup`, `ConnectedForm`, `ConnectedFormGroup`, `GridForm`, and field renderers. Source: `packages/gamut/src/Form/`, `ConnectedForm/`, `GridForm/`.
|
|
13
|
+
|
|
14
|
+
Universal label and primitive guidance: [`accessibility.mdc`](../../rules/accessibility.mdc) · overlay and composite patterns: [`gamut-accessibility`](../gamut-accessibility/SKILL.md).
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Mandatory: use organisms for functional forms
|
|
19
|
+
|
|
20
|
+
Functional forms (submit/save, validation, dirty state) must use `GridForm` or `ConnectedForm`. Do not compose from bare `Input`, `Select`, `Checkbox`, etc.
|
|
21
|
+
|
|
22
|
+
| Organism | When |
|
|
23
|
+
| --------------- | -------------------------------------------------------- |
|
|
24
|
+
| `GridForm` | Declarative `fields` + `submit` — settings, CRUD dialogs |
|
|
25
|
+
| `ConnectedForm` | Custom layout with managed `react-hook-form` state |
|
|
26
|
+
|
|
27
|
+
Rules: Always set `defaultValues`. Use `validation="onChange"` when submit should stay disabled until valid. `hideLabel: true` on checkbox/radio fields with no `label`, and on toggle (`custom`) fields where `Toggle` renders its own label.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Prefer connected layouts
|
|
32
|
+
|
|
33
|
+
For typical product forms, prefer `GridForm` (declarative `fields`, `LayoutGrid`, submit/cancel) or `ConnectedForm` with `ConnectedFormGroup` / `useConnectedForm`. Use raw `FormGroup` + atoms only when the layout is simple and you fully own `id`, `htmlFor`, invalid state, and any `aria-describedby` (see below).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Labels and controls
|
|
38
|
+
|
|
39
|
+
`htmlFor` / `id` pairing — universal rule in [`accessibility.mdc`](../../rules/accessibility.mdc) (Form label association). Form-specific notes:
|
|
40
|
+
|
|
41
|
+
- `FormGroupLabel` → control `id` (or stable `name` when that is your field’s id convention).
|
|
42
|
+
- Checkbox, Radio, Select: same pairing; checkbox/radio use the visually hidden input pattern from `@codecademy/gamut-styles` where applicable.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## `FormGroup` (baseline)
|
|
47
|
+
|
|
48
|
+
[`FormGroup.tsx`](https://github.com/Codecademy/gamut/blob/main/packages/gamut/src/Form/elements/FormGroup.tsx)
|
|
49
|
+
|
|
50
|
+
- `description` → `FormGroupDescription` with `aria-live="assertive"`.
|
|
51
|
+
- `error` (string) → `FormError` with `aria-live="polite"` and `role="alert"`.
|
|
52
|
+
|
|
53
|
+
Raw `FormGroup` does not set `aria-describedby` or `aria-invalid` on `children`. If you compose fields outside `ConnectedFormGroup` / `GridForm`, wire those yourself or accept that only the live regions above communicate errors/descriptions.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## `ConnectedFormGroup`
|
|
58
|
+
|
|
59
|
+
[`ConnectedFormGroup.tsx`](https://github.com/Codecademy/gamut/blob/main/packages/gamut/src/ConnectedForm/ConnectedFormGroup.tsx)
|
|
60
|
+
|
|
61
|
+
- Passes `aria-describedby` (error region id when shown) and `aria-invalid` on the rendered field component.
|
|
62
|
+
- `FormError`: `aria-live="assertive"` and `role="alert"` only when `isFirstError`; otherwise `aria-live="off"` and `role="status"` so subsequent errors do not interrupt repeatedly.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## `GridForm`
|
|
67
|
+
|
|
68
|
+
[`GridFormInputGroup/index.tsx`](https://github.com/Codecademy/gamut/blob/main/packages/gamut/src/GridForm/GridFormInputGroup/index.tsx) · [`GridFormTextInput`](https://github.com/Codecademy/gamut/blob/main/packages/gamut/src/GridForm/GridFormInputGroup/GridFormTextInput/index.tsx)
|
|
69
|
+
|
|
70
|
+
- Composes `ConnectedForm`, `LayoutGrid`, `GridFormButtons`, and field metadata. `FormError` uses the same first-error assertive pattern as `ConnectedFormGroup` (`aria-live` assertive vs off, `role` alert vs status).
|
|
71
|
+
- Built-in text inputs set `aria-invalid` and register with react-hook-form via `register`. Custom / `custom` / `custom-group` renderers must still expose correct `id`, `label`, and error surfacing consistent with this pattern.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Live regions — do not double up
|
|
76
|
+
|
|
77
|
+
`FormGroup`, `ConnectedFormGroup`, and `GridForm` already render `FormError` (and base `FormGroup` renders `FormGroupDescription`) with live-region attributes. Do not add a second `aria-live` wrapper for the same message stream.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Storybook
|
|
82
|
+
|
|
83
|
+
- [Organisms / GridForm / About](https://gamut.codecademy.com/?path=/docs-organisms-gridform-about--docs) · [Usage](https://gamut.codecademy.com/?path=/docs-organisms-gridform-usage--docs) · [Validation](https://gamut.codecademy.com/?path=/docs-organisms-gridform-validation--docs) · [Fields](https://gamut.codecademy.com/?path=/docs-organisms-gridform-fields--docs)
|
|
84
|
+
- [Organisms / ConnectedForm / ConnectedForm](https://gamut.codecademy.com/?path=/docs-organisms-connectedform-connectedform--docs) · [ConnectedFormGroup](https://gamut.codecademy.com/?path=/docs-organisms-connectedform-connectedformgroup--docs)
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Example — baseline `FormGroup`
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
<FormGroup
|
|
92
|
+
htmlFor="email-input"
|
|
93
|
+
description="Used for login"
|
|
94
|
+
error={errors.email}
|
|
95
|
+
>
|
|
96
|
+
<FormGroupLabel htmlFor="email-input">Email</FormGroupLabel>
|
|
97
|
+
<Input id="email-input" type="email" />
|
|
98
|
+
</FormGroup>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
When using `ConnectedFormGroup` or `GridForm`, prefer their docs and defaults over hand-rolling the above for every field.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gamut-style-utilities
|
|
3
|
+
description: css(), variant(), states(), StyleProps, useTheme from @codecademy/gamut-styles. When invoked, read guidelines/foundations/color.md for semantic tokens.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Gamut style utilities
|
|
7
|
+
|
|
8
|
+
## Read first
|
|
9
|
+
|
|
10
|
+
When this skill applies, read [`guidelines/foundations/color.md`](../../guidelines/foundations/color.md) before choosing color tokens in `css` / `variant` / `states`.
|
|
11
|
+
|
|
12
|
+
Source: `@codecademy/gamut-styles` — [`variance/props.ts`](https://github.com/Codecademy/gamut/blob/main/packages/gamut-styles/src/variance/props.ts) (`css`, `variant`, `states` built on `PROPERTIES.all`).
|
|
13
|
+
|
|
14
|
+
See also: [`gamut-theming`](../gamut-theming/SKILL.md) (which theme, `GamutProvider`, new themes). [`gamut-system-props`](../gamut-system-props/SKILL.md) (`system.*`, responsive props, `Box`). [`gamut-color-mode`](../gamut-color-mode/SKILL.md) (semantic color, `<ColorMode>`, `<Background>`). [Best practices](../../../../styleguide/src/lib/Meta/Best%20practices.mdx) and [system compose](https://gamut.codecademy.com/?path=/docs-foundations-system-compose--page).
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
Use `css()`, `variant()`, and `states()` from `@codecademy/gamut-styles` for typed, token-scaled style objects (same scales as composed `system.*` props). Prefer semantic color keys so styles track ColorMode and theme.
|
|
19
|
+
|
|
20
|
+
For layout-heavy styled components, prefer composing `system.*` via `variance.compose()` (see `gamut-system-props`) instead of re-stating every longhand in `css()`.
|
|
21
|
+
|
|
22
|
+
## `css()` — static style objects
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { css } from '@codecademy/gamut-styles';
|
|
26
|
+
import styled from '@emotion/styled';
|
|
27
|
+
|
|
28
|
+
const Box = styled.div(css({ bg: 'navy-400', p: 4 }));
|
|
29
|
+
const Text = styled.div(css({ color: 'primary', p: 4 }));
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## `variant()` and `states()` — branching and toggles
|
|
33
|
+
|
|
34
|
+
- `variant()` — mutually exclusive modes: `base`, `defaultVariant`, and a `variants` map (semantic colors, spacing shorthands, nested selectors such as `'&:hover'`).
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { variant } from '@codecademy/gamut-styles';
|
|
38
|
+
import styled from '@emotion/styled';
|
|
39
|
+
|
|
40
|
+
const Anchor = styled.a(
|
|
41
|
+
variant({
|
|
42
|
+
base: { p: 4 },
|
|
43
|
+
defaultVariant: 'interface',
|
|
44
|
+
variants: {
|
|
45
|
+
interface: {
|
|
46
|
+
color: 'text',
|
|
47
|
+
'&:hover': { color: 'text-accent' },
|
|
48
|
+
},
|
|
49
|
+
inline: {
|
|
50
|
+
color: 'primary',
|
|
51
|
+
'&:hover': { color: 'secondary' },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- `states()` — independent boolean-style props (`base` + named keys).
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { states } from '@codecademy/gamut-styles';
|
|
62
|
+
import styled from '@emotion/styled';
|
|
63
|
+
|
|
64
|
+
const UtilityBox = styled.div(
|
|
65
|
+
states({
|
|
66
|
+
base: { mx: 4, my: 8, p: 16 },
|
|
67
|
+
disabled: { bg: 'background-disabled', color: 'text-disabled' },
|
|
68
|
+
center: { alignItems: 'center', justifyContent: 'center' },
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `StyleProps` on React components
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { states } from '@codecademy/gamut-styles';
|
|
77
|
+
import { StyleProps } from '@codecademy/variance';
|
|
78
|
+
import styled from '@emotion/styled';
|
|
79
|
+
|
|
80
|
+
const panelShellStates = states({ base: { p: 4 }, dense: { p: 2 } });
|
|
81
|
+
const PanelShell = styled.div(panelShellStates);
|
|
82
|
+
|
|
83
|
+
export type PanelShellProps = StyleProps<typeof panelShellStates> & {
|
|
84
|
+
title: string;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const Panel: React.FC<PanelShellProps> = ({ title, ...rest }) => (
|
|
88
|
+
<PanelShell {...rest}>{title}</PanelShell>
|
|
89
|
+
);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Prefer `variant` / `states` over branching on raw `theme` fields inside styled template literals when the output is Emotion-managed CSS.
|
|
93
|
+
|
|
94
|
+
## `useTheme()` — escape hatch
|
|
95
|
+
|
|
96
|
+
Prefer `css()`, `system.*`, `variant()`, and `states()` for styling. Use `useTheme()` from `@emotion/react` when a token value must be read in plain JS (charts, canvas, third-party props), not as the default way to color DOM nodes.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import { useTheme } from '@emotion/react';
|
|
100
|
+
|
|
101
|
+
const Sparkline = () => {
|
|
102
|
+
const theme = useTheme();
|
|
103
|
+
return <path strokeWidth={theme.spacing[4]} d="M0 0 L10 10" />;
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Key principles
|
|
108
|
+
|
|
109
|
+
- Prefer semantic color keys in `css` / `variant` / `states` so ColorMode and theme switches apply; see `gamut-color-mode`.
|
|
110
|
+
- Never hardcode hex in component styles — use tokens / semantic aliases.
|
|
111
|
+
- Prefer `variant` / `states` for modes and toggles instead of ad-hoc `theme` interpolation in template literals.
|
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: gamut-system-props
|
|
3
|
-
description:
|
|
3
|
+
description: Layout, spacing, color, flex, grid system props from @codecademy/gamut-styles. When invoked, read guidelines/foundations/spacing.md first.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Gamut System Props
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Read first
|
|
9
|
+
|
|
10
|
+
When this skill applies, read [`guidelines/foundations/spacing.md`](../../guidelines/foundations/spacing.md) before writing code.
|
|
11
|
+
|
|
12
|
+
Source: `@codecademy/gamut-styles` — [`variance/config.ts`](https://github.com/Codecademy/gamut/blob/main/packages/gamut-styles/src/variance/config.ts) (definitions) and [`variance/props.ts`](https://github.com/Codecademy/gamut/blob/main/packages/gamut-styles/src/variance/props.ts) (`variance.create` groups). `Box`, `FlexBox`, and `GridBox` compose the same groups in [`packages/gamut/src/Box/props.ts`](https://github.com/Codecademy/gamut/blob/main/packages/gamut/src/Box/props.ts).
|
|
13
|
+
|
|
14
|
+
See also: [`gamut-style-utilities`](../gamut-style-utilities/SKILL.md) (`css`, `variant`, `states`, `StyleProps`). [foundations/spacing.md](../../guidelines/foundations/spacing.md) (token scale). [Styleguide — Best practices](../../../../styleguide/src/lib/Meta/Best%20practices.mdx) and Storybook [Responsive properties](https://gamut.codecademy.com/storybook/?path=/docs-foundations-system-responsive-properties--page).
|
|
15
|
+
|
|
16
|
+
## Styling rules
|
|
17
|
+
|
|
18
|
+
- Never use inline `style` attributes. Use system props on `Box` / `FlexBox` / `Text`, or `css` / `variant` / `states` on styled components.
|
|
19
|
+
- Use shorthand — `mb={16}`, not `marginBottom={16}`.
|
|
20
|
+
|
|
21
|
+
| Long form | Shorthand |
|
|
22
|
+
| -------------- | --------- |
|
|
23
|
+
| `margin` | `m` |
|
|
24
|
+
| `marginTop` | `mt` |
|
|
25
|
+
| `marginBottom` | `mb` |
|
|
26
|
+
| `marginX` | `mx` |
|
|
27
|
+
| `marginY` | `my` |
|
|
28
|
+
| `padding` | `p` |
|
|
29
|
+
| `paddingX` | `px` |
|
|
30
|
+
| `paddingY` | `py` |
|
|
31
|
+
|
|
32
|
+
Colors and borders: `bg`, `color` / `textColor`, `borderColor`, `borderRadius` — values must be Gamut tokens, never raw hex.
|
|
9
33
|
|
|
10
34
|
## Overview
|
|
11
35
|
|
|
12
|
-
System props are strongly-typed, theme-connected CSS prop groups from `@codecademy/gamut-styles`. They give styled components a consistent, responsive API. All props are built on top of `@codecademy/variance`.
|
|
36
|
+
System props are strongly-typed, theme-connected CSS prop groups from `@codecademy/gamut-styles`. They give styled components a consistent, responsive API. All props are built on top of `@codecademy/variance`.
|
|
13
37
|
|
|
14
38
|
Each prop group has:
|
|
15
39
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
40
|
+
- `properties`: The CSS properties it controls
|
|
41
|
+
- `scale`: Token scale it's restricted to (theme colors, spacing values, etc.)
|
|
42
|
+
- `transform`: Optional transform applied before output (e.g. `width={0.5}` → `width: 50%`)
|
|
19
43
|
|
|
20
44
|
## Basic usage
|
|
21
45
|
|
|
@@ -40,7 +64,7 @@ const FlexBox = styled.div(
|
|
|
40
64
|
|
|
41
65
|
### `system.layout`
|
|
42
66
|
|
|
43
|
-
Controls dimensions, display, overflow, and container behavior.
|
|
67
|
+
Controls dimensions, display, overflow, and container behavior. This group also carries flex/grid item props used when laying out children: `flexGrow`, `flexShrink`, `flexBasis`, `order`, `gridColumn`, `gridRow`, `gridColumnStart`, `gridRowStart`, `gridColumnEnd`, `gridRowEnd`, `alignSelf`, `justifySelf`, `gridArea`.
|
|
44
68
|
|
|
45
69
|
```tsx
|
|
46
70
|
const Box = styled.div(system.layout);
|
|
@@ -48,7 +72,7 @@ const Box = styled.div(system.layout);
|
|
|
48
72
|
<Box display="flex" width="50%" height="300px" verticalAlign="middle" />;
|
|
49
73
|
```
|
|
50
74
|
|
|
51
|
-
Key props: `display`, `width`, `height`, `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `overflow`, `overflowX`, `overflowY`, `verticalAlign`
|
|
75
|
+
Key props: `containerType`, `display`, `direction`, `dimensions`, `width`, `height`, `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `overflow`, `overflowX`, `overflowY`, `verticalAlign`, plus the item props above (see `config.ts` for the full map).
|
|
52
76
|
|
|
53
77
|
### `system.space`
|
|
54
78
|
|
|
@@ -60,7 +84,7 @@ const Box = styled.div(system.space);
|
|
|
60
84
|
// Single value
|
|
61
85
|
<Box p={8} m={16} />;
|
|
62
86
|
|
|
63
|
-
// Responsive array
|
|
87
|
+
// Responsive (array / object — see Responsive values)
|
|
64
88
|
<Box my={[16, 24, 32]} px={[8, 16]} />;
|
|
65
89
|
```
|
|
66
90
|
|
|
@@ -73,10 +97,10 @@ Foreground, background, and border colors restricted to the theme's color palett
|
|
|
73
97
|
```tsx
|
|
74
98
|
const Box = styled.div(system.color);
|
|
75
99
|
|
|
76
|
-
<Box bg="navy" textColor="gray-100" borderColor="blue" />;
|
|
100
|
+
<Box bg="navy" color="gray-900" textColor="gray-100" borderColor="blue" />;
|
|
77
101
|
```
|
|
78
102
|
|
|
79
|
-
Key props: `
|
|
103
|
+
Key props: `color`, `textColor` (both set CSS `color`), `bg`, `borderColor`, plus directional `borderColor*` variants — see `config.ts` for the full set.
|
|
80
104
|
|
|
81
105
|
### `system.typography`
|
|
82
106
|
|
|
@@ -88,18 +112,19 @@ const Text = styled.p(system.typography);
|
|
|
88
112
|
<Text
|
|
89
113
|
fontSize={16}
|
|
90
114
|
fontFamily="accent"
|
|
115
|
+
fontStyle="italic"
|
|
91
116
|
textTransform="uppercase"
|
|
92
|
-
lineHeight=
|
|
117
|
+
lineHeight="base"
|
|
93
118
|
/>;
|
|
94
119
|
```
|
|
95
120
|
|
|
96
|
-
Key props: `fontFamily`, `fontSize`, `fontWeight`, `lineHeight`, `textAlign`, `textTransform`, `textDecoration`, `letterSpacing`, `whiteSpace`
|
|
121
|
+
Key props: `fontFamily`, `fontSize`, `fontWeight`, `fontStyle`, `lineHeight`, `textAlign`, `textTransform`, `textDecoration`, `letterSpacing`, `whiteSpace` — prefer `lineHeight` scale keys (`base`, `title`, `spacedTitle`) from the theme over raw numbers when possible.
|
|
97
122
|
|
|
98
123
|
### `system.border`
|
|
99
124
|
|
|
100
|
-
Border width, style, radius, and color.
|
|
125
|
+
Border width, style, radius, and color. Many logical shorthands exist (`borderX`, `borderColorY`, `borderRadiusTop`, …); see `config.ts` for the full map.
|
|
101
126
|
|
|
102
|
-
Key props: `border`, `borderTop`, `borderRight`, `borderBottom`, `borderLeft`, `borderRadius`, `borderWidth`, `borderStyle`
|
|
127
|
+
Key props (non-exhaustive): `border`, `borderTop`, `borderRight`, `borderBottom`, `borderLeft`, `borderRadius`, `borderWidth`, `borderStyle`
|
|
103
128
|
|
|
104
129
|
### `system.background`
|
|
105
130
|
|
|
@@ -123,17 +148,17 @@ Key props: `background`, `backgroundImage`, `backgroundSize`, `backgroundPositio
|
|
|
123
148
|
|
|
124
149
|
Flexbox child and container properties.
|
|
125
150
|
|
|
126
|
-
Key props: `flex`, `flexDirection`, `flexWrap`, `flexGrow`, `flexShrink`, `flexBasis`, `alignItems`, `alignSelf`, `justifyContent`, `justifySelf`, `gap`, `rowGap`, `columnGap`
|
|
151
|
+
Key props (non-exhaustive): `flex`, `flexDirection`, `flexWrap`, `flexGrow`, `flexShrink`, `flexBasis`, `alignItems`, `alignContent`, `alignSelf`, `justifyContent`, `justifyItems`, `justifySelf`, `gap`, `rowGap`, `columnGap`
|
|
127
152
|
|
|
128
153
|
### `system.grid`
|
|
129
154
|
|
|
130
155
|
CSS Grid container and child properties.
|
|
131
156
|
|
|
132
|
-
Key props: `gridTemplateColumns`, `gridTemplateRows`, `gridTemplateAreas`, `gridColumn`, `gridRow`, `gridArea`, `gridAutoFlow`
|
|
157
|
+
Key props (non-exhaustive): `gridTemplateColumns`, `gridTemplateRows`, `gridTemplateAreas`, `gridColumn`, `gridRow`, `gridArea`, `gridAutoFlow`, `gridAutoColumns`, `gridAutoRows`, `gap`, `rowGap`, `columnGap`
|
|
133
158
|
|
|
134
159
|
### `system.positioning`
|
|
135
160
|
|
|
136
|
-
Position and offset properties.
|
|
161
|
+
Position and offset properties. Inset shorthands use `transformSize`; physical vs logical edges follow `useLogicalProperties`.
|
|
137
162
|
|
|
138
163
|
```tsx
|
|
139
164
|
const Overlay = styled.div(variance.compose(system.layout, system.positioning));
|
|
@@ -141,7 +166,7 @@ const Overlay = styled.div(variance.compose(system.layout, system.positioning));
|
|
|
141
166
|
<Overlay position="absolute" top={0} left={0} width="100%" height="100%" />;
|
|
142
167
|
```
|
|
143
168
|
|
|
144
|
-
Key props: `position`, `top`, `right`, `bottom`, `left`, `zIndex`
|
|
169
|
+
Key props: `position`, `inset`, `top`, `right`, `bottom`, `left`, `zIndex`, `opacity`
|
|
145
170
|
|
|
146
171
|
### `system.shadow`
|
|
147
172
|
|
|
@@ -149,18 +174,35 @@ Box and text shadow.
|
|
|
149
174
|
|
|
150
175
|
Key props: `boxShadow`, `textShadow`
|
|
151
176
|
|
|
177
|
+
### `system.list`
|
|
178
|
+
|
|
179
|
+
List marker styling (`listStyle`, `listStyleType`, `listStylePosition`, `listStyleImage`). Included on `Box` alongside the other composed groups.
|
|
180
|
+
|
|
152
181
|
## Responsive values
|
|
153
182
|
|
|
154
|
-
All system props accept
|
|
183
|
+
All system props accept responsive values mobile-first (min-width queries). Two shapes are supported:
|
|
184
|
+
|
|
185
|
+
### Object syntax
|
|
186
|
+
|
|
187
|
+
Keys are breakpoints; `_` is the base (no breakpoint). Includes `xs`, `sm`, `md`, `lg`, `xl`, and container keys `c_xs` … `c_xl`.
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
<Box width={{ _: '100%', sm: '50%', md: '33%' }} px={{ _: 8, md: 16 }} />
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Array syntax
|
|
194
|
+
|
|
195
|
+
Slots map in order to: base, `xs`, `sm`, `md`, `lg`, `xl`, then `c_xs` … `c_xl`. Leave a slot empty (or use `undefined`) to skip a breakpoint.
|
|
155
196
|
|
|
156
197
|
```tsx
|
|
157
|
-
|
|
158
|
-
<Box width={['100%', '50%', '33%']} p={[8, 16, 24]} />
|
|
198
|
+
<Box width={['100%', , '50%']} p={[8, 16, , 24]} />
|
|
159
199
|
```
|
|
160
200
|
|
|
201
|
+
Full typings and behavior: [Responsive properties (Storybook)](https://gamut.codecademy.com/storybook/?path=/docs-foundations-system-responsive-properties--page).
|
|
202
|
+
|
|
161
203
|
## Using `css()` for styled definitions
|
|
162
204
|
|
|
163
|
-
For static styles in styled components, use `css()` from `@codecademy/gamut-styles
|
|
205
|
+
For static styles in styled components, use `css()` from `@codecademy/gamut-styles` (same implementation as `system.css` on the `system` namespace).
|
|
164
206
|
|
|
165
207
|
```tsx
|
|
166
208
|
import { css } from '@codecademy/gamut-styles';
|
|
@@ -176,6 +218,8 @@ const Text = styled.div(css({ color: 'primary', p: 4 }));
|
|
|
176
218
|
## Key principles
|
|
177
219
|
|
|
178
220
|
- Compose `system.*` groups via `variance.compose()` — don't apply multiple groups by chaining `styled.div(system.a)(system.b)`.
|
|
179
|
-
-
|
|
180
|
-
- Use `
|
|
181
|
-
-
|
|
221
|
+
- Prefer semantic color names on `system.color` (e.g. `bg="background"`, `textColor="text"`) so values track ColorMode; use raw palette keys only when the design should stay fixed across modes.
|
|
222
|
+
- Use `bg` with semantic tokens for most mode-aware surfaces; use `<Background>` from `@codecademy/gamut-styles` when you need its contrast- and mode-aware behavior, not for every tinted panel.
|
|
223
|
+
- Use `system.space` values on the spacing scale rather than arbitrary pixel strings to keep rhythm consistent.
|
|
224
|
+
- For background images/patterns use `system.background`; for solid fills use `system.color` / semantic `bg` (or `Background` when that component’s behavior is required).
|
|
225
|
+
- For reusable variants or boolean states on styled primitives, use `variant` / `states` from `@codecademy/gamut-styles` and expose props with `StyleProps<typeof …>` from `@codecademy/variance` — see [Best practices](../../../../styleguide/src/lib/Meta/Best%20practices.mdx).
|