@tallyui/theme 3.12.0 → 3.13.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/dist/index.d.ts CHANGED
@@ -1,6 +1,104 @@
1
1
  import { ClassValue } from 'clsx';
2
2
  export { ClassValue } from 'clsx';
3
3
 
4
+ declare const THEME_FONT_FAMILIES: {
5
+ readonly dmSans: "DM Sans";
6
+ readonly instrumentSerif: "Instrument Serif";
7
+ readonly jetbrainsMono: "JetBrains Mono";
8
+ readonly spaceGrotesk: "Space Grotesk";
9
+ readonly fraunces: "Fraunces";
10
+ readonly manrope: "Manrope";
11
+ };
12
+ type ThemeFontFamily = (typeof THEME_FONT_FAMILIES)[keyof typeof THEME_FONT_FAMILIES];
13
+ interface ThemeFontFace {
14
+ file: string;
15
+ weight: number;
16
+ style?: 'italic';
17
+ }
18
+ /**
19
+ * Faces an app must bundle (Google Fonts, SIL OFL 1.1), with v2's file names.
20
+ * Map each to an app asset, e.g. expo-font:
21
+ * { path: require('./assets/fonts/DMSans-400.ttf'), weight: 400, style, display: 'swap' }.
22
+ */
23
+ declare const FONT_FACES: Record<ThemeFontFamily, readonly ThemeFontFace[]>;
24
+ type ThemeType = {
25
+ body?: ThemeFontFamily;
26
+ num?: ThemeFontFamily;
27
+ display?: ThemeFontFamily;
28
+ displayItalic?: boolean;
29
+ };
30
+ declare const SYSTEM_TYPE: ThemeType;
31
+ declare const TYPE_SETS: {
32
+ readonly system: ThemeType;
33
+ readonly instrument: {
34
+ readonly body: "DM Sans";
35
+ readonly num: "JetBrains Mono";
36
+ readonly display: "Instrument Serif";
37
+ readonly displayItalic: true;
38
+ };
39
+ readonly grotesk: {
40
+ readonly body: "Space Grotesk";
41
+ readonly num: "Space Grotesk";
42
+ readonly display: "Space Grotesk";
43
+ };
44
+ readonly fraunces: {
45
+ readonly body: "DM Sans";
46
+ readonly num: "DM Sans";
47
+ readonly display: "Fraunces";
48
+ readonly displayItalic: true;
49
+ };
50
+ readonly manrope: {
51
+ readonly body: "Manrope";
52
+ readonly num: "Manrope";
53
+ readonly display: "Manrope";
54
+ };
55
+ };
56
+ type TypeSetId = keyof typeof TYPE_SETS;
57
+ declare const TYPE_SET_IDS: TypeSetId[];
58
+ declare const TYPE_SETTING_AUTO = "auto";
59
+ /** The `ui.font` choices in Settings order. */
60
+ declare const FONT_SETTINGS: readonly ('auto' | TypeSetId)[];
61
+ declare function familiesForType({ body, num, display }: ThemeType): ThemeFontFamily[];
62
+ /** An explicit set wins; auto, absent and unknown values resolve to `auto`. */
63
+ declare function resolveTypeSet(value: unknown, auto?: TypeSetId): TypeSetId;
64
+ declare function fontFamilyStyle(family: ThemeFontFamily | undefined, isWeb: boolean): {
65
+ fontFamily: string;
66
+ } | undefined;
67
+
4
68
  declare function cn(...inputs: ClassValue[]): string;
5
69
 
6
- export { cn };
70
+ /** Port of WCPOS v2 `packages/components/src/lib/scale.ts`. */
71
+ type ScaleStep = 'compact' | 'regular' | 'spacious';
72
+ type ScaleOverride = 'auto' | ScaleStep;
73
+ type Pointer = 'coarse' | 'fine';
74
+ type ScaleVariables = {
75
+ '--spacing': number;
76
+ '--text-base': number;
77
+ '--spacing-ctl': number;
78
+ '--spacing-row': number;
79
+ '--spacing-tile': number;
80
+ '--radius': number;
81
+ '--text-amt': number;
82
+ '--text-xs': number;
83
+ '--text-2xs': number;
84
+ };
85
+ /** The nine names in declaration order (the order of each SCALE_STEPS row). */
86
+ declare const SCALE_VARIABLE_NAMES: readonly ["--spacing", "--text-base", "--spacing-ctl", "--spacing-row", "--spacing-tile", "--radius", "--text-amt", "--text-xs", "--text-2xs"];
87
+ declare const SCALE_STEPS: {
88
+ readonly compact: readonly [3.5, 13, 40, 36, 56, 6, 34, 12, 11];
89
+ readonly regular: readonly [4, 14, 44, 44, 64, 8, 40, 12, 11];
90
+ readonly spacious: readonly [5, 16, 52, 52, 80, 10, 48, 14, 13];
91
+ };
92
+ declare const POINTER_FLOORS: {
93
+ readonly coarse: 44;
94
+ readonly fine: 24;
95
+ };
96
+ declare const AUTO_COMPACT_UNDER = 640;
97
+ declare const AUTO_SPACIOUS_FROM = 1600;
98
+ declare const MAX_FONT_SCALE = 1.3;
99
+ /** Explicit steps win; Auto and unknown stored values follow the window extent. */
100
+ declare function resolveStep(override: string | undefined | null, extent: number): ScaleStep;
101
+ /** Apply pointer target floors to controls and rows, leaving the other tokens unchanged. */
102
+ declare function scaleVariables(step: ScaleStep, pointer: Pointer): ScaleVariables;
103
+
104
+ export { AUTO_COMPACT_UNDER, AUTO_SPACIOUS_FROM, FONT_FACES, FONT_SETTINGS, MAX_FONT_SCALE, POINTER_FLOORS, type Pointer, SCALE_STEPS, SCALE_VARIABLE_NAMES, SYSTEM_TYPE, type ScaleOverride, type ScaleStep, type ScaleVariables, THEME_FONT_FAMILIES, TYPE_SETS, TYPE_SETTING_AUTO, TYPE_SET_IDS, type ThemeFontFace, type ThemeFontFamily, type ThemeType, type TypeSetId, cn, familiesForType, fontFamilyStyle, resolveStep, resolveTypeSet, scaleVariables };
package/dist/index.js CHANGED
@@ -1,9 +1,155 @@
1
+ // src/fonts.ts
2
+ var THEME_FONT_FAMILIES = {
3
+ dmSans: "DM Sans",
4
+ instrumentSerif: "Instrument Serif",
5
+ jetbrainsMono: "JetBrains Mono",
6
+ spaceGrotesk: "Space Grotesk",
7
+ fraunces: "Fraunces",
8
+ manrope: "Manrope"
9
+ };
10
+ var FONT_FACES = {
11
+ [THEME_FONT_FAMILIES.dmSans]: [
12
+ { file: "DMSans-400.ttf", weight: 400 },
13
+ { file: "DMSans-500.ttf", weight: 500 },
14
+ { file: "DMSans-600.ttf", weight: 600 },
15
+ { file: "DMSans-700.ttf", weight: 700 }
16
+ ],
17
+ [THEME_FONT_FAMILIES.instrumentSerif]: [
18
+ { file: "InstrumentSerif-400.ttf", weight: 400 },
19
+ { file: "InstrumentSerif-400Italic.ttf", weight: 400, style: "italic" }
20
+ ],
21
+ [THEME_FONT_FAMILIES.jetbrainsMono]: [
22
+ { file: "JetBrainsMono-400.ttf", weight: 400 },
23
+ { file: "JetBrainsMono-500.ttf", weight: 500 },
24
+ { file: "JetBrainsMono-600.ttf", weight: 600 }
25
+ ],
26
+ [THEME_FONT_FAMILIES.spaceGrotesk]: [
27
+ { file: "SpaceGrotesk-500.ttf", weight: 500 },
28
+ { file: "SpaceGrotesk-600.ttf", weight: 600 },
29
+ { file: "SpaceGrotesk-700.ttf", weight: 700 }
30
+ ],
31
+ [THEME_FONT_FAMILIES.fraunces]: [
32
+ { file: "Fraunces-500.ttf", weight: 500 },
33
+ { file: "Fraunces-600.ttf", weight: 600 },
34
+ { file: "Fraunces-500Italic.ttf", weight: 500, style: "italic" },
35
+ { file: "Fraunces-600Italic.ttf", weight: 600, style: "italic" }
36
+ ],
37
+ [THEME_FONT_FAMILIES.manrope]: [
38
+ { file: "Manrope-500.ttf", weight: 500 },
39
+ { file: "Manrope-600.ttf", weight: 600 },
40
+ { file: "Manrope-700.ttf", weight: 700 },
41
+ { file: "Manrope-800.ttf", weight: 800 }
42
+ ]
43
+ };
44
+ var SYSTEM_TYPE = {};
45
+ var TYPE_SETS = {
46
+ system: SYSTEM_TYPE,
47
+ instrument: {
48
+ body: THEME_FONT_FAMILIES.dmSans,
49
+ num: THEME_FONT_FAMILIES.jetbrainsMono,
50
+ display: THEME_FONT_FAMILIES.instrumentSerif,
51
+ displayItalic: true
52
+ },
53
+ grotesk: {
54
+ body: THEME_FONT_FAMILIES.spaceGrotesk,
55
+ num: THEME_FONT_FAMILIES.spaceGrotesk,
56
+ display: THEME_FONT_FAMILIES.spaceGrotesk
57
+ },
58
+ fraunces: {
59
+ body: THEME_FONT_FAMILIES.dmSans,
60
+ num: THEME_FONT_FAMILIES.dmSans,
61
+ display: THEME_FONT_FAMILIES.fraunces,
62
+ displayItalic: true
63
+ },
64
+ manrope: {
65
+ body: THEME_FONT_FAMILIES.manrope,
66
+ num: THEME_FONT_FAMILIES.manrope,
67
+ display: THEME_FONT_FAMILIES.manrope
68
+ }
69
+ };
70
+ var TYPE_SET_IDS = Object.keys(TYPE_SETS);
71
+ var TYPE_SETTING_AUTO = "auto";
72
+ var FONT_SETTINGS = [TYPE_SETTING_AUTO, ...TYPE_SET_IDS];
73
+ function familiesForType({ body, num, display }) {
74
+ return [...new Set([body, num, display].filter((family) => family !== void 0))];
75
+ }
76
+ function resolveTypeSet(value, auto = "system") {
77
+ return TYPE_SET_IDS.find((id) => id === value) ?? auto;
78
+ }
79
+ function fontFamilyStyle(family, isWeb) {
80
+ if (!family) return void 0;
81
+ if (!isWeb) return { fontFamily: family };
82
+ const fallback = family === THEME_FONT_FAMILIES.instrumentSerif || family === THEME_FONT_FAMILIES.fraunces ? "ui-serif, serif" : family === THEME_FONT_FAMILIES.jetbrainsMono ? "ui-monospace, monospace" : "system-ui, sans-serif";
83
+ return { fontFamily: `"${family}", ${fallback}` };
84
+ }
85
+
1
86
  // src/cn.ts
2
87
  import { clsx } from "clsx";
3
88
  import { twMerge } from "tailwind-merge";
4
89
  function cn(...inputs) {
5
90
  return twMerge(clsx(inputs));
6
91
  }
92
+
93
+ // src/scale.ts
94
+ var SCALE_VARIABLE_NAMES = [
95
+ "--spacing",
96
+ "--text-base",
97
+ "--spacing-ctl",
98
+ "--spacing-row",
99
+ "--spacing-tile",
100
+ "--radius",
101
+ "--text-amt",
102
+ "--text-xs",
103
+ "--text-2xs"
104
+ ];
105
+ var SCALE_STEPS = {
106
+ compact: [3.5, 13, 40, 36, 56, 6, 34, 12, 11],
107
+ regular: [4, 14, 44, 44, 64, 8, 40, 12, 11],
108
+ spacious: [5, 16, 52, 52, 80, 10, 48, 14, 13]
109
+ };
110
+ var POINTER_FLOORS = { coarse: 44, fine: 24 };
111
+ var AUTO_COMPACT_UNDER = 640;
112
+ var AUTO_SPACIOUS_FROM = 1600;
113
+ var MAX_FONT_SCALE = 1.3;
114
+ function resolveStep(override, extent) {
115
+ if (override === "compact" || override === "regular" || override === "spacious") return override;
116
+ if (extent < AUTO_COMPACT_UNDER) return "compact";
117
+ if (extent >= AUTO_SPACIOUS_FROM) return "spacious";
118
+ return "regular";
119
+ }
120
+ function scaleVariables(step, pointer) {
121
+ const [spacing, textBase, ctl, row, tile, radius, amt, xs, xxs] = SCALE_STEPS[step];
122
+ const floor = POINTER_FLOORS[pointer];
123
+ return {
124
+ "--spacing": spacing,
125
+ "--text-base": textBase,
126
+ "--spacing-ctl": Math.max(ctl, floor),
127
+ "--spacing-row": Math.max(row, floor),
128
+ "--spacing-tile": tile,
129
+ "--radius": radius,
130
+ "--text-amt": amt,
131
+ "--text-xs": xs,
132
+ "--text-2xs": xxs
133
+ };
134
+ }
7
135
  export {
8
- cn
136
+ AUTO_COMPACT_UNDER,
137
+ AUTO_SPACIOUS_FROM,
138
+ FONT_FACES,
139
+ FONT_SETTINGS,
140
+ MAX_FONT_SCALE,
141
+ POINTER_FLOORS,
142
+ SCALE_STEPS,
143
+ SCALE_VARIABLE_NAMES,
144
+ SYSTEM_TYPE,
145
+ THEME_FONT_FAMILIES,
146
+ TYPE_SETS,
147
+ TYPE_SETTING_AUTO,
148
+ TYPE_SET_IDS,
149
+ cn,
150
+ familiesForType,
151
+ fontFamilyStyle,
152
+ resolveStep,
153
+ resolveTypeSet,
154
+ scaleVariables
9
155
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyui/theme",
3
- "version": "3.12.0",
3
+ "version": "3.13.0",
4
4
  "type": "module",
5
5
  "description": "Shared design tokens and utilities for Tally UI",
6
6
  "main": "./dist/index.js",
@@ -13,7 +13,8 @@
13
13
  "source": "./src/index.ts",
14
14
  "default": "./dist/index.js"
15
15
  },
16
- "./tokens.css": "./src/tokens.css"
16
+ "./tokens.css": "./src/tokens.css",
17
+ "./scale.css": "./src/scale.css"
17
18
  },
18
19
  "files": [
19
20
  "dist",
package/src/fonts.ts ADDED
@@ -0,0 +1,99 @@
1
+ // Port of WCPOS v2 packages/components/src/lib/fonts.ts and the type sets in lib/themes.ts.
2
+ export const THEME_FONT_FAMILIES = {
3
+ dmSans: 'DM Sans',
4
+ instrumentSerif: 'Instrument Serif',
5
+ jetbrainsMono: 'JetBrains Mono',
6
+ spaceGrotesk: 'Space Grotesk',
7
+ fraunces: 'Fraunces',
8
+ manrope: 'Manrope',
9
+ } as const;
10
+ export type ThemeFontFamily = (typeof THEME_FONT_FAMILIES)[keyof typeof THEME_FONT_FAMILIES];
11
+
12
+ export interface ThemeFontFace { file: string; weight: number; style?: 'italic' }
13
+
14
+ /**
15
+ * Faces an app must bundle (Google Fonts, SIL OFL 1.1), with v2's file names.
16
+ * Map each to an app asset, e.g. expo-font:
17
+ * { path: require('./assets/fonts/DMSans-400.ttf'), weight: 400, style, display: 'swap' }.
18
+ */
19
+ export const FONT_FACES: Record<ThemeFontFamily, readonly ThemeFontFace[]> = {
20
+ [THEME_FONT_FAMILIES.dmSans]: [
21
+ { file: 'DMSans-400.ttf', weight: 400 },
22
+ { file: 'DMSans-500.ttf', weight: 500 },
23
+ { file: 'DMSans-600.ttf', weight: 600 },
24
+ { file: 'DMSans-700.ttf', weight: 700 },
25
+ ],
26
+ [THEME_FONT_FAMILIES.instrumentSerif]: [
27
+ { file: 'InstrumentSerif-400.ttf', weight: 400 },
28
+ { file: 'InstrumentSerif-400Italic.ttf', weight: 400, style: 'italic' },
29
+ ],
30
+ [THEME_FONT_FAMILIES.jetbrainsMono]: [
31
+ { file: 'JetBrainsMono-400.ttf', weight: 400 },
32
+ { file: 'JetBrainsMono-500.ttf', weight: 500 },
33
+ { file: 'JetBrainsMono-600.ttf', weight: 600 },
34
+ ],
35
+ [THEME_FONT_FAMILIES.spaceGrotesk]: [
36
+ { file: 'SpaceGrotesk-500.ttf', weight: 500 },
37
+ { file: 'SpaceGrotesk-600.ttf', weight: 600 },
38
+ { file: 'SpaceGrotesk-700.ttf', weight: 700 },
39
+ ],
40
+ [THEME_FONT_FAMILIES.fraunces]: [
41
+ { file: 'Fraunces-500.ttf', weight: 500 },
42
+ { file: 'Fraunces-600.ttf', weight: 600 },
43
+ { file: 'Fraunces-500Italic.ttf', weight: 500, style: 'italic' },
44
+ { file: 'Fraunces-600Italic.ttf', weight: 600, style: 'italic' },
45
+ ],
46
+ [THEME_FONT_FAMILIES.manrope]: [
47
+ { file: 'Manrope-500.ttf', weight: 500 },
48
+ { file: 'Manrope-600.ttf', weight: 600 },
49
+ { file: 'Manrope-700.ttf', weight: 700 },
50
+ { file: 'Manrope-800.ttf', weight: 800 },
51
+ ],
52
+ };
53
+
54
+ export type ThemeType = { body?: ThemeFontFamily; num?: ThemeFontFamily; display?: ThemeFontFamily; displayItalic?: boolean };
55
+ export const SYSTEM_TYPE: ThemeType = {};
56
+ export const TYPE_SETS = {
57
+ system: SYSTEM_TYPE,
58
+ instrument: {
59
+ body: THEME_FONT_FAMILIES.dmSans, num: THEME_FONT_FAMILIES.jetbrainsMono,
60
+ display: THEME_FONT_FAMILIES.instrumentSerif, displayItalic: true,
61
+ },
62
+ grotesk: {
63
+ body: THEME_FONT_FAMILIES.spaceGrotesk, num: THEME_FONT_FAMILIES.spaceGrotesk,
64
+ display: THEME_FONT_FAMILIES.spaceGrotesk,
65
+ },
66
+ fraunces: {
67
+ body: THEME_FONT_FAMILIES.dmSans, num: THEME_FONT_FAMILIES.dmSans,
68
+ display: THEME_FONT_FAMILIES.fraunces, displayItalic: true,
69
+ },
70
+ manrope: {
71
+ body: THEME_FONT_FAMILIES.manrope, num: THEME_FONT_FAMILIES.manrope,
72
+ display: THEME_FONT_FAMILIES.manrope,
73
+ },
74
+ } as const satisfies Record<string, ThemeType>;
75
+ export type TypeSetId = keyof typeof TYPE_SETS;
76
+ export const TYPE_SET_IDS = Object.keys(TYPE_SETS) as TypeSetId[];
77
+ export const TYPE_SETTING_AUTO = 'auto';
78
+ /** The `ui.font` choices in Settings order. */
79
+ export const FONT_SETTINGS: readonly ('auto' | TypeSetId)[] = [TYPE_SETTING_AUTO, ...TYPE_SET_IDS] as const;
80
+
81
+ export function familiesForType({ body, num, display }: ThemeType): ThemeFontFamily[] {
82
+ return [...new Set([body, num, display].filter((family) => family !== undefined))];
83
+ }
84
+
85
+ /** An explicit set wins; auto, absent and unknown values resolve to `auto`. */
86
+ export function resolveTypeSet(value: unknown, auto: TypeSetId = 'system'): TypeSetId {
87
+ return TYPE_SET_IDS.find((id) => id === value) ?? auto;
88
+ }
89
+
90
+ export function fontFamilyStyle(family: ThemeFontFamily | undefined, isWeb: boolean): { fontFamily: string } | undefined {
91
+ if (!family) return undefined;
92
+ if (!isWeb) return { fontFamily: family };
93
+ const fallback = family === THEME_FONT_FAMILIES.instrumentSerif || family === THEME_FONT_FAMILIES.fraunces
94
+ ? 'ui-serif, serif'
95
+ : family === THEME_FONT_FAMILIES.jetbrainsMono
96
+ ? 'ui-monospace, monospace'
97
+ : 'system-ui, sans-serif';
98
+ return { fontFamily: `"${family}", ${fallback}` };
99
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,12 @@
1
+ export {
2
+ THEME_FONT_FAMILIES, FONT_FACES, SYSTEM_TYPE, TYPE_SETS, TYPE_SET_IDS,
3
+ TYPE_SETTING_AUTO, FONT_SETTINGS, familiesForType, resolveTypeSet, fontFamilyStyle,
4
+ type ThemeFontFamily, type ThemeFontFace, type ThemeType, type TypeSetId,
5
+ } from './fonts';
1
6
  export { cn } from './cn';
2
7
  export type { ClassValue } from 'clsx';
8
+ export {
9
+ SCALE_VARIABLE_NAMES, SCALE_STEPS, POINTER_FLOORS,
10
+ AUTO_COMPACT_UNDER, AUTO_SPACIOUS_FROM, MAX_FONT_SCALE, resolveStep, scaleVariables,
11
+ } from './scale';
12
+ export type { ScaleStep, ScaleOverride, Pointer, ScaleVariables } from './scale';
package/src/scale.css ADDED
@@ -0,0 +1,38 @@
1
+ /* Opt-in UI scale tokens. Import after tokens.css for the Regular column and
2
+ * derived ramp. ScaleProvider overrides the nine values per step.
3
+ * Port of WCPOS v2 `apps/main/global.css`.
4
+ */
5
+ @theme {
6
+ --spacing: 4px;
7
+ --text-base: 14px;
8
+ --spacing-ctl: 44px;
9
+ --spacing-row: 44px;
10
+ --spacing-tile: 64px;
11
+ --radius: 8px;
12
+ --text-amt: 40px;
13
+ --text-xs: 12px;
14
+ --text-2xs: 11px;
15
+ }
16
+
17
+ /* Resolve derived values where utilities are used, so a step scoped below the root moves them too. */
18
+ @theme inline {
19
+ --text-2xs--line-height: calc(var(--text-2xs) * 1.35);
20
+ --text-xs--line-height: calc(var(--text-xs) * 1.35);
21
+ --text-sm: calc(var(--text-base) * 0.929);
22
+ --text-sm--line-height: calc(var(--text-base) * 0.929 * 1.35);
23
+ --text-base--line-height: calc(var(--text-base) * 1.35);
24
+ --text-lg: calc(var(--text-base) * 1.143);
25
+ --text-lg--line-height: calc(var(--text-base) * 1.143 * 1.35);
26
+ --text-xl: calc(var(--text-base) * 1.286);
27
+ --text-xl--line-height: calc(var(--text-base) * 1.286 * 1.35);
28
+ --text-2xl: calc(var(--text-base) * 1.5);
29
+ --text-2xl--line-height: calc(var(--text-base) * 1.5 * 1.35);
30
+ --text-3xl: calc(var(--text-base) * 1.857);
31
+ --text-3xl--line-height: calc(var(--text-base) * 1.857 * 1.35);
32
+ --text-amt--line-height: calc(var(--text-amt) * 1.1);
33
+ --radius-sm: calc(var(--radius) - 4px);
34
+ --radius-md: calc(var(--radius) - 2px);
35
+ --radius-lg: var(--radius);
36
+ --radius-xl: calc(var(--radius) + 4px);
37
+ --radius-2xl: calc(var(--radius) + 8px);
38
+ }
package/src/scale.ts ADDED
@@ -0,0 +1,57 @@
1
+ /** Port of WCPOS v2 `packages/components/src/lib/scale.ts`. */
2
+ export type ScaleStep = 'compact' | 'regular' | 'spacious';
3
+ export type ScaleOverride = 'auto' | ScaleStep;
4
+ export type Pointer = 'coarse' | 'fine';
5
+ export type ScaleVariables = {
6
+ '--spacing': number;
7
+ '--text-base': number;
8
+ '--spacing-ctl': number;
9
+ '--spacing-row': number;
10
+ '--spacing-tile': number;
11
+ '--radius': number;
12
+ '--text-amt': number;
13
+ '--text-xs': number;
14
+ '--text-2xs': number;
15
+ };
16
+
17
+ /** The nine names in declaration order (the order of each SCALE_STEPS row). */
18
+ export const SCALE_VARIABLE_NAMES = [
19
+ '--spacing', '--text-base', '--spacing-ctl', '--spacing-row', '--spacing-tile',
20
+ '--radius', '--text-amt', '--text-xs', '--text-2xs',
21
+ ] as const satisfies readonly (keyof ScaleVariables)[];
22
+
23
+ export const SCALE_STEPS = {
24
+ compact: [3.5, 13, 40, 36, 56, 6, 34, 12, 11],
25
+ regular: [4, 14, 44, 44, 64, 8, 40, 12, 11],
26
+ spacious: [5, 16, 52, 52, 80, 10, 48, 14, 13],
27
+ } as const satisfies Record<ScaleStep, readonly number[]>;
28
+
29
+ export const POINTER_FLOORS = { coarse: 44, fine: 24 } as const satisfies Record<Pointer, number>;
30
+ export const AUTO_COMPACT_UNDER = 640;
31
+ export const AUTO_SPACIOUS_FROM = 1600;
32
+ export const MAX_FONT_SCALE = 1.3;
33
+
34
+ /** Explicit steps win; Auto and unknown stored values follow the window extent. */
35
+ export function resolveStep(override: string | undefined | null, extent: number): ScaleStep {
36
+ if (override === 'compact' || override === 'regular' || override === 'spacious') return override;
37
+ if (extent < AUTO_COMPACT_UNDER) return 'compact';
38
+ if (extent >= AUTO_SPACIOUS_FROM) return 'spacious';
39
+ return 'regular';
40
+ }
41
+
42
+ /** Apply pointer target floors to controls and rows, leaving the other tokens unchanged. */
43
+ export function scaleVariables(step: ScaleStep, pointer: Pointer): ScaleVariables {
44
+ const [spacing, textBase, ctl, row, tile, radius, amt, xs, xxs] = SCALE_STEPS[step];
45
+ const floor = POINTER_FLOORS[pointer];
46
+ return {
47
+ '--spacing': spacing,
48
+ '--text-base': textBase,
49
+ '--spacing-ctl': Math.max(ctl, floor),
50
+ '--spacing-row': Math.max(row, floor),
51
+ '--spacing-tile': tile,
52
+ '--radius': radius,
53
+ '--text-amt': amt,
54
+ '--text-xs': xs,
55
+ '--text-2xs': xxs,
56
+ };
57
+ }
package/src/tokens.css CHANGED
@@ -59,115 +59,113 @@
59
59
  }
60
60
 
61
61
  @layer theme {
62
- :root {
63
- @variant light {
64
- /* Base */
65
- --color-background: #f8f9fa;
66
- --color-foreground: #111827;
67
-
68
- /* Card */
69
- --color-card: #ffffff;
70
- --color-card-foreground: #111827;
71
-
72
- /* Popover */
73
- --color-popover: #ffffff;
74
- --color-popover-foreground: #111827;
75
-
76
- /* Primary */
77
- --color-primary: #5b5ef0;
78
- --color-primary-foreground: #ffffff;
79
-
80
- /* Secondary */
81
- --color-secondary: #f3f4f6;
82
- --color-secondary-foreground: #111827;
83
-
84
- /* Muted */
85
- --color-muted: #f3f4f6;
86
- --color-muted-foreground: #656c79;
87
-
88
- /* Accent */
89
- --color-accent: #f3f4f6;
90
- --color-accent-foreground: #111827;
91
-
92
- /* Destructive */
93
- --color-destructive: #dc2626;
94
- --color-destructive-foreground: #ffffff;
95
-
96
- /* Success */
97
- --color-success: #047857;
98
- --color-success-foreground: #ffffff;
99
-
100
- /* Warning */
101
- --color-warning: #b45309;
102
- --color-warning-foreground: #ffffff;
103
-
104
- /* Info */
105
- --color-info: #2563eb;
106
- --color-info-foreground: #ffffff;
107
-
108
- /* Border / Input / Ring */
109
- --color-border: #e5e7eb;
110
- --color-input: #848a94;
111
- --color-ring: #5b5ef0;
112
-
113
- /* Commerce */
114
- --color-price: #047857;
115
- --color-sale: #dc2626;
116
- }
117
-
118
- @variant dark {
119
- /* Base */
120
- --color-background: #0d1117;
121
- --color-foreground: #c9d1d9;
122
-
123
- /* Card */
124
- --color-card: #161b22;
125
- --color-card-foreground: #c9d1d9;
126
-
127
- /* Popover */
128
- --color-popover: #1c2128;
129
- --color-popover-foreground: #c9d1d9;
130
-
131
- /* Primary */
132
- --color-primary: #818cf8;
133
- --color-primary-foreground: #1e1b4b;
134
-
135
- /* Secondary */
136
- --color-secondary: #1c2128;
137
- --color-secondary-foreground: #c9d1d9;
138
-
139
- /* Muted */
140
- --color-muted: #1c2128;
141
- --color-muted-foreground: #8b949e;
142
-
143
- /* Accent */
144
- --color-accent: #1c2128;
145
- --color-accent-foreground: #c9d1d9;
146
-
147
- /* Destructive */
148
- --color-destructive: #f85149;
149
- --color-destructive-foreground: #0d1117;
150
-
151
- /* Success */
152
- --color-success: #3fb950;
153
- --color-success-foreground: #0d1117;
154
-
155
- /* Warning */
156
- --color-warning: #d29922;
157
- --color-warning-foreground: #0d1117;
158
-
159
- /* Info */
160
- --color-info: #58a6ff;
161
- --color-info-foreground: #0d1117;
162
-
163
- /* Border / Input / Ring */
164
- --color-border: #3d444d;
165
- --color-input: #636c76;
166
- --color-ring: #818cf8;
167
-
168
- /* Commerce */
169
- --color-price: #3fb950;
170
- --color-sale: #f85149;
171
- }
62
+ @variant light {
63
+ /* Base */
64
+ --color-background: #f8f9fa;
65
+ --color-foreground: #111827;
66
+
67
+ /* Card */
68
+ --color-card: #ffffff;
69
+ --color-card-foreground: #111827;
70
+
71
+ /* Popover */
72
+ --color-popover: #ffffff;
73
+ --color-popover-foreground: #111827;
74
+
75
+ /* Primary */
76
+ --color-primary: #5b5ef0;
77
+ --color-primary-foreground: #ffffff;
78
+
79
+ /* Secondary */
80
+ --color-secondary: #f3f4f6;
81
+ --color-secondary-foreground: #111827;
82
+
83
+ /* Muted */
84
+ --color-muted: #f3f4f6;
85
+ --color-muted-foreground: #656c79;
86
+
87
+ /* Accent */
88
+ --color-accent: #f3f4f6;
89
+ --color-accent-foreground: #111827;
90
+
91
+ /* Destructive */
92
+ --color-destructive: #dc2626;
93
+ --color-destructive-foreground: #ffffff;
94
+
95
+ /* Success */
96
+ --color-success: #047857;
97
+ --color-success-foreground: #ffffff;
98
+
99
+ /* Warning */
100
+ --color-warning: #b45309;
101
+ --color-warning-foreground: #ffffff;
102
+
103
+ /* Info */
104
+ --color-info: #2563eb;
105
+ --color-info-foreground: #ffffff;
106
+
107
+ /* Border / Input / Ring */
108
+ --color-border: #e5e7eb;
109
+ --color-input: #848a94;
110
+ --color-ring: #5b5ef0;
111
+
112
+ /* Commerce */
113
+ --color-price: #047857;
114
+ --color-sale: #dc2626;
115
+ }
116
+
117
+ @variant dark {
118
+ /* Base */
119
+ --color-background: #0d1117;
120
+ --color-foreground: #c9d1d9;
121
+
122
+ /* Card */
123
+ --color-card: #161b22;
124
+ --color-card-foreground: #c9d1d9;
125
+
126
+ /* Popover */
127
+ --color-popover: #1c2128;
128
+ --color-popover-foreground: #c9d1d9;
129
+
130
+ /* Primary */
131
+ --color-primary: #818cf8;
132
+ --color-primary-foreground: #1e1b4b;
133
+
134
+ /* Secondary */
135
+ --color-secondary: #1c2128;
136
+ --color-secondary-foreground: #c9d1d9;
137
+
138
+ /* Muted */
139
+ --color-muted: #1c2128;
140
+ --color-muted-foreground: #8b949e;
141
+
142
+ /* Accent */
143
+ --color-accent: #1c2128;
144
+ --color-accent-foreground: #c9d1d9;
145
+
146
+ /* Destructive */
147
+ --color-destructive: #f85149;
148
+ --color-destructive-foreground: #0d1117;
149
+
150
+ /* Success */
151
+ --color-success: #3fb950;
152
+ --color-success-foreground: #0d1117;
153
+
154
+ /* Warning */
155
+ --color-warning: #d29922;
156
+ --color-warning-foreground: #0d1117;
157
+
158
+ /* Info */
159
+ --color-info: #58a6ff;
160
+ --color-info-foreground: #0d1117;
161
+
162
+ /* Border / Input / Ring */
163
+ --color-border: #3d444d;
164
+ --color-input: #636c76;
165
+ --color-ring: #818cf8;
166
+
167
+ /* Commerce */
168
+ --color-price: #3fb950;
169
+ --color-sale: #f85149;
172
170
  }
173
171
  }