@codecademy/gamut 68.6.1-alpha.c8d945.0 → 68.6.1-alpha.d46fc5.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/.claude-plugin/marketplace.json +16 -0
- package/agent-tools/.claude-plugin/plugin.json +7 -0
- package/agent-tools/.cursor-plugin/plugin.json +7 -0
- package/agent-tools/DESIGN.Codecademy.md +643 -0
- package/agent-tools/DESIGN.LXStudio.md +444 -0
- package/agent-tools/DESIGN.Percipio.md +435 -0
- package/agent-tools/DESIGN.md +1 -0
- package/agent-tools/agents/.gitkeep +0 -0
- package/agent-tools/commands/gamut-review.md +246 -0
- package/agent-tools/guidelines/components/buttons.md +91 -0
- package/agent-tools/guidelines/components/overview.md +52 -0
- package/agent-tools/guidelines/foundations/color.md +172 -0
- package/agent-tools/guidelines/foundations/modes.md +47 -0
- package/agent-tools/guidelines/foundations/spacing.md +107 -0
- package/agent-tools/guidelines/foundations/typography.md +84 -0
- package/agent-tools/guidelines/overview.md +46 -0
- package/agent-tools/guidelines/setup.md +81 -0
- package/agent-tools/rules/accessibility.mdc +78 -0
- package/agent-tools/skills/gamut-accessibility/SKILL.md +214 -0
- package/agent-tools/skills/gamut-color-mode/SKILL.md +140 -0
- package/agent-tools/skills/gamut-forms/SKILL.md +84 -0
- package/agent-tools/skills/gamut-style-utilities/SKILL.md +107 -0
- package/agent-tools/skills/gamut-system-props/SKILL.md +203 -0
- package/agent-tools/skills/gamut-testing/SKILL.md +221 -0
- package/agent-tools/skills/gamut-theming/SKILL.md +48 -0
- package/agent-tools/skills/gamut-typography/SKILL.md +75 -0
- package/bin/commands/plugin/install.mjs +213 -0
- package/bin/commands/plugin/list.mjs +73 -0
- package/bin/commands/plugin/remove.mjs +108 -0
- package/bin/commands/plugin/update.mjs +59 -0
- package/bin/gamut.mjs +96 -0
- package/bin/lib/claude.mjs +52 -0
- package/bin/lib/cursor.mjs +40 -0
- package/bin/lib/design.mjs +71 -0
- package/bin/lib/io.mjs +14 -0
- package/bin/lib/resolve-plugin-dir.mjs +38 -0
- package/bin/lib/run-command.mjs +22 -0
- package/dist/{PatternBackdrop/PatternBackdrop.d.ts → InternalFloatingCard/InternalFloatingCard.d.ts} +24 -8
- package/dist/InternalFloatingCard/InternalFloatingCard.js +98 -0
- package/dist/Modals/elements.d.ts +1 -186
- package/dist/Modals/elements.js +3 -3
- package/dist/Toast/Toast.js +4 -4
- package/package.json +11 -8
- package/dist/PatternBackdrop/PatternBackdrop.js +0 -43
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gamut-testing
|
|
3
|
+
description: Use this skill when writing or fixing unit tests for React components that use Gamut — prefer setupRtl from @codecademy/gamut-tests, harness patterns for useLogicalProperties and ColorMode, RTL/dir testing, emotion matchers, or removing jest.mock of @codecademy/gamut / gamut-styles.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Gamut Testing
|
|
7
|
+
|
|
8
|
+
Source: `@codecademy/gamut-tests` — [`index.tsx`](https://github.com/Codecademy/gamut/blob/main/packages/gamut-tests/src/index.tsx)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What `MockGamutProvider` does (under `setupRtl`)
|
|
15
|
+
|
|
16
|
+
`MockGamutProvider` forwards to `GamutProvider` with:
|
|
17
|
+
|
|
18
|
+
- `useCache={false}` — stable Emotion output across tests
|
|
19
|
+
- `useGlobals={false}` — no global Reboot/Typography bleed between files
|
|
20
|
+
- `theme={theme}` — full token theme for styled components
|
|
21
|
+
- Optional **`useLogicalProperties`** — forwarded for logical vs physical CSS in variance
|
|
22
|
+
|
|
23
|
+
You normally **do not** import `MockGamutProvider` for plain component tests; `setupRtl` already wraps the **component under test** once. Import it **inside a harness** when the SUT needs a non-default provider flag or extra wrappers (see below).
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Decision guide
|
|
28
|
+
|
|
29
|
+
| Scenario | Prefer |
|
|
30
|
+
| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
31
|
+
| Default unit test for a Gamut (or app) component | **`setupRtl(Component, defaultProps)`** once per file / describe |
|
|
32
|
+
| Vary **`useLogicalProperties`** across cases | **Harness** that accepts `useLogicalProperties` and wraps **`MockGamutProvider`**, then **`setupRtl(Harness, defaults)`**; pass overrides per `it` / `describe.each` |
|
|
33
|
+
| Need **`ColorMode`** (or other context) around the SUT | **Harness** with `<ColorMode>` inside the tree, then **`setupRtl(Harness)`** — no need for raw `render` unless you are testing the provider itself |
|
|
34
|
+
| **`dir` / RTL** behavior (e.g. mirrored layout, `useElementDir`) | Keep using **`setupRtl`** for the component; set **`document.documentElement.setAttribute('dir', 'rtl' \| 'ltr')`** (and scroll/viewport stubs if needed) in **`beforeEach` / `afterEach`**; reset `dir` after tests so suites do not leak |
|
|
35
|
+
| Storybook-only mock, chromatic-style wrapper, or non-RTL harness | **`MockGamutProvider`** (± **`ColorMode`**) in the exported wrapper component |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## `setupRtl` — primary pattern
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { setupRtl } from '@codecademy/gamut-tests';
|
|
43
|
+
|
|
44
|
+
import { MyComponent } from '../MyComponent';
|
|
45
|
+
|
|
46
|
+
const renderView = setupRtl(MyComponent, {
|
|
47
|
+
label: 'Default label',
|
|
48
|
+
onClick: jest.fn(),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('renders the label', () => {
|
|
52
|
+
const { view } = renderView();
|
|
53
|
+
expect(view.getByText('Default label')).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('accepts prop overrides', () => {
|
|
57
|
+
const { view } = renderView({ label: 'Override' });
|
|
58
|
+
expect(view.getByText('Override')).toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`renderView` returns `{ view, props, update }`:
|
|
63
|
+
|
|
64
|
+
- **`view`** — RTL `RenderResult` (`getByRole`, `getByLabelText`, `getByText`, …)
|
|
65
|
+
- **`props`** — resolved props (handy for `jest.fn()` assertions)
|
|
66
|
+
- **`update`** — re-render with new props without remounting
|
|
67
|
+
|
|
68
|
+
### Query and interaction habits (RTL)
|
|
69
|
+
|
|
70
|
+
- Prefer **`getByRole`**, **`getByLabelText`**, and accessible names over CSS selectors or snapshotting class strings unless you are explicitly testing styling.
|
|
71
|
+
- Prefer **`@testing-library/user-event`** over `fireEvent` when simulating real input (import `userEvent` from **`@testing-library/user-event`** in current major versions).
|
|
72
|
+
|
|
73
|
+
### Accessing mock functions via `props`
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import userEvent from '@testing-library/user-event';
|
|
77
|
+
|
|
78
|
+
it('calls onClick when clicked', async () => {
|
|
79
|
+
const { view, props } = renderView();
|
|
80
|
+
await userEvent.click(view.getByRole('button'));
|
|
81
|
+
expect(props.onClick).toHaveBeenCalled();
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Harness + `setupRtl` when the wrapper is not default
|
|
88
|
+
|
|
89
|
+
`setupRtl` always wraps with **`MockGamutProvider`** with default props. To vary **`useLogicalProperties`**, add **`ColorMode`**, or compose other providers, define a **small harness** and pass **`setupRtl`** that harness — still one `renderView` factory, still `props` / `update` ergonomics.
|
|
90
|
+
|
|
91
|
+
### Varying `useLogicalProperties` (logical vs physical CSS)
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { MockGamutProvider, setupRtl } from '@codecademy/gamut-tests';
|
|
95
|
+
|
|
96
|
+
import { MyComponent } from '../MyComponent';
|
|
97
|
+
|
|
98
|
+
type HarnessProps = React.ComponentProps<typeof MyComponent> & {
|
|
99
|
+
useLogicalProperties?: boolean;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const MyHarness = ({ useLogicalProperties, ...rest }: HarnessProps) => (
|
|
103
|
+
<MockGamutProvider useLogicalProperties={useLogicalProperties}>
|
|
104
|
+
<MyComponent {...rest} />
|
|
105
|
+
</MockGamutProvider>
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const renderView = setupRtl(MyHarness, { width: '200px' });
|
|
109
|
+
|
|
110
|
+
describe.each([
|
|
111
|
+
{ useLogicalProperties: true as const, widthProp: 'inlineSize' as const },
|
|
112
|
+
{ useLogicalProperties: false as const, widthProp: 'width' as const },
|
|
113
|
+
])(
|
|
114
|
+
'useLogicalProperties=$useLogicalProperties',
|
|
115
|
+
({ useLogicalProperties, widthProp }) => {
|
|
116
|
+
it(`uses ${widthProp}`, () => {
|
|
117
|
+
const { view } = renderView({ useLogicalProperties });
|
|
118
|
+
expect(view.getByTestId('my-component-root')).toHaveStyle({
|
|
119
|
+
[widthProp]: '200px',
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The outer `setupRtl` wrapper adds a default **`MockGamutProvider`**; the harness’s inner **`MockGamutProvider`** sets **`useLogicalProperties`** for the subtree under test (nested `GamutProvider` / theme is the nearest one Emotion and variance see).
|
|
127
|
+
|
|
128
|
+
### `ColorMode` without abandoning `setupRtl`
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import { ColorMode } from '@codecademy/gamut-styles';
|
|
132
|
+
import { setupRtl } from '@codecademy/gamut-tests';
|
|
133
|
+
|
|
134
|
+
const DarkHarness = (props: React.ComponentProps<typeof MyComponent>) => (
|
|
135
|
+
<ColorMode mode="dark">
|
|
136
|
+
<MyComponent {...props} />
|
|
137
|
+
</ColorMode>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const renderDark = setupRtl(DarkHarness, { title: 'Hi' });
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Use **`MockGamutProvider`** only inside the harness if you also need a non-default Gamut flag **and** `ColorMode` in the same tree; otherwise **`setupRtl(DarkHarness)`** is enough.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Raw `render` + `MockGamutProvider` — rare
|
|
148
|
+
|
|
149
|
+
Reserve **`render` from `@testing-library/react`** + manual **`MockGamutProvider`** for cases where a harness would be more obscure than a single inline tree (e.g. highly dynamic one-off trees). If the same wrapper appears more than once, switch to a **harness + `setupRtl`**.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## RTL / `dir` and document-level behavior
|
|
154
|
+
|
|
155
|
+
Some components (e.g. overlays that call **`useElementDir`**) resolve direction from **`document.documentElement`** when there is no real target node. For those tests:
|
|
156
|
+
|
|
157
|
+
- Set **`document.documentElement.setAttribute('dir', 'rtl')`** (or `'ltr'`) around the scenario, **`unmount`** between LTR and RTL assertions when re-rendering, and restore **`dir`** in **`afterEach`** so other tests start clean.
|
|
158
|
+
- Combine with the harness pattern above when **`useLogicalProperties`** affects which longhand wins (`left` vs `insetInlineStart`, etc.).
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Emotion style assertions
|
|
163
|
+
|
|
164
|
+
Install **`@emotion/jest`** matchers if you absolutely need to enable CSS-in-JS assertions:
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { matchers } from '@emotion/jest';
|
|
168
|
+
|
|
169
|
+
expect.extend(matchers);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Then assert on styles:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
expect(element).toHaveStyle({ borderRadius: '2px' });
|
|
176
|
+
expect(element).toHaveStyleRule('padding', '1rem');
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Use **`theme`** from **`@codecademy/gamut-styles`** instead of hardcoding token strings:
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { theme } from '@codecademy/gamut-styles';
|
|
183
|
+
|
|
184
|
+
expect(element).toHaveStyle({ columnGap: theme.spacing[40] });
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Visual test wrappers and Storybook
|
|
190
|
+
|
|
191
|
+
Exported mocks and stories may wrap with **`MockGamutProvider`** and **`ColorMode`** explicitly (no `setupRtl` in Storybook):
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { MockGamutProvider } from '@codecademy/gamut-tests';
|
|
195
|
+
import { ColorMode } from '@codecademy/gamut-styles';
|
|
196
|
+
|
|
197
|
+
export const MyComponentMock: React.FC<ComponentProps<typeof MyComponent>> = (
|
|
198
|
+
props
|
|
199
|
+
) => (
|
|
200
|
+
<MockGamutProvider>
|
|
201
|
+
<ColorMode mode="light">
|
|
202
|
+
<MyComponent {...props} />
|
|
203
|
+
</ColorMode>
|
|
204
|
+
</MockGamutProvider>
|
|
205
|
+
);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Common anti-patterns
|
|
211
|
+
|
|
212
|
+
| Anti-pattern | Fix |
|
|
213
|
+
| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
214
|
+
| `jest.mock('@codecademy/gamut', () => ({ ... }))` | Remove; use **`setupRtl`** (or harness + **`setupRtl`**) |
|
|
215
|
+
| `jest.mock('@codecademy/gamut-styles', ...)` | Remove; **`MockGamutProvider`** / **`setupRtl`** supplies theme |
|
|
216
|
+
| **`GamutProvider`** in test files | Use **`MockGamutProvider`** only when building a harness or story; default tests go through **`setupRtl`** |
|
|
217
|
+
| **`import { setupRtl } from 'component-test-setup'`** in Gamut / apps | Import **`setupRtl` from `@codecademy/gamut-tests`** so **`MockGamutProvider`** is applied |
|
|
218
|
+
| Repeated **`render(<MockGamutProvider>…`** | **Harness + `setupRtl`**, or a shared **`renderView`** factory |
|
|
219
|
+
| One **`setupRtl`** call per **`it`** | Define **`renderView`** once outside **`describe`**, call it inside each **`it`** |
|
|
220
|
+
| Asserting raw CSS strings for tokens | Use **`theme`** from **`@codecademy/gamut-styles`** |
|
|
221
|
+
| Leaking **`dir="rtl"`** between tests | Reset **`document.documentElement`** in **`afterEach`** |
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gamut-theming
|
|
3
|
+
description: Use this skill when choosing or extending Gamut themes (Core, Admin, Platform, LX Studio, Percipio), wiring GamutProvider and Emotion theme TypeScript augmentation, or following CreatingThemes — not for day-to-day css(), variant(), or states() patterns (see gamut-style-utilities).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Gamut Theming
|
|
7
|
+
|
|
8
|
+
Source: `@codecademy/gamut-styles`
|
|
9
|
+
|
|
10
|
+
**See also:** [`gamut-style-utilities`](../gamut-style-utilities/SKILL.md) (`css`, `variant`, `states`, `StyleProps`, `useTheme` escape hatch). [`gamut-color-mode`](../gamut-color-mode/SKILL.md) (semantic color, `<ColorMode>`, `<Background>`). [`gamut-system-props`](../gamut-system-props/SKILL.md) (`system.*`, responsive `Box` props).
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Gamut uses Emotion's theme system. **Themes** are org-specific token bundles (colors, typography, spacing, etc.). The active theme is set at the app root with **`<GamutProvider theme={...}>`**; child styled components read tokens through Emotion context.
|
|
15
|
+
|
|
16
|
+
For **authoring component styles** (`css`, `variant`, `states`, system props, ColorMode), use the skills linked above and the styleguide [Best practices](../../../../styleguide/src/lib/Meta/Best%20practices.mdx).
|
|
17
|
+
|
|
18
|
+
## Available themes
|
|
19
|
+
|
|
20
|
+
| Theme | Used for |
|
|
21
|
+
| --------- | ---------------------------------------------------------- |
|
|
22
|
+
| Core | Codecademy default |
|
|
23
|
+
| Admin | Codecademy admin tools |
|
|
24
|
+
| Platform | Codecademy learning environment / shared platform surfaces |
|
|
25
|
+
| LX Studio | Learning Experience Studio |
|
|
26
|
+
| Percipio | Skillsoft Percipio platform |
|
|
27
|
+
|
|
28
|
+
Product-level import names and `theme.d.ts` patterns live in [setup.md](../../guidelines/setup.md).
|
|
29
|
+
|
|
30
|
+
## Theme vs color mode vs style API
|
|
31
|
+
|
|
32
|
+
| Concern | Where to read |
|
|
33
|
+
| ------------------------------------------------------- | -------------------------------------------------- |
|
|
34
|
+
| Which `theme` object to pass to `GamutProvider` | This skill + [setup.md](../../guidelines/setup.md) |
|
|
35
|
+
| Light / dark semantic colors, `ColorMode`, `Background` | **`gamut-color-mode`** |
|
|
36
|
+
| `css` / `variant` / `states`, `useTheme` for non-CSS JS | **`gamut-style-utilities`** |
|
|
37
|
+
| Composed `system.*` props on styled primitives / `Box` | **`gamut-system-props`** |
|
|
38
|
+
|
|
39
|
+
## Creating a new theme
|
|
40
|
+
|
|
41
|
+
See `CreatingThemes.mdx` in the styleguide (`packages/styleguide/src/lib/Foundations/Theme/CreatingThemes.mdx`). Themes are defined in `@codecademy/gamut-styles` and must extend the base theme shape with all required token keys.
|
|
42
|
+
|
|
43
|
+
## Key principles
|
|
44
|
+
|
|
45
|
+
- Pick the **correct theme export** for the product (`coreTheme`, `adminTheme`, `platformTheme`, `lxStudioTheme`, `percipioTheme`, etc.) so tokens and fonts match design intent.
|
|
46
|
+
- Align **`theme.d.ts`** / `Theme extends …` with the same theme interface you pass to `GamutProvider` (see [setup.md](../../guidelines/setup.md)).
|
|
47
|
+
- Components stay portable across themes when they use **token and semantic aliases** rather than one-off hex; authoring rules live in **`gamut-style-utilities`** and **`gamut-color-mode`**.
|
|
48
|
+
- **`GamutProvider`** wires theme, color mode, and logical-properties settings at the root; individual components should not hard-code which org theme is active.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gamut-typography
|
|
3
|
+
description: Use this skill when creating or reviewing UI text in Gamut apps — headlines, body, captions, labels, code snippets, or text-heavy layouts. Covers theme-specific stacks (Core Apercu/Suisse vs Percipio/LX Skillsoft), fontSize / lineHeight tokens, semantic fontWeight title (700 vs 500), line length, and alignment for Codecademy-branded surfaces.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Gamut Typography
|
|
7
|
+
|
|
8
|
+
**Implementation source of truth:** [`packages/gamut-styles/src/variables/typography.ts`](https://github.com/Codecademy/gamut/blob/main/packages/gamut-styles/src/variables/typography.ts) and themes under [`packages/gamut-styles/src/themes`](https://github.com/Codecademy/gamut/tree/main/packages/gamut-styles/src/themes). Agent guideline: [foundations/typography.md](../../guidelines/foundations/typography.md).
|
|
9
|
+
|
|
10
|
+
## Scope by theme
|
|
11
|
+
|
|
12
|
+
| Themes | Fonts | `fontWeight.title` |
|
|
13
|
+
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
|
|
14
|
+
| **Core**, **Admin**, **Platform** | `base` → Apercu stack; `accent` → Suisse + Apercu stack | **700** |
|
|
15
|
+
| **Percipio**, **LX Studio** | `base` → Skillsoft Text; `accent` → Skillsoft Sans; Percipio `monospace` → Roboto Mono; LX `monospace` matches Core stack per theme file | **500** |
|
|
16
|
+
|
|
17
|
+
Use **`fontWeight="title"`** for headlines / emphasis roles — never hardcode **`700`** on Percipio/LX unless SPECIFICALLY noted in Figma designs.
|
|
18
|
+
|
|
19
|
+
## Font size scale (`fontSize`)
|
|
20
|
+
|
|
21
|
+
Theme keys: `64`, `44`, `34`, `26`, `22`, `20`, `18`, `16`, `14`.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { css } from '@codecademy/gamut-styles';
|
|
25
|
+
import styled from '@emotion/styled';
|
|
26
|
+
import { system } from '@codecademy/gamut-styles';
|
|
27
|
+
|
|
28
|
+
const Paragraph = styled.p(system.typography);
|
|
29
|
+
<Paragraph fontSize={16} lineHeight="base" />;
|
|
30
|
+
|
|
31
|
+
const Styled = styled.div(css({ fontSize: 14, fontFamily: 'base' }));
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Line height (`lineHeight`)
|
|
35
|
+
|
|
36
|
+
Tokens: **`base`** (1.5), **`spacedTitle`** (1.3), **`title`** (1.2). Prefer tokens over raw decimals. Only specify `lineHeight` when specified by design.
|
|
37
|
+
|
|
38
|
+
## Line length
|
|
39
|
+
|
|
40
|
+
| Context | Target |
|
|
41
|
+
| ------------------ | ------------------------ |
|
|
42
|
+
| Single-column body | ~66 characters (max ~85) |
|
|
43
|
+
| Multi-column | ≤50 characters per line |
|
|
44
|
+
| Minimum | ~45 characters |
|
|
45
|
+
|
|
46
|
+
## Accessing typography tokens
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { system } from '@codecademy/gamut-styles';
|
|
50
|
+
import { variance } from '@codecademy/variance';
|
|
51
|
+
|
|
52
|
+
const Heading = styled.h2(variance.compose(system.typography, system.space));
|
|
53
|
+
|
|
54
|
+
<Heading
|
|
55
|
+
fontSize={26}
|
|
56
|
+
fontFamily="base"
|
|
57
|
+
fontWeight="title"
|
|
58
|
+
lineHeight="title"
|
|
59
|
+
mb={8}
|
|
60
|
+
/>;
|
|
61
|
+
|
|
62
|
+
import { css } from '@codecademy/gamut-styles';
|
|
63
|
+
|
|
64
|
+
const Caption = styled.span(
|
|
65
|
+
css({ fontFamily: 'accent', fontSize: 14, color: 'text-secondary' })
|
|
66
|
+
);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Prefer `<Text>` from `@codecademy/gamut` with `variant` / `as` — see Storybook [Typography / Text](https://gamut.codecademy.com/?path=/docs-typography-text--docs).
|
|
70
|
+
|
|
71
|
+
## Semantic vs visual headings
|
|
72
|
+
|
|
73
|
+
- `<Text as="h1">` … `<Text as="h6">` gets **default heading styles**: each tag maps to the same scale as `variant="title-xxl"` … `variant="title-xs"` (`h1` largest through `h6` smallest). Plain `<Text>` defaults to `as="span"` (inherits font size).
|
|
74
|
+
- Use **`variant`** plus **`fontSize` / `fontWeight` / `lineHeight`** (and other system props) to override element defaults when the outline needs one heading level but the UI needs another visual weight — e.g. `<Text as="h2" variant="title-sm">`.
|
|
75
|
+
- Still pick **`h1`–`h6`** for document structure and assistive tech; overrides are for intentional divergence between semantics and appearance.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { cp, mkdir, readdir, rm, symlink } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { claudePluginSpec, marketplaceName } from '../../lib/claude.mjs';
|
|
5
|
+
import { cursorDestPath } from '../../lib/cursor.mjs';
|
|
6
|
+
import {
|
|
7
|
+
installDesignMd,
|
|
8
|
+
listCanonicalThemes,
|
|
9
|
+
resolveTheme,
|
|
10
|
+
} from '../../lib/design.mjs';
|
|
11
|
+
import { log, warn } from '../../lib/io.mjs';
|
|
12
|
+
import { getFlag, resolvePluginDir } from '../../lib/resolve-plugin-dir.mjs';
|
|
13
|
+
import { runCommand } from '../../lib/run-command.mjs';
|
|
14
|
+
|
|
15
|
+
export const TARGETS = ['cursor', 'claude'];
|
|
16
|
+
export const SCOPES = ['all', 'skills', 'rules', 'commands', 'agents'];
|
|
17
|
+
|
|
18
|
+
export function help() {
|
|
19
|
+
log(`
|
|
20
|
+
Usage:
|
|
21
|
+
gamut plugin install [target] [options]
|
|
22
|
+
|
|
23
|
+
Install the Gamut plugin into an AI tool.
|
|
24
|
+
|
|
25
|
+
Arguments:
|
|
26
|
+
target Tool to install into (default: cursor)
|
|
27
|
+
cursor | claude
|
|
28
|
+
|
|
29
|
+
Options:
|
|
30
|
+
--scope <scope> Content to install (default: all)
|
|
31
|
+
all | skills | rules | commands | agents
|
|
32
|
+
--theme <theme> Copy DESIGN.*.md to ./DESIGN.md in the current directory
|
|
33
|
+
core | admin | platform | percipio | lxstudio
|
|
34
|
+
(admin/platform use Codecademy DESIGN; aliases: codecademy, cc, lx-studio)
|
|
35
|
+
--force Overwrite existing DESIGN.md when using --theme
|
|
36
|
+
--plugin-dir <path> Override the bundled agent-tools directory
|
|
37
|
+
-h, --help Show this help message
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
gamut plugin install
|
|
41
|
+
gamut plugin install claude
|
|
42
|
+
gamut plugin install cursor --theme core
|
|
43
|
+
gamut plugin install cursor --theme percipio --force
|
|
44
|
+
gamut plugin install cursor --scope skills
|
|
45
|
+
gamut plugin install cursor --plugin-dir ./my-agent-tools
|
|
46
|
+
`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
/** Directories in the plugin source that should not be installed to Cursor. */
|
|
52
|
+
const CURSOR_IGNORE = new Set([
|
|
53
|
+
'.claude-plugin', // Claude Code manifest — not a Cursor concept
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
/** @param {string} sourceRoot @param {string} scope */
|
|
57
|
+
async function installCursor(sourceRoot, scope) {
|
|
58
|
+
const dest = await cursorDestPath(sourceRoot);
|
|
59
|
+
|
|
60
|
+
if ((process.env.CURSOR_INSTALL_METHOD ?? 'copy') !== 'copy') {
|
|
61
|
+
// Symlink the whole plugin dir (dev convenience)
|
|
62
|
+
await rm(dest, { recursive: true, force: true });
|
|
63
|
+
await symlink(resolve(sourceRoot), dest, 'dir');
|
|
64
|
+
log(`Cursor: symlinked to ${dest}`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Selective copy: always include the cursor manifest, then scoped content dirs
|
|
69
|
+
await rm(dest, { recursive: true, force: true });
|
|
70
|
+
await mkdir(dest, { recursive: true });
|
|
71
|
+
|
|
72
|
+
await cp(`${sourceRoot}/.cursor-plugin`, `${dest}/.cursor-plugin`, {
|
|
73
|
+
recursive: true,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
let dirs;
|
|
77
|
+
if (scope === 'all') {
|
|
78
|
+
const entries = await readdir(sourceRoot, { withFileTypes: true });
|
|
79
|
+
dirs = entries
|
|
80
|
+
.filter(
|
|
81
|
+
(e) =>
|
|
82
|
+
e.isDirectory() &&
|
|
83
|
+
!e.name.startsWith('.') &&
|
|
84
|
+
!CURSOR_IGNORE.has(e.name)
|
|
85
|
+
)
|
|
86
|
+
.map((e) => e.name);
|
|
87
|
+
} else {
|
|
88
|
+
dirs = [scope];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
await Promise.all(
|
|
92
|
+
dirs.map((dir) =>
|
|
93
|
+
cp(`${sourceRoot}/${dir}`, `${dest}/${dir}`, { recursive: true }).catch(
|
|
94
|
+
() => {
|
|
95
|
+
// directory may be empty/missing — not an error
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const scopeLabel = scope === 'all' ? 'all content' : scope;
|
|
102
|
+
log(`Cursor: installed (${scopeLabel}) → ${dest}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Claude Code only loads from recognized plugin directories: skills/, commands/, agents/.
|
|
106
|
+
// rules/ is Cursor-specific (.mdc format). guidelines/ is installed to Cursor and is
|
|
107
|
+
// also source for the Figma Make kit; Claude marketplace registers the full sourceRoot.
|
|
108
|
+
|
|
109
|
+
/** @param {string} sourceRoot */
|
|
110
|
+
async function installClaude(sourceRoot) {
|
|
111
|
+
const spec = await claudePluginSpec(sourceRoot);
|
|
112
|
+
const mpName = marketplaceName(spec);
|
|
113
|
+
const root = resolve(sourceRoot);
|
|
114
|
+
|
|
115
|
+
let code = await runCommand('claude', [
|
|
116
|
+
'plugin',
|
|
117
|
+
'marketplace',
|
|
118
|
+
'add',
|
|
119
|
+
root,
|
|
120
|
+
'--scope',
|
|
121
|
+
'user',
|
|
122
|
+
]);
|
|
123
|
+
if (code !== 0) {
|
|
124
|
+
warn(
|
|
125
|
+
`warning: "claude plugin marketplace add" exited ${code} — ` +
|
|
126
|
+
`if it's already registered this is safe to ignore.`
|
|
127
|
+
);
|
|
128
|
+
code = await runCommand('claude', [
|
|
129
|
+
'plugin',
|
|
130
|
+
'marketplace',
|
|
131
|
+
'update',
|
|
132
|
+
mpName,
|
|
133
|
+
]);
|
|
134
|
+
if (code !== 0) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
`claude plugin marketplace add/update failed (exit ${code}).\n` +
|
|
137
|
+
`Try manually: claude plugin marketplace add ${root}`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
code = await runCommand('claude', [
|
|
143
|
+
'plugin',
|
|
144
|
+
'install',
|
|
145
|
+
spec,
|
|
146
|
+
'--scope',
|
|
147
|
+
'user',
|
|
148
|
+
]);
|
|
149
|
+
if (code !== 0) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
`claude plugin install failed (exit ${code}).\n` +
|
|
152
|
+
`Try manually: claude plugin install ${spec} --scope user`
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
log(`Claude Code: installed ${spec} (user scope)`);
|
|
157
|
+
log(
|
|
158
|
+
` Tip: run /reload-plugins in Claude Code if skills don't appear immediately.`
|
|
159
|
+
);
|
|
160
|
+
log(` One-off without install: claude --plugin-dir ${root}`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* gamut plugin install [cursor|claude] [--scope all|skills|rules|commands|agents]
|
|
167
|
+
* [--plugin-dir <path>]
|
|
168
|
+
*
|
|
169
|
+
* @param {string[]} args
|
|
170
|
+
*/
|
|
171
|
+
export default async function install(args) {
|
|
172
|
+
const target = args.find((a) => !a.startsWith('-')) ?? 'cursor';
|
|
173
|
+
const scope = getFlag(args, '--scope', 'all') ?? 'all';
|
|
174
|
+
|
|
175
|
+
if (!TARGETS.includes(target)) {
|
|
176
|
+
throw new Error(
|
|
177
|
+
`Unknown target: "${target}". Choose from: ${TARGETS.join(', ')}`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
if (!SCOPES.includes(scope)) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
`Unknown scope: "${scope}". Choose from: ${SCOPES.join(', ')}`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const pluginDir = await resolvePluginDir(args);
|
|
187
|
+
const theme = getFlag(args, '--theme');
|
|
188
|
+
const force = args.includes('--force');
|
|
189
|
+
|
|
190
|
+
if (theme) {
|
|
191
|
+
resolveTheme(theme);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (target === 'cursor') {
|
|
195
|
+
await installCursor(pluginDir, scope);
|
|
196
|
+
} else if (target === 'claude') {
|
|
197
|
+
await installClaude(pluginDir);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (theme) {
|
|
201
|
+
const { dest, label } = await installDesignMd(
|
|
202
|
+
pluginDir,
|
|
203
|
+
process.cwd(),
|
|
204
|
+
theme,
|
|
205
|
+
{
|
|
206
|
+
force,
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
log(`DESIGN.md: installed (${label}) → ${dest}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export { listCanonicalThemes };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { stat } from 'node:fs/promises';
|
|
2
|
+
|
|
3
|
+
import { cursorDestPath } from '../../lib/cursor.mjs';
|
|
4
|
+
import { log } from '../../lib/io.mjs';
|
|
5
|
+
import { resolvePluginDir } from '../../lib/resolve-plugin-dir.mjs';
|
|
6
|
+
|
|
7
|
+
export function help() {
|
|
8
|
+
log(`
|
|
9
|
+
Usage:
|
|
10
|
+
gamut plugin list [options]
|
|
11
|
+
|
|
12
|
+
Show installation status for all supported targets.
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--plugin-dir <path> Override the bundled agent-tools directory
|
|
16
|
+
-h, --help Show this help message
|
|
17
|
+
|
|
18
|
+
Examples:
|
|
19
|
+
gamut plugin list
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
/** @param {string} sourceRoot */
|
|
26
|
+
async function cursorStatus(sourceRoot) {
|
|
27
|
+
const dest = await cursorDestPath(sourceRoot);
|
|
28
|
+
const installed = !!(await stat(dest).catch(() => null));
|
|
29
|
+
return {
|
|
30
|
+
target: 'cursor',
|
|
31
|
+
status: installed ? '✓ installed' : '✗ not installed',
|
|
32
|
+
notes: installed ? dest : 'run: gamut plugin install cursor',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function claudeStatus() {
|
|
37
|
+
// Claude Code doesn't expose a stable filesystem path we can check.
|
|
38
|
+
return {
|
|
39
|
+
target: 'claude',
|
|
40
|
+
status: '? unknown',
|
|
41
|
+
notes: 'run: claude plugin list',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* gamut plugin list
|
|
49
|
+
*
|
|
50
|
+
* Shows installation status for each supported target.
|
|
51
|
+
*
|
|
52
|
+
* @param {string[]} args
|
|
53
|
+
*/
|
|
54
|
+
export default async function list(args) {
|
|
55
|
+
const pluginDir = await resolvePluginDir(args);
|
|
56
|
+
|
|
57
|
+
const rows = await Promise.all([cursorStatus(pluginDir), claudeStatus()]);
|
|
58
|
+
|
|
59
|
+
const col0 = Math.max(...rows.map((r) => r.target.length));
|
|
60
|
+
const col1 = Math.max(...rows.map((r) => r.status.length));
|
|
61
|
+
|
|
62
|
+
const header = `${'Target'.padEnd(col0)} ${'Status'.padEnd(
|
|
63
|
+
col1
|
|
64
|
+
)} Path / Notes`;
|
|
65
|
+
const rule = '─'.repeat(header.length);
|
|
66
|
+
|
|
67
|
+
log(`\n${header}`);
|
|
68
|
+
log(rule);
|
|
69
|
+
for (const row of rows) {
|
|
70
|
+
log(`${row.target.padEnd(col0)} ${row.status.padEnd(col1)} ${row.notes}`);
|
|
71
|
+
}
|
|
72
|
+
log('');
|
|
73
|
+
}
|