@itkeazco/graphite 0.0.0-stage → 1.2.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/CHANGELOG.md +61 -0
- package/README.md +271 -2
- package/bin/graphite.js +94 -0
- package/dist/fonts.css +2 -0
- package/dist/icon-sets/phosphor-bold.json +1 -0
- package/dist/icon-sets/phosphor-light.json +1 -0
- package/dist/icon-sets/phosphor-regular.json +1 -0
- package/dist/icon-sets/tabler.json +1 -0
- package/dist/index.css +5 -0
- package/dist/index.d.ts +657 -0
- package/dist/index.js +2224 -0
- package/dist/layers.css +853 -0
- package/dist/neutrals.css +565 -0
- package/dist/styles.css +636 -0
- package/dist/tokens.css +824 -0
- package/dist/tokens.d.ts +35 -0
- package/dist/tokens.js +2 -0
- package/dist/tokens.json +884 -0
- package/dist/typography.css +26 -0
- package/package.json +90 -4
- package/rules/graphite.mdc +99 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* Graphite — optional text-style classes. Sizes come from type tokens in tokens.css. */
|
|
2
|
+
.gt-text-display-2xl { font-family: var(--font-display); font-size: var(--type-display-2xl-size); line-height: var(--type-display-2xl-leading); font-weight: var(--type-display-2xl-weight); letter-spacing: var(--type-display-2xl-tracking); }
|
|
3
|
+
.gt-text-display-xl { font-family: var(--font-display); font-size: var(--type-display-xl-size); line-height: var(--type-display-xl-leading); font-weight: var(--type-display-xl-weight); letter-spacing: var(--type-display-xl-tracking); }
|
|
4
|
+
.gt-text-display-lg { font-family: var(--font-display); font-size: var(--type-display-lg-size); line-height: var(--type-display-lg-leading); font-weight: var(--type-display-lg-weight); letter-spacing: var(--type-display-lg-tracking); }
|
|
5
|
+
.gt-text-display { font-family: var(--font-display); font-size: var(--type-display-size); line-height: var(--type-display-leading); font-weight: var(--type-display-weight); letter-spacing: var(--type-display-tracking); }
|
|
6
|
+
.gt-text-heading { font-family: var(--font-display); font-size: var(--type-heading-size); line-height: var(--type-heading-leading); font-weight: var(--type-heading-weight); letter-spacing: var(--type-heading-tracking); }
|
|
7
|
+
.gt-text-subheading { font-family: var(--font-display); font-size: var(--type-subheading-size); line-height: var(--type-subheading-leading); font-weight: var(--type-subheading-weight); letter-spacing: var(--type-subheading-tracking); }
|
|
8
|
+
.gt-text-title { font-family: var(--font-display); font-size: var(--type-title-size); line-height: var(--type-title-leading); font-weight: var(--type-title-weight); letter-spacing: var(--type-title-tracking); }
|
|
9
|
+
.gt-text-body { font-family: var(--font-sans); font-size: var(--type-body-size); line-height: var(--type-body-leading); font-weight: var(--type-body-weight); }
|
|
10
|
+
.gt-text-label { font-family: var(--font-sans); font-size: var(--type-label-size); line-height: var(--type-label-leading); font-weight: var(--type-label-weight); }
|
|
11
|
+
.gt-text-caption { font-family: var(--font-sans); font-size: var(--type-caption-size); line-height: var(--type-caption-leading); font-weight: var(--type-caption-weight); }
|
|
12
|
+
.gt-text-micro { font-family: var(--font-sans); font-size: var(--type-micro-size); line-height: var(--type-micro-leading); font-weight: var(--type-micro-weight); }
|
|
13
|
+
.gt-text-code { font-family: var(--font-mono); font-size: var(--type-code-size); line-height: var(--type-code-leading); font-weight: var(--type-code-weight); }
|
|
14
|
+
|
|
15
|
+
/* Tone modifiers. Size and weight stay on .gt-text-{variant}; colour comes from semantic text tokens. */
|
|
16
|
+
.gt-text--primary { color: var(--color-text-default-primary); }
|
|
17
|
+
.gt-text--secondary { color: var(--color-text-default-secondary); }
|
|
18
|
+
.gt-text--danger { color: var(--color-text-danger-primary); }
|
|
19
|
+
.gt-text--success { color: var(--color-text-success-primary); }
|
|
20
|
+
.gt-text--warning { color: var(--color-text-warning-primary); }
|
|
21
|
+
.gt-text--info { color: var(--color-text-info-primary); }
|
|
22
|
+
.gt-text--inverse { color: var(--color-text-inverse-primary); }
|
|
23
|
+
.gt-text--accent { color: var(--color-text-accent-primary); }
|
|
24
|
+
|
|
25
|
+
/* Text and Heading render native h1-h6 and p; drop the browser margins so spacing comes only from layout (zero specificity, so any layout rule wins). */
|
|
26
|
+
:where(h1, h2, h3, h4, h5, h6, p)[class*="gt-text-"] { margin: 0; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,92 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itkeazco/graphite",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Graphite design system — soft-grey, tactile React components and design tokens.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./tokens": {
|
|
16
|
+
"types": "./dist/tokens.d.ts",
|
|
17
|
+
"import": "./dist/tokens.js",
|
|
18
|
+
"default": "./dist/tokens.js"
|
|
19
|
+
},
|
|
20
|
+
"./tokens.json": "./dist/tokens.json",
|
|
21
|
+
"./index.css": "./dist/index.css",
|
|
22
|
+
"./tokens.css": "./dist/tokens.css",
|
|
23
|
+
"./neutrals.css": "./dist/neutrals.css",
|
|
24
|
+
"./styles.css": "./dist/styles.css",
|
|
25
|
+
"./typography.css": "./dist/typography.css",
|
|
26
|
+
"./fonts.css": "./dist/fonts.css",
|
|
27
|
+
"./layers.css": "./dist/layers.css",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"bin",
|
|
33
|
+
"rules",
|
|
34
|
+
"README.md",
|
|
35
|
+
"CHANGELOG.md"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": [
|
|
38
|
+
"**/*.css"
|
|
39
|
+
],
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"lucide-react": ">=1.0.0",
|
|
42
|
+
"react": ">=18",
|
|
43
|
+
"react-dom": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"design-system",
|
|
47
|
+
"react",
|
|
48
|
+
"components",
|
|
49
|
+
"tokens",
|
|
50
|
+
"graphite"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"license": "UNLICENSED",
|
|
56
|
+
"bin": {
|
|
57
|
+
"graphite": "bin/graphite.js"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "node scripts/build-tokens.mjs && node scripts/build-neutrals.mjs && node scripts/copy-css.mjs && tsup",
|
|
61
|
+
"prepublishOnly": "npm run build",
|
|
62
|
+
"preversion": "npm run lint && npm test && npm run build",
|
|
63
|
+
"docs": "vite docs --open",
|
|
64
|
+
"docs:build": "vite build docs",
|
|
65
|
+
"release:patch": "npm version patch && git push --follow-tags",
|
|
66
|
+
"release:minor": "npm version minor && git push --follow-tags",
|
|
67
|
+
"v2:tokens": "node v2/bin/generate.ts v2/projects/mori",
|
|
68
|
+
"v2:test": "node --test v2/test/*.test.ts",
|
|
69
|
+
"v2:check": "tsc -p v2/tsconfig.json && node --test v2/test/*.test.ts",
|
|
70
|
+
"v2:app": "node v2/app/build.mjs",
|
|
71
|
+
"v2:app:watch": "node v2/app/build.mjs --watch",
|
|
72
|
+
"v2:figma": "node v2/bin/figma.ts v2/projects/mori"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@types/node": "^24.19.2",
|
|
76
|
+
"@types/react": "^19.3.0",
|
|
77
|
+
"@types/react-dom": "^19.3.0",
|
|
78
|
+
"lucide-react": "^1.52.0",
|
|
79
|
+
"react": "^19.0.0",
|
|
80
|
+
"react-dom": "^19.0.0",
|
|
81
|
+
"tsup": "^8.5.1",
|
|
82
|
+
"typescript": "5.9",
|
|
83
|
+
"vite": "^8.3.0"
|
|
84
|
+
},
|
|
85
|
+
"repository": {
|
|
86
|
+
"type": "git",
|
|
87
|
+
"url": "git+https://github.com/ItkeazCo/graphite.git"
|
|
88
|
+
},
|
|
89
|
+
"engines": {
|
|
90
|
+
"node": ">=18"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Build UI with the Graphite design system (@itkeazco/graphite) — components, tokens, states and wording.
|
|
3
|
+
globs: ["**/*.tsx", "**/*.jsx", "**/*.css", "**/*.scss"]
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Graphite design system
|
|
8
|
+
|
|
9
|
+
This project uses **Graphite** (`@itkeazco/graphite`). Build every screen from Graphite components and tokens. Never hand-build a control that Graphite already has, and never hard-code colours, spacing, radius or shadows.
|
|
10
|
+
|
|
11
|
+
Types and props: `node_modules/@itkeazco/graphite/dist/index.d.ts`. Full guide: `node_modules/@itkeazco/graphite/README.md`. Read them before using a component you haven't used yet.
|
|
12
|
+
|
|
13
|
+
## Setup (already done if `index.css` is imported)
|
|
14
|
+
|
|
15
|
+
- `import "@itkeazco/graphite/index.css";` once, in `app/layout.tsx` (or `pages/_app.tsx`). Run `npx graphite init` if it's missing.
|
|
16
|
+
- Components are client components (`"use client"` is built in) — use them directly in server pages.
|
|
17
|
+
- Dark mode: `data-theme="dark"` or `class="dark"` on `<html>`; with neither, it follows the OS.
|
|
18
|
+
|
|
19
|
+
## Components — use these, don't rebuild them
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { Button, IconButton, SegmentedControl, SliderField, Switch, Checkbox,
|
|
23
|
+
RadioGroup, RadioCards, ChipGroup, Input, Textarea, Select, SettingRow, Card, ListRow, Divider, Badge, Avatar,
|
|
24
|
+
Kbd, Progress, Tooltip, Toast, Panel, Stage, Dialog, Icon, Text, Heading } from "@itkeazco/graphite";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Need | Use |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| Any action | `Button` — `variant="primary"` for the ONE main action per surface; `secondary` (default), `soft` inside panels, `ghost` low emphasis, `danger` destructive, `overlay` white with no stroke on a scrim, image or video. `size` sm/md/lg, `icon`, `block`, `loading` |
|
|
30
|
+
| Icon-only action | `IconButton` with a required `label`; wrap in `Tooltip` |
|
|
31
|
+
| 2–5 short exclusive options (inspector, toolbar) | `SegmentedControl` |
|
|
32
|
+
| 2–5 exclusive options in a form | `RadioGroup`; options that need a sentence each → `RadioCards` |
|
|
33
|
+
| Tunable number | `SliderField` (label and value sit inside the track); exact typed number → `Input` |
|
|
34
|
+
| Instant on/off | `Switch` (`label` or `ariaLabel`, `onCheckedChange`); on/off applied on save → `Checkbox` (`onCheckedChange`; native `onChange` is the event) |
|
|
35
|
+
| Filters, presets, tags | `ChipGroup` (`multiple` for multi-select, `onValueChange`, `label` on the group) |
|
|
36
|
+
| Text fields | `Input` (one line), `Textarea` (several), `Select` (six or more options, `onValueChange`; native `onChange` is the event) — always with `label`; `hint` / `error` below |
|
|
37
|
+
| Interface copy | `Text` / `Heading` — they apply `.gt-text-*` classes from typography.css (source of truth for size and weight). Secondary colour: `<Text tone="secondary">` (class `.gt-text--secondary`, token `--color-text-default-secondary`). Do not invent font sizes or set colour with an inline style |
|
|
38
|
+
| A group of related content | `Card` (`variant="surface"` or `"elevated"`) |
|
|
39
|
+
| A tappable item in a list | `ListRow` (`href` or `onClick`; `chevron` when the row opens something) |
|
|
40
|
+
| A hairline between sections | `Divider` (`orientation="vertical"` in a row; `inset` to pull a rule in) |
|
|
41
|
+
| Settings list | `SettingRow` with a `Switch`, `Select` or `Button size="sm" variant="soft"` |
|
|
42
|
+
| Status word | `Badge` — `tone` neutral/solid/outline/live/success/warning/danger/info |
|
|
43
|
+
| Something just happened | `Toast` — past tense, one action max |
|
|
44
|
+
| Confirm something irreversible | `Dialog`; the confirm button repeats the verb ("Discard") |
|
|
45
|
+
| Long work | `Progress` (`indeterminate` if unknown, `error` on failure) |
|
|
46
|
+
| Person | `Avatar` (`status` online/live/away) |
|
|
47
|
+
| Shortcut | `Kbd` |
|
|
48
|
+
| Icons | Lucide only. Common names: `<Icon name="mic" />`, `<Button icon="download">`. Anything else: `import { CloudUpload } from "lucide-react"` and pass it — `<Button icon={CloudUpload}>`, `<Icon name={CloudUpload} />`. Never another icon library, emoji or hand-made SVG |
|
|
49
|
+
|
|
50
|
+
If something isn't in Graphite (tabs, menus, popovers, date pickers…), build it from Graphite **tokens** to match, and flag it as a candidate component in a code comment.
|
|
51
|
+
|
|
52
|
+
## Tokens — never raw values
|
|
53
|
+
|
|
54
|
+
Use CSS variables. Components read semantic tokens; app layout CSS does too.
|
|
55
|
+
|
|
56
|
+
- **Surfaces:** `--color-bg-surface-secondary` → `--color-bg-surface-tertiary` → `--color-bg-surface-primary` (raised). Recessed tracks: `--color-bg-neutral-secondary`, hover `--color-bg-neutral-secondary-hover`, amount `--color-bg-neutral-primary`. One black action: `--color-bg-inverse-primary` + `--color-text-inverse-primary`.
|
|
57
|
+
- **Text:** `--color-text-default-primary`, `--color-text-default-secondary` (hints, descriptions), `--color-text-default-tertiary` (placeholders only).
|
|
58
|
+
- **Borders:** `--color-border-default-tertiary` (dividers), `--color-border-default-secondary` (control outlines), `--color-border-default-primary` (selected / focused).
|
|
59
|
+
- **Status:** `--status-{success|warning|danger|info}` solid; `--text-{status}` ink; `--bg-{status}-subtle` tinted ground; `--border-{status}`. Ink on a solid status fill: `--color-text-onbold-primary` (amber: `--color-text-onwarning-primary`).
|
|
60
|
+
- **Accent (opt-in, not the primary button):** `--color-bg-accent-primary`, `--color-text-accent-primary`, `--color-bg-accent-secondary`. Primary actions use `--color-bg-brand-primary` and `--button-primary-*`; `--color-bg-inverse-primary` is only for tooltips and solid badges.
|
|
61
|
+
- **Space:** `--gap-tight` 4, `--gap-control` 8, `--gap-inline` 12, `--gap-group` 24, `--gap-section` 40; `--inset-control` 12, `--inset-button` 16, `--inset-container` 20.
|
|
62
|
+
- **Radius:** `--radius-control` (pills: things you press), `--radius-field` (things you drag / type in), `--radius-card`, `--radius-container`.
|
|
63
|
+
- **Heights:** `--control-sm` 28, `--control-md` 36, `--control-lg` 42, `--control-xl` 64.
|
|
64
|
+
- **Elevation:** `--shadow-raised`, `--shadow-floating`. **Motion:** `--duration-fast`, `--duration-base`, `--ease-out`, `--ease-spring`.
|
|
65
|
+
- **Type:** `--font-sans` (Inter) for interface text, timers and shortcuts. `--font-mono` (Menlo) only for code. Text styles: `.gt-text-title`, `.gt-text-body`, `.gt-text-label`, `.gt-text-caption`, `.gt-text-micro` from `@itkeazco/graphite/typography.css`.
|
|
66
|
+
|
|
67
|
+
Primitive palettes (`--graphite-*`, `--blue-600`, `--red-500` … full Tailwind palette) exist, but **don't use them in product code** — use a semantic token. To brand a product, ship a stylesheet and set `data-brand` on `<html>`. Remap `--color-bg-inverse-primary`, `--color-bg-inverse-primary-hover`, `--color-bg-inverse-primary-pressed` and `--color-text-inverse-primary` for the primary action (buttons already alias those through `--button-primary-*`). `--color-bg-accent-primary` does not colour buttons. For Hebrew, set `dir="rtl"` — Graphite layout and arrow keys follow it. To restyle one component, override its component token (e.g. `--button-radius`) on a container. Never edit files in `node_modules`.
|
|
68
|
+
|
|
69
|
+
Need a value in JS (charts, canvas)? `import { tokens } from "@itkeazco/graphite/tokens"`.
|
|
70
|
+
|
|
71
|
+
## Look and feel
|
|
72
|
+
|
|
73
|
+
- Greyscale surfaces; colour only means something (status, live, accent).
|
|
74
|
+
- Fills, not borders: controls sit in recessed wells; the active part is a raised white thumb or a grey fill.
|
|
75
|
+
- Pills for things you press, rounded rectangles for things you drag, big soft corners for containers.
|
|
76
|
+
- One primary (black) button per surface. Panel footers: secondary above primary, both `block size="lg"`.
|
|
77
|
+
|
|
78
|
+
## Icons — Lucide only
|
|
79
|
+
|
|
80
|
+
- Graphite has no icon artwork of its own; every icon is Lucide (`lucide-react`), drawn at `--icon-stroke` (1.75). Browse: lucide.dev/icons.
|
|
81
|
+
- The 48 most-used icons work by Lucide name (`x`, `chevron-down`, `trash-2`, `triangle-alert`, `settings`, `download`…) — see `IconName` in the types.
|
|
82
|
+
- For any other icon: `import { CloudUpload } from "lucide-react"` and pass the component to an `icon` prop or `<Icon name={CloudUpload} />`. Don't place bare lucide-react icons next to Graphite controls — wrap them in `Icon` so size and stroke match.
|
|
83
|
+
- Sizes: 16 small controls, 18 buttons, 20 toolbars. Icon-only buttons are `IconButton` with a `label`.
|
|
84
|
+
|
|
85
|
+
## States — every interactive thing has them
|
|
86
|
+
|
|
87
|
+
Default, hover, pressed, focus (2px `--color-border-focus-primary`), disabled (`--opacity-disabled`), plus selected / error / loading where they apply. Graphite components handle these already — pass the prop (`disabled`, `error`, `loading`, `value`) rather than styling states yourself. Show form errors after a submit attempt, and use `noValidate` on forms so Graphite's error appears instead of the browser bubble.
|
|
88
|
+
|
|
89
|
+
## Wording
|
|
90
|
+
|
|
91
|
+
- Sentence case everywhere: "Save note", not "Save Note".
|
|
92
|
+
- Buttons are verbs, one or two words. Toasts are past tense ("Note saved"). Errors say how to fix it ("Use a number in pixels, like 28px.").
|
|
93
|
+
- No exclamation marks, no emoji, no "Success!".
|
|
94
|
+
|
|
95
|
+
## Accessibility
|
|
96
|
+
|
|
97
|
+
- Every input has a `label` (or `ariaLabel` / `label` prop on icon-only controls).
|
|
98
|
+
- Don't remove focus outlines. Don't rely on colour alone — Badges carry a word.
|
|
99
|
+
- Group radios with `RadioGroup` / `RadioCards` (they render a fieldset + legend).
|