@prismora/tokens 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aravind Kumar and Prismora contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,15 @@
1
- # Temporary Holding Version
1
+ # @prismora/tokens
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Prismora design tokens: spacing, radius, type scale, font pairings, elevation, z-index and breakpoints.
4
+
5
+ ```sh
6
+ npm install @prismora/tokens
7
+ ```
8
+
9
+ ```ts
10
+ import { space, breakpoints, FONT_PAIRINGS } from '@prismora/tokens';
11
+ ```
12
+
13
+ Most apps use the tokens as CSS custom properties (`var(--pm-space-4)`) from `@prismora/css`.
14
+
15
+ Documentation: [prismora.design/docs/tokens](https://prismora.design/docs/tokens) · Part of [Prismora](https://github.com/axxra/prismora), one seed, every theme. MIT licence.
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Tier-1 primitive tokens that do not depend on colour (space, radius, type, elevation, z, motion).
3
+ * Colour primitives & semantics are generated per theme by @prismora/theme + @prismora/color.
4
+ */
5
+ export type TokenGroup = Record<string, string>;
6
+ /** 4px base grid. */
7
+ export declare const space: TokenGroup;
8
+ /** Radius scale is multiplied by `--pm-radius-factor` (set by data-radius / theme). */
9
+ export declare const radiusBase: Record<string, number>;
10
+ export declare const RADIUS_PRESETS: {
11
+ readonly none: 0;
12
+ readonly sharp: 0.5;
13
+ readonly rounded: 1;
14
+ readonly soft: 1.5;
15
+ readonly pill: 1;
16
+ };
17
+ export type RadiusPreset = keyof typeof RADIUS_PRESETS;
18
+ export declare const DENSITY_PRESETS: {
19
+ readonly compact: 0.85;
20
+ readonly comfortable: 1;
21
+ readonly spacious: 1.18;
22
+ };
23
+ export type Density = keyof typeof DENSITY_PRESETS;
24
+ /** Fluid type scale: min at 360px viewport, max at 1280px. */
25
+ export declare function typeScale(ratio?: number, base?: number): TokenGroup;
26
+ export declare const fontWeight: TokenGroup;
27
+ export declare const lineHeight: TokenGroup;
28
+ /** System fallbacks: used as-is by the zero-download `system` pairing and appended to every web font. */
29
+ export declare const SYSTEM_STACKS: {
30
+ readonly sans: "ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif";
31
+ readonly serif: "ui-serif, 'Iowan Old Style', 'Palatino Linotype', Georgia, Cambria, 'Times New Roman', serif";
32
+ readonly mono: "ui-monospace, 'SFMono-Regular', 'Cascadia Code', Menlo, Consolas, 'Liberation Mono', monospace";
33
+ readonly rounded: "ui-rounded, 'SF Pro Rounded', 'Hiragino Maru Gothic ProN', 'Arial Rounded MT Bold', system-ui, sans-serif";
34
+ };
35
+ export declare const fontFamily: TokenGroup;
36
+ /** Letter spacing. */
37
+ export declare const tracking: TokenGroup;
38
+ /** Comfortable line lengths for running text. */
39
+ export declare const measure: TokenGroup;
40
+ export type FontRole = 'sans' | 'display' | 'serif' | 'mono';
41
+ /** A font pairing: one web-font family (or system stack) per role. `body` is the family of long-form reading text
42
+ * (`.pm-prose`); UI controls always use the sans family. */
43
+ export interface FontPairing {
44
+ label: string;
45
+ description: string;
46
+ /** Family name per role (null = system stack for that role). */
47
+ families: Record<FontRole, string | null>;
48
+ /** Role used for body text (editorial pairings read in serif). Default 'sans'. */
49
+ body?: 'sans' | 'serif';
50
+ }
51
+ /**
52
+ * Curated pairings, selected with `data-font="<id>"` on any element (or the theme's `typography.font`).
53
+ * Fonts come from @prismora/fonts (self-hosted, OFL); until a font is loaded the system stack shows.
54
+ */
55
+ export declare const FONT_PAIRINGS: {
56
+ readonly system: {
57
+ readonly label: "System";
58
+ readonly description: "The device's own UI fonts. Nothing to download.";
59
+ readonly families: {
60
+ readonly sans: null;
61
+ readonly display: null;
62
+ readonly serif: null;
63
+ readonly mono: null;
64
+ };
65
+ };
66
+ readonly inter: {
67
+ readonly label: "Inter";
68
+ readonly description: "Neutral, highly legible UI sans (default).";
69
+ readonly families: {
70
+ readonly sans: "Inter Variable";
71
+ readonly display: "Inter Variable";
72
+ readonly serif: "Source Serif 4 Variable";
73
+ readonly mono: "JetBrains Mono Variable";
74
+ };
75
+ };
76
+ readonly figtree: {
77
+ readonly label: "Figtree";
78
+ readonly description: "Friendly geometric sans with clean numerals.";
79
+ readonly families: {
80
+ readonly sans: "Figtree Variable";
81
+ readonly display: "Figtree Variable";
82
+ readonly serif: "Lora Variable";
83
+ readonly mono: "JetBrains Mono Variable";
84
+ };
85
+ };
86
+ readonly jakarta: {
87
+ readonly label: "Plus Jakarta";
88
+ readonly description: "Modern product sans with a distinctive display.";
89
+ readonly families: {
90
+ readonly sans: "Plus Jakarta Sans Variable";
91
+ readonly display: "Plus Jakarta Sans Variable";
92
+ readonly serif: "Source Serif 4 Variable";
93
+ readonly mono: "Fira Code Variable";
94
+ };
95
+ };
96
+ readonly manrope: {
97
+ readonly label: "Manrope";
98
+ readonly description: "Semi-condensed, technical and compact.";
99
+ readonly families: {
100
+ readonly sans: "Manrope Variable";
101
+ readonly display: "Manrope Variable";
102
+ readonly serif: "Source Serif 4 Variable";
103
+ readonly mono: "JetBrains Mono Variable";
104
+ };
105
+ };
106
+ readonly grotesk: {
107
+ readonly label: "Grotesk";
108
+ readonly description: "Space Grotesk headings over DM Sans text.";
109
+ readonly families: {
110
+ readonly sans: "DM Sans Variable";
111
+ readonly display: "Space Grotesk Variable";
112
+ readonly serif: "Lora Variable";
113
+ readonly mono: "Fira Code Variable";
114
+ };
115
+ };
116
+ readonly friendly: {
117
+ readonly label: "Friendly";
118
+ readonly description: "Rounded Nunito for consumer and education apps.";
119
+ readonly families: {
120
+ readonly sans: "Nunito Variable";
121
+ readonly display: "Nunito Variable";
122
+ readonly serif: "Lora Variable";
123
+ readonly mono: "Fira Code Variable";
124
+ };
125
+ };
126
+ readonly editorial: {
127
+ readonly label: "Editorial";
128
+ readonly description: "Serif reading text with Fraunces headings and Inter UI.";
129
+ readonly body: "serif";
130
+ readonly families: {
131
+ readonly sans: "Inter Variable";
132
+ readonly display: "Fraunces Variable";
133
+ readonly serif: "Source Serif 4 Variable";
134
+ readonly mono: "JetBrains Mono Variable";
135
+ };
136
+ };
137
+ };
138
+ export type FontPairingId = keyof typeof FONT_PAIRINGS;
139
+ /** CSS font-family value for a role of a pairing (web font first, then the system stack). */
140
+ export declare function fontStack(family: string | null, role: FontRole): string;
141
+ /** Declarations that apply a pairing: --pm-font-sans/display/serif/mono and --pm-font-body. */
142
+ export declare function pairingDeclarations(id: FontPairingId): string[];
143
+ /** Layered shadows; colour comes from --pm-shadow-color (theme-aware). */
144
+ export declare const elevation: TokenGroup;
145
+ export declare const zIndex: TokenGroup;
146
+ export declare const breakpoints: TokenGroup;
147
+ export declare const controlHeight: Record<string, number>;
148
+ export declare const blur: TokenGroup;
149
+ /** Emit primitive (non-colour) tokens as CSS declarations (without selector). */
150
+ export declare function primitiveDeclarations(opts?: {
151
+ typeRatio?: number;
152
+ fontSans?: string;
153
+ fontDisplay?: string;
154
+ fontMono?: string;
155
+ fontSerif?: string;
156
+ fontBody?: 'sans' | 'serif';
157
+ }): string[];
package/dist/index.js ADDED
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Tier-1 primitive tokens that do not depend on colour (space, radius, type, elevation, z, motion).
3
+ * Colour primitives & semantics are generated per theme by @prismora/theme + @prismora/color.
4
+ */
5
+ /** 4px base grid. */
6
+ export const space = {
7
+ '0': '0',
8
+ px: '1px',
9
+ '0-5': '0.125rem',
10
+ '1': '0.25rem',
11
+ '1-5': '0.375rem',
12
+ '2': '0.5rem',
13
+ '3': '0.75rem',
14
+ '4': '1rem',
15
+ '5': '1.25rem',
16
+ '6': '1.5rem',
17
+ '8': '2rem',
18
+ '10': '2.5rem',
19
+ '12': '3rem',
20
+ '16': '4rem',
21
+ '20': '5rem',
22
+ '24': '6rem',
23
+ };
24
+ /** Radius scale is multiplied by `--pm-radius-factor` (set by data-radius / theme). */
25
+ export const radiusBase = { xs: 2, sm: 4, md: 8, lg: 12, xl: 16, '2xl': 24 };
26
+ export const RADIUS_PRESETS = { none: 0, sharp: 0.5, rounded: 1, soft: 1.5, pill: 1 };
27
+ export const DENSITY_PRESETS = { compact: 0.85, comfortable: 1, spacious: 1.18 };
28
+ /** Fluid type scale: min at 360px viewport, max at 1280px. */
29
+ export function typeScale(ratio = 1.2, base = 1) {
30
+ const steps = { xs: -2, sm: -1, md: 0, lg: 1, xl: 2, '2xl': 3, '3xl': 4, '4xl': 5, '5xl': 6 };
31
+ const out = {};
32
+ for (const [name, step] of Object.entries(steps)) {
33
+ const max = base * ratio ** step;
34
+ // Small steps stay fixed; larger ones shrink up to ~15% on small screens.
35
+ const min = step <= 0 ? max : max * (1 - Math.min(0.06 * step, 0.3));
36
+ out[name] = fluid(min, max);
37
+ }
38
+ return out;
39
+ }
40
+ function fluid(minRem, maxRem, minVw = 22.5, maxVw = 80) {
41
+ const r = (v) => Math.round(v * 1000) / 1000;
42
+ if (Math.abs(maxRem - minRem) < 0.001)
43
+ return `${r(maxRem)}rem`;
44
+ const slope = (maxRem - minRem) / (maxVw - minVw);
45
+ const intercept = minRem - slope * minVw;
46
+ return `clamp(${r(minRem)}rem, ${r(intercept)}rem + ${r(slope * 100)}vw, ${r(maxRem)}rem)`;
47
+ }
48
+ export const fontWeight = {
49
+ regular: '400',
50
+ medium: '500',
51
+ semibold: '600',
52
+ bold: '700',
53
+ };
54
+ export const lineHeight = { tight: '1.15', snug: '1.3', normal: '1.5', relaxed: '1.65' };
55
+ /** System fallbacks: used as-is by the zero-download `system` pairing and appended to every web font. */
56
+ export const SYSTEM_STACKS = {
57
+ sans: "ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
58
+ serif: "ui-serif, 'Iowan Old Style', 'Palatino Linotype', Georgia, Cambria, 'Times New Roman', serif",
59
+ mono: "ui-monospace, 'SFMono-Regular', 'Cascadia Code', Menlo, Consolas, 'Liberation Mono', monospace",
60
+ rounded: "ui-rounded, 'SF Pro Rounded', 'Hiragino Maru Gothic ProN', 'Arial Rounded MT Bold', system-ui, sans-serif",
61
+ };
62
+ export const fontFamily = {
63
+ sans: `'Inter Variable', 'Inter', ${SYSTEM_STACKS.sans}`,
64
+ display: `'Inter Variable', 'Inter', ${SYSTEM_STACKS.sans}`,
65
+ serif: `'Source Serif 4 Variable', 'Source Serif 4', ${SYSTEM_STACKS.serif}`,
66
+ mono: `'JetBrains Mono Variable', 'JetBrains Mono', ${SYSTEM_STACKS.mono}`,
67
+ };
68
+ /** Letter spacing. */
69
+ export const tracking = { tighter: '-0.03em', tight: '-0.015em', normal: '0', wide: '0.025em', wider: '0.06em', widest: '0.12em' };
70
+ /** Comfortable line lengths for running text. */
71
+ export const measure = { narrow: '45ch', normal: '65ch', wide: '80ch' };
72
+ /**
73
+ * Curated pairings, selected with `data-font="<id>"` on any element (or the theme's `typography.font`).
74
+ * Fonts come from @prismora/fonts (self-hosted, OFL); until a font is loaded the system stack shows.
75
+ */
76
+ export const FONT_PAIRINGS = {
77
+ system: { label: 'System', description: 'The device\'s own UI fonts. Nothing to download.', families: { sans: null, display: null, serif: null, mono: null } },
78
+ inter: { label: 'Inter', description: 'Neutral, highly legible UI sans (default).', families: { sans: 'Inter Variable', display: 'Inter Variable', serif: 'Source Serif 4 Variable', mono: 'JetBrains Mono Variable' } },
79
+ figtree: { label: 'Figtree', description: 'Friendly geometric sans with clean numerals.', families: { sans: 'Figtree Variable', display: 'Figtree Variable', serif: 'Lora Variable', mono: 'JetBrains Mono Variable' } },
80
+ jakarta: { label: 'Plus Jakarta', description: 'Modern product sans with a distinctive display.', families: { sans: 'Plus Jakarta Sans Variable', display: 'Plus Jakarta Sans Variable', serif: 'Source Serif 4 Variable', mono: 'Fira Code Variable' } },
81
+ manrope: { label: 'Manrope', description: 'Semi-condensed, technical and compact.', families: { sans: 'Manrope Variable', display: 'Manrope Variable', serif: 'Source Serif 4 Variable', mono: 'JetBrains Mono Variable' } },
82
+ grotesk: { label: 'Grotesk', description: 'Space Grotesk headings over DM Sans text.', families: { sans: 'DM Sans Variable', display: 'Space Grotesk Variable', serif: 'Lora Variable', mono: 'Fira Code Variable' } },
83
+ friendly: { label: 'Friendly', description: 'Rounded Nunito for consumer and education apps.', families: { sans: 'Nunito Variable', display: 'Nunito Variable', serif: 'Lora Variable', mono: 'Fira Code Variable' } },
84
+ editorial: { label: 'Editorial', description: 'Serif reading text with Fraunces headings and Inter UI.', body: 'serif', families: { sans: 'Inter Variable', display: 'Fraunces Variable', serif: 'Source Serif 4 Variable', mono: 'JetBrains Mono Variable' } },
85
+ };
86
+ /** CSS font-family value for a role of a pairing (web font first, then the system stack). */
87
+ export function fontStack(family, role) {
88
+ const sys = role === 'serif' ? SYSTEM_STACKS.serif : role === 'mono' ? SYSTEM_STACKS.mono : SYSTEM_STACKS.sans;
89
+ return family ? `'${family}', ${sys}` : sys;
90
+ }
91
+ /** Declarations that apply a pairing: --pm-font-sans/display/serif/mono and --pm-font-body. */
92
+ export function pairingDeclarations(id) {
93
+ const p = FONT_PAIRINGS[id];
94
+ const roles = ['sans', 'display', 'serif', 'mono'];
95
+ const d = roles.map((r) => `--pm-font-${r}: ${fontStack(p.families[r], r)};`);
96
+ d.push(`--pm-font-body: var(--pm-font-${p.body ?? 'sans'});`);
97
+ return d;
98
+ }
99
+ /** Layered shadows; colour comes from --pm-shadow-color (theme-aware). */
100
+ export const elevation = {
101
+ '0': 'none',
102
+ '1': '0 1px 2px var(--pm-shadow-color-soft), 0 1px 1px var(--pm-shadow-color-soft)',
103
+ '2': '0 1px 2px var(--pm-shadow-color-soft), 0 4px 8px -2px var(--pm-shadow-color-soft), 0 2px 4px var(--pm-shadow-color-soft)',
104
+ '3': '0 2px 4px var(--pm-shadow-color-soft), 0 8px 16px -4px var(--pm-shadow-color), 0 4px 8px var(--pm-shadow-color-soft)',
105
+ '4': '0 4px 8px var(--pm-shadow-color-soft), 0 16px 32px -8px var(--pm-shadow-color), 0 8px 16px var(--pm-shadow-color-soft)',
106
+ '5': '0 8px 16px var(--pm-shadow-color-soft), 0 32px 64px -12px var(--pm-shadow-color-strong), 0 16px 32px var(--pm-shadow-color-soft)',
107
+ };
108
+ export const zIndex = {
109
+ base: '0',
110
+ raised: '1',
111
+ sticky: '100',
112
+ overlay: '1000',
113
+ toast: '1100',
114
+ };
115
+ export const breakpoints = { sm: '40rem', md: '48rem', lg: '64rem', xl: '80rem', '2xl': '96rem' };
116
+ export const controlHeight = { xs: 1.5, sm: 2, md: 2.5, lg: 3, xl: 3.5 };
117
+ export const blur = { sm: '6px', md: '12px', lg: '20px', xl: '32px' };
118
+ /** Emit primitive (non-colour) tokens as CSS declarations (without selector). */
119
+ export function primitiveDeclarations(opts = {}) {
120
+ const d = [];
121
+ for (const [k, v] of Object.entries(space))
122
+ d.push(`--pm-space-${k}: ${v};`);
123
+ for (const [k, v] of Object.entries(radiusBase))
124
+ d.push(`--pm-radius-${k}: calc(${v}px * var(--pm-radius-factor, 1));`);
125
+ d.push('--pm-radius-full: 9999px;');
126
+ for (const [k, v] of Object.entries(typeScale(opts.typeRatio)))
127
+ d.push(`--pm-font-size-${k}: ${v};`);
128
+ for (const [k, v] of Object.entries(fontWeight))
129
+ d.push(`--pm-font-weight-${k}: ${v};`);
130
+ for (const [k, v] of Object.entries(lineHeight))
131
+ d.push(`--pm-line-height-${k}: ${v};`);
132
+ d.push(`--pm-font-sans: ${opts.fontSans ?? fontFamily.sans};`);
133
+ d.push(`--pm-font-display: ${opts.fontDisplay ?? fontFamily.display};`);
134
+ d.push(`--pm-font-mono: ${opts.fontMono ?? fontFamily.mono};`);
135
+ d.push(`--pm-font-serif: ${opts.fontSerif ?? fontFamily.serif};`);
136
+ d.push(`--pm-font-body: var(--pm-font-${opts.fontBody ?? 'sans'});`);
137
+ for (const [k, v] of Object.entries(tracking))
138
+ d.push(`--pm-tracking-${k}: ${v};`);
139
+ for (const [k, v] of Object.entries(measure))
140
+ d.push(`--pm-measure-${k}: ${v};`);
141
+ for (const [k, v] of Object.entries(elevation))
142
+ d.push(`--pm-elevation-${k}: ${v};`);
143
+ for (const [k, v] of Object.entries(zIndex))
144
+ d.push(`--pm-z-${k}: ${v};`);
145
+ for (const [k, v] of Object.entries(blur))
146
+ d.push(`--pm-blur-${k}: ${v};`);
147
+ // On touch screens (pointer: coarse) base.css sets --pm-touch-min / --pm-touch-min-sm so controls meet native
148
+ // 44 px (md+) / 36 px (xs, sm) hit targets; set them to 0px to opt out.
149
+ for (const [k, v] of Object.entries(controlHeight))
150
+ d.push(`--pm-control-height-${k}: max(calc(${v}rem * var(--pm-density, 1)), var(${v < 2.5 ? '--pm-touch-min-sm' : '--pm-touch-min'}, 0px));`);
151
+ return d;
152
+ }
package/package.json CHANGED
@@ -1,6 +1,37 @@
1
1
  {
2
2
  "name": "@prismora/tokens",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Primitive design tokens (space, radius, type, elevation, z, blur).",
5
+ "keywords": [
6
+ "prismora",
7
+ "design-system",
8
+ "design-tokens"
9
+ ],
10
+ "homepage": "https://prismora.design",
11
+ "bugs": {
12
+ "url": "https://github.com/axxra/prismora/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/axxra/prismora.git",
17
+ "directory": "packages/tokens"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Aravind Kumar",
21
+ "type": "module",
22
+ "main": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "sideEffects": false,
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }