@kornorg/design-system 0.7.1 → 0.8.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/README.md CHANGED
@@ -31,7 +31,10 @@ export function Example() {
31
31
  Each theme stylesheet is self-contained (component styles, the full semantic-token
32
32
  utility vocabulary, and the Geist `@font-face` faces) — no Tailwind setup required
33
33
  in the consuming app. Token values are also importable from
34
- `@kornorg/design-system/tokens`.
34
+ `@kornorg/design-system/tokens` — `light` and `dark` give resolved literal values
35
+ (real oklch colors, real pixel radii) for code that has no CSS to resolve a
36
+ `var(--x)` reference against: chart libraries, canvas/SVG rendering, email
37
+ templates.
35
38
 
36
39
  ### Components
37
40
 
@@ -149,8 +152,10 @@ pnpm check:contrast # Regenerate docs/accessibility/contrast.md after a token ch
149
152
  ```
150
153
 
151
154
  - **Components** live in `src/components/ui/` (one file each), re-exported from
152
- `src/components/ui/index.ts`. Styling tokens are in `src/app/globals.css`
153
- (mirrored as typed values in `src/tokens.ts`).
155
+ `src/components/ui/index.ts`. Styling tokens are in `src/styles/themes/*.css`
156
+ (one file per feel); `src/tokens.ts` types the values with no CSS backing
157
+ (spacing, type scale, font weights) and `scripts/build-css.mjs` resolves the
158
+ default theme's CSS to literal values for the rest.
154
159
  - **The package build** (tsup + Tailwind CLI) emits `dist/` — see
155
160
  [ADR-0011](./docs/adr/0011-design-system-package.md).
156
161
  - **Adding/changing components**: edit source, run `pnpm build`, then re-sync to
package/dist/tokens.d.ts CHANGED
@@ -1,56 +1,18 @@
1
1
  /**
2
- * Design tokens — typed source of truth.
2
+ * Design tokens — typed source of truth for the values that have no CSS
3
+ * backing (spacing scale, type scale, font weights).
3
4
  *
4
- * These mirror the CSS custom properties declared in `src/app/globals.css`.
5
- * Components consume tokens through Tailwind utility classes (e.g. `bg-primary`);
6
- * this file is for code that needs token values directly — chart libraries,
7
- * canvas/SVG rendering, email templates, or programmatic theming.
8
- *
9
- * Keep this in sync with globals.css when values change.
5
+ * Color, radius, and font-family values live in a theme's CSS custom
6
+ * properties (`src/styles/themes/<feel>.css`) instead — components consume
7
+ * those through Tailwind utility classes (e.g. `bg-primary`), which is the
8
+ * only place a `var(--x)` reference resolves. The published `tokens` export
9
+ * needs to work without a DOM (chart libraries, canvas/SVG rendering, email
10
+ * templates), so `scripts/build-css.mjs` resolves the default theme's CSS to
11
+ * literal values at build time and appends them to this file's build output
12
+ * as `light` / `dark` (see `scripts/generate-tokens.mjs`), plus `radii` and
13
+ * `fontFamily`. Import them from `@kornorg/design-system/tokens` alongside
14
+ * the tokens defined here — this source file only has the pieces below.
10
15
  */
11
- /** Semantic color tokens. Values are the light-mode references; the dark
12
- * variant is applied at runtime via the `.dark` class in globals.css. */
13
- declare const colors: {
14
- readonly background: "var(--background)";
15
- readonly foreground: "var(--foreground)";
16
- readonly card: "var(--card)";
17
- readonly cardForeground: "var(--card-foreground)";
18
- readonly popover: "var(--popover)";
19
- readonly popoverForeground: "var(--popover-foreground)";
20
- readonly muted: "var(--muted)";
21
- readonly mutedForeground: "var(--muted-foreground)";
22
- readonly primary: "var(--primary)";
23
- readonly primaryForeground: "var(--primary-foreground)";
24
- readonly secondary: "var(--secondary)";
25
- readonly secondaryForeground: "var(--secondary-foreground)";
26
- readonly accent: "var(--accent)";
27
- readonly accentForeground: "var(--accent-foreground)";
28
- readonly destructive: "var(--destructive)";
29
- readonly destructiveForeground: "var(--destructive-foreground)";
30
- readonly success: "var(--success)";
31
- readonly successForeground: "var(--success-foreground)";
32
- readonly warning: "var(--warning)";
33
- readonly warningForeground: "var(--warning-foreground)";
34
- readonly border: "var(--border)";
35
- readonly input: "var(--input)";
36
- readonly ring: "var(--ring)";
37
- readonly overlay: "var(--overlay)";
38
- };
39
- /** Border-radius scale. Base radius is 0.5rem (8px). */
40
- declare const radii: {
41
- readonly sm: "var(--radius-sm)";
42
- readonly md: "var(--radius-md)";
43
- readonly lg: "var(--radius-lg)";
44
- readonly xl: "var(--radius-xl)";
45
- readonly full: "9999px";
46
- };
47
- /** Soft elevation shadow scale. */
48
- declare const shadows: {
49
- readonly xs: "var(--shadow-xs)";
50
- readonly sm: "var(--shadow-sm)";
51
- readonly md: "var(--shadow-md)";
52
- readonly lg: "var(--shadow-lg)";
53
- };
54
16
  /**
55
17
  * Spacing scale (rem). Matches Tailwind's default 4px step so utility classes
56
18
  * (`p-4`, `gap-2`, …) and token references stay aligned.
@@ -87,86 +49,103 @@ declare const fontWeight: {
87
49
  readonly semibold: "600";
88
50
  readonly bold: "700";
89
51
  };
90
- declare const fontFamily: {
91
- readonly sans: "var(--font-geist-sans), system-ui, sans-serif";
92
- readonly mono: "var(--font-geist-mono), ui-monospace, monospace";
52
+
53
+ export { fontSize, fontWeight, spacing };
54
+
55
+ // --- Generated by scripts/build-css.mjs from src/styles/themes/modern-neutral.css. ---
56
+ /** Resolved literal values (colors, shadows) for the default theme's light
57
+ * mode — no var(--x) — usable outside a DOM styling context: chart
58
+ * libraries, canvas/SVG rendering, email templates. */
59
+ export declare const light: {
60
+ readonly colors: {
61
+ readonly background: "oklch(1 0 0)";
62
+ readonly foreground: "oklch(0.21 0.006 285.9)";
63
+ readonly card: "oklch(1 0 0)";
64
+ readonly cardForeground: "oklch(0.21 0.006 285.9)";
65
+ readonly popover: "oklch(1 0 0)";
66
+ readonly popoverForeground: "oklch(0.21 0.006 285.9)";
67
+ readonly muted: "oklch(0.967 0.001 286.4)";
68
+ readonly mutedForeground: "oklch(0.543 0.016 285.9)";
69
+ readonly primary: "oklch(0.585 0.233 277.1)";
70
+ readonly primaryForeground: "oklch(0.985 0 0)";
71
+ readonly secondary: "oklch(0.967 0.001 286.4)";
72
+ readonly secondaryForeground: "oklch(0.21 0.006 285.9)";
73
+ readonly accent: "oklch(0.967 0.001 286.4)";
74
+ readonly accentForeground: "oklch(0.21 0.006 285.9)";
75
+ readonly destructive: "oklch(0.577 0.245 27.3)";
76
+ readonly destructiveForeground: "oklch(0.985 0 0)";
77
+ readonly success: "oklch(0.596 0.145 163.2)";
78
+ readonly successForeground: "oklch(0.985 0 0)";
79
+ readonly warning: "oklch(0.769 0.166 70.1)";
80
+ readonly warningForeground: "oklch(0.21 0.006 285.9)";
81
+ readonly border: "oklch(0.92 0.004 286.3)";
82
+ readonly input: "oklch(0.92 0.004 286.3)";
83
+ readonly ring: "oklch(0.585 0.233 277.1)";
84
+ readonly overlay: "oklch(0.21 0.006 285.9 / 0.5)";
85
+ };
86
+ readonly shadows: {
87
+ readonly xs: "0 1px 2px 0 oklch(0.21 0.006 285.9 / 0.05)";
88
+ readonly sm: "0 1px 3px 0 oklch(0.21 0.006 285.9 / 0.1), 0 1px 2px -1px oklch(0.21 0.006 285.9 / 0.1)";
89
+ readonly md: "0 4px 6px -1px oklch(0.21 0.006 285.9 / 0.1), 0 2px 4px -2px oklch(0.21 0.006 285.9 / 0.1)";
90
+ readonly lg: "0 10px 15px -3px oklch(0.21 0.006 285.9 / 0.1), 0 4px 6px -4px oklch(0.21 0.006 285.9 / 0.1)";
91
+ };
92
+ };
93
+ /** Same as `light`, resolved from the theme's `.dark` block. */
94
+ export declare const dark: {
95
+ readonly colors: {
96
+ readonly background: "oklch(0.21 0.006 285.9)";
97
+ readonly foreground: "oklch(0.985 0 0)";
98
+ readonly card: "oklch(0.27 0.006 286)";
99
+ readonly cardForeground: "oklch(0.985 0 0)";
100
+ readonly popover: "oklch(0.27 0.006 286)";
101
+ readonly popoverForeground: "oklch(0.985 0 0)";
102
+ readonly muted: "oklch(0.27 0.006 286)";
103
+ readonly mutedForeground: "oklch(0.712 0.013 286.1)";
104
+ readonly primary: "oklch(0.673 0.182 276.9)";
105
+ readonly primaryForeground: "oklch(0.21 0.006 285.9)";
106
+ readonly secondary: "oklch(0.27 0.006 286)";
107
+ readonly secondaryForeground: "oklch(0.985 0 0)";
108
+ readonly accent: "oklch(0.37 0.012 285.8)";
109
+ readonly accentForeground: "oklch(0.985 0 0)";
110
+ readonly destructive: "oklch(0.677 0.191 22.2)";
111
+ readonly destructiveForeground: "oklch(0.985 0 0)";
112
+ readonly success: "oklch(0.696 0.17 162.5)";
113
+ readonly successForeground: "oklch(0.21 0.006 285.9)";
114
+ readonly warning: "oklch(0.828 0.189 84.4)";
115
+ readonly warningForeground: "oklch(0.21 0.006 285.9)";
116
+ readonly border: "oklch(1 0 0 / 0.1)";
117
+ readonly input: "oklch(1 0 0 / 0.15)";
118
+ readonly ring: "oklch(0.673 0.182 276.9)";
119
+ readonly overlay: "oklch(0 0 0 / 0.7)";
120
+ };
121
+ readonly shadows: {
122
+ readonly xs: "0 1px 2px 0 oklch(0 0 0 / 0.3)";
123
+ readonly sm: "0 1px 3px 0 oklch(0 0 0 / 0.4), 0 1px 2px -1px oklch(0 0 0 / 0.4)";
124
+ readonly md: "0 4px 6px -1px oklch(0 0 0 / 0.4), 0 2px 4px -2px oklch(0 0 0 / 0.4)";
125
+ readonly lg: "0 10px 15px -3px oklch(0 0 0 / 0.5), 0 4px 6px -4px oklch(0 0 0 / 0.5)";
126
+ };
93
127
  };
94
- declare const tokens: {
95
- readonly colors: {
96
- readonly background: "var(--background)";
97
- readonly foreground: "var(--foreground)";
98
- readonly card: "var(--card)";
99
- readonly cardForeground: "var(--card-foreground)";
100
- readonly popover: "var(--popover)";
101
- readonly popoverForeground: "var(--popover-foreground)";
102
- readonly muted: "var(--muted)";
103
- readonly mutedForeground: "var(--muted-foreground)";
104
- readonly primary: "var(--primary)";
105
- readonly primaryForeground: "var(--primary-foreground)";
106
- readonly secondary: "var(--secondary)";
107
- readonly secondaryForeground: "var(--secondary-foreground)";
108
- readonly accent: "var(--accent)";
109
- readonly accentForeground: "var(--accent-foreground)";
110
- readonly destructive: "var(--destructive)";
111
- readonly destructiveForeground: "var(--destructive-foreground)";
112
- readonly success: "var(--success)";
113
- readonly successForeground: "var(--success-foreground)";
114
- readonly warning: "var(--warning)";
115
- readonly warningForeground: "var(--warning-foreground)";
116
- readonly border: "var(--border)";
117
- readonly input: "var(--input)";
118
- readonly ring: "var(--ring)";
119
- readonly overlay: "var(--overlay)";
120
- };
121
- readonly radii: {
122
- readonly sm: "var(--radius-sm)";
123
- readonly md: "var(--radius-md)";
124
- readonly lg: "var(--radius-lg)";
125
- readonly xl: "var(--radius-xl)";
126
- readonly full: "9999px";
127
- };
128
- readonly shadows: {
129
- readonly xs: "var(--shadow-xs)";
130
- readonly sm: "var(--shadow-sm)";
131
- readonly md: "var(--shadow-md)";
132
- readonly lg: "var(--shadow-lg)";
133
- };
134
- readonly spacing: {
135
- readonly 0: "0rem";
136
- readonly 0.5: "0.125rem";
137
- readonly 1: "0.25rem";
138
- readonly 2: "0.5rem";
139
- readonly 3: "0.75rem";
140
- readonly 4: "1rem";
141
- readonly 5: "1.25rem";
142
- readonly 6: "1.5rem";
143
- readonly 8: "2rem";
144
- readonly 10: "2.5rem";
145
- readonly 12: "3rem";
146
- readonly 16: "4rem";
147
- };
148
- readonly fontSize: {
149
- readonly xs: readonly ["0.75rem", "1rem"];
150
- readonly sm: readonly ["0.875rem", "1.25rem"];
151
- readonly base: readonly ["1rem", "1.5rem"];
152
- readonly lg: readonly ["1.125rem", "1.75rem"];
153
- readonly xl: readonly ["1.25rem", "1.75rem"];
154
- readonly "2xl": readonly ["1.5rem", "2rem"];
155
- readonly "3xl": readonly ["1.875rem", "2.25rem"];
156
- readonly "4xl": readonly ["2.25rem", "2.5rem"];
157
- readonly "5xl": readonly ["3rem", "1"];
158
- };
159
- readonly fontWeight: {
160
- readonly normal: "400";
161
- readonly medium: "500";
162
- readonly semibold: "600";
163
- readonly bold: "700";
164
- };
165
- readonly fontFamily: {
166
- readonly sans: "var(--font-geist-sans), system-ui, sans-serif";
167
- readonly mono: "var(--font-geist-mono), ui-monospace, monospace";
168
- };
128
+ /** Border-radius scale, resolved to literal pixel values. Mode-independent —
129
+ * the theme has no `.dark` override for radius. */
130
+ export declare const radii: {
131
+ readonly sm: "4px";
132
+ readonly md: "6px";
133
+ readonly lg: "8px";
134
+ readonly xl: "12px";
135
+ readonly full: "9999px";
169
136
  };
170
- type Tokens = typeof tokens;
171
-
172
- export { type Tokens, colors, fontFamily, fontSize, fontWeight, radii, shadows, spacing, tokens };
137
+ /** Font stacks, resolved to literal face names. Mode-independent. */
138
+ export declare const fontFamily: {
139
+ readonly sans: "\"Geist\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif";
140
+ readonly mono: "\"Geist Mono\", ui-monospace, SFMono-Regular, \"SF Mono\", Menlo, monospace";
141
+ };
142
+ export declare const tokens: {
143
+ readonly light: typeof light;
144
+ readonly dark: typeof dark;
145
+ readonly radii: typeof radii;
146
+ readonly spacing: typeof spacing;
147
+ readonly fontSize: typeof fontSize;
148
+ readonly fontWeight: typeof fontWeight;
149
+ readonly fontFamily: typeof fontFamily;
150
+ };
151
+ export type Tokens = typeof tokens;
package/dist/tokens.mjs CHANGED
@@ -1,47 +1,4 @@
1
1
  // src/tokens.ts
2
- var colors = {
3
- background: "var(--background)",
4
- foreground: "var(--foreground)",
5
- card: "var(--card)",
6
- cardForeground: "var(--card-foreground)",
7
- popover: "var(--popover)",
8
- popoverForeground: "var(--popover-foreground)",
9
- muted: "var(--muted)",
10
- mutedForeground: "var(--muted-foreground)",
11
- primary: "var(--primary)",
12
- primaryForeground: "var(--primary-foreground)",
13
- secondary: "var(--secondary)",
14
- secondaryForeground: "var(--secondary-foreground)",
15
- accent: "var(--accent)",
16
- accentForeground: "var(--accent-foreground)",
17
- destructive: "var(--destructive)",
18
- destructiveForeground: "var(--destructive-foreground)",
19
- success: "var(--success)",
20
- successForeground: "var(--success-foreground)",
21
- warning: "var(--warning)",
22
- warningForeground: "var(--warning-foreground)",
23
- border: "var(--border)",
24
- input: "var(--input)",
25
- ring: "var(--ring)",
26
- overlay: "var(--overlay)"
27
- };
28
- var radii = {
29
- sm: "var(--radius-sm)",
30
- // 4px
31
- md: "var(--radius-md)",
32
- // 6px
33
- lg: "var(--radius-lg)",
34
- // 8px
35
- xl: "var(--radius-xl)",
36
- // 12px
37
- full: "9999px"
38
- };
39
- var shadows = {
40
- xs: "var(--shadow-xs)",
41
- sm: "var(--shadow-sm)",
42
- md: "var(--shadow-md)",
43
- lg: "var(--shadow-lg)"
44
- };
45
2
  var spacing = {
46
3
  0: "0rem",
47
4
  0.5: "0.125rem",
@@ -84,18 +41,99 @@ var fontWeight = {
84
41
  semibold: "600",
85
42
  bold: "700"
86
43
  };
44
+
45
+ export { fontSize, fontWeight, spacing };
46
+
47
+ // --- Generated by scripts/build-css.mjs from src/styles/themes/modern-neutral.css. ---
48
+ // Resolved literal values — no var(--x) — for canvas/SVG/email use, where
49
+ // there's no DOM to resolve a CSS custom property against.
50
+ var light = {
51
+ colors: {
52
+ background: "oklch(1 0 0)",
53
+ foreground: "oklch(0.21 0.006 285.9)",
54
+ card: "oklch(1 0 0)",
55
+ cardForeground: "oklch(0.21 0.006 285.9)",
56
+ popover: "oklch(1 0 0)",
57
+ popoverForeground: "oklch(0.21 0.006 285.9)",
58
+ muted: "oklch(0.967 0.001 286.4)",
59
+ mutedForeground: "oklch(0.543 0.016 285.9)",
60
+ primary: "oklch(0.585 0.233 277.1)",
61
+ primaryForeground: "oklch(0.985 0 0)",
62
+ secondary: "oklch(0.967 0.001 286.4)",
63
+ secondaryForeground: "oklch(0.21 0.006 285.9)",
64
+ accent: "oklch(0.967 0.001 286.4)",
65
+ accentForeground: "oklch(0.21 0.006 285.9)",
66
+ destructive: "oklch(0.577 0.245 27.3)",
67
+ destructiveForeground: "oklch(0.985 0 0)",
68
+ success: "oklch(0.596 0.145 163.2)",
69
+ successForeground: "oklch(0.985 0 0)",
70
+ warning: "oklch(0.769 0.166 70.1)",
71
+ warningForeground: "oklch(0.21 0.006 285.9)",
72
+ border: "oklch(0.92 0.004 286.3)",
73
+ input: "oklch(0.92 0.004 286.3)",
74
+ ring: "oklch(0.585 0.233 277.1)",
75
+ overlay: "oklch(0.21 0.006 285.9 / 0.5)",
76
+ },
77
+ shadows: {
78
+ xs: "0 1px 2px 0 oklch(0.21 0.006 285.9 / 0.05)",
79
+ sm: "0 1px 3px 0 oklch(0.21 0.006 285.9 / 0.1), 0 1px 2px -1px oklch(0.21 0.006 285.9 / 0.1)",
80
+ md: "0 4px 6px -1px oklch(0.21 0.006 285.9 / 0.1), 0 2px 4px -2px oklch(0.21 0.006 285.9 / 0.1)",
81
+ lg: "0 10px 15px -3px oklch(0.21 0.006 285.9 / 0.1), 0 4px 6px -4px oklch(0.21 0.006 285.9 / 0.1)",
82
+ }
83
+ };
84
+ var dark = {
85
+ colors: {
86
+ background: "oklch(0.21 0.006 285.9)",
87
+ foreground: "oklch(0.985 0 0)",
88
+ card: "oklch(0.27 0.006 286)",
89
+ cardForeground: "oklch(0.985 0 0)",
90
+ popover: "oklch(0.27 0.006 286)",
91
+ popoverForeground: "oklch(0.985 0 0)",
92
+ muted: "oklch(0.27 0.006 286)",
93
+ mutedForeground: "oklch(0.712 0.013 286.1)",
94
+ primary: "oklch(0.673 0.182 276.9)",
95
+ primaryForeground: "oklch(0.21 0.006 285.9)",
96
+ secondary: "oklch(0.27 0.006 286)",
97
+ secondaryForeground: "oklch(0.985 0 0)",
98
+ accent: "oklch(0.37 0.012 285.8)",
99
+ accentForeground: "oklch(0.985 0 0)",
100
+ destructive: "oklch(0.677 0.191 22.2)",
101
+ destructiveForeground: "oklch(0.985 0 0)",
102
+ success: "oklch(0.696 0.17 162.5)",
103
+ successForeground: "oklch(0.21 0.006 285.9)",
104
+ warning: "oklch(0.828 0.189 84.4)",
105
+ warningForeground: "oklch(0.21 0.006 285.9)",
106
+ border: "oklch(1 0 0 / 0.1)",
107
+ input: "oklch(1 0 0 / 0.15)",
108
+ ring: "oklch(0.673 0.182 276.9)",
109
+ overlay: "oklch(0 0 0 / 0.7)",
110
+ },
111
+ shadows: {
112
+ xs: "0 1px 2px 0 oklch(0 0 0 / 0.3)",
113
+ sm: "0 1px 3px 0 oklch(0 0 0 / 0.4), 0 1px 2px -1px oklch(0 0 0 / 0.4)",
114
+ md: "0 4px 6px -1px oklch(0 0 0 / 0.4), 0 2px 4px -2px oklch(0 0 0 / 0.4)",
115
+ lg: "0 10px 15px -3px oklch(0 0 0 / 0.5), 0 4px 6px -4px oklch(0 0 0 / 0.5)",
116
+ }
117
+ };
118
+ var radii = {
119
+ sm: "4px",
120
+ md: "6px",
121
+ lg: "8px",
122
+ xl: "12px",
123
+ full: "9999px",
124
+ };
87
125
  var fontFamily = {
88
- sans: "var(--font-geist-sans), system-ui, sans-serif",
89
- mono: "var(--font-geist-mono), ui-monospace, monospace"
126
+ sans: "\"Geist\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif",
127
+ mono: "\"Geist Mono\", ui-monospace, SFMono-Regular, \"SF Mono\", Menlo, monospace",
90
128
  };
91
129
  var tokens = {
92
- colors,
130
+ light,
131
+ dark,
93
132
  radii,
94
- shadows,
95
133
  spacing,
96
134
  fontSize,
97
135
  fontWeight,
98
136
  fontFamily
99
137
  };
100
138
 
101
- export { colors, fontFamily, fontSize, fontWeight, radii, shadows, spacing, tokens };
139
+ export { dark, fontFamily, light, radii, tokens };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kornorg/design-system",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Modern Neutral — a React + Tailwind CSS design system (components, tokens, Geist fonts).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://kornsour.github.io/design-system/",