@velora-cms/design-tokens 0.9.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 +202 -0
- package/README.md +26 -0
- package/dist/generate.d.ts +1 -0
- package/dist/generate.js +34 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/tailwind-theme.d.ts +28 -0
- package/dist/tailwind-theme.js +49 -0
- package/dist/theme-css.d.ts +12 -0
- package/dist/theme-css.js +42 -0
- package/dist/theme-types.d.ts +39 -0
- package/dist/theme-types.js +1 -0
- package/dist/themes/dark.d.ts +13 -0
- package/dist/themes/dark.js +42 -0
- package/dist/themes/index.d.ts +5 -0
- package/dist/themes/index.js +4 -0
- package/dist/themes/light.d.ts +9 -0
- package/dist/themes/light.js +13 -0
- package/dist/tokens.css +146 -0
- package/dist/tokens.d.ts +12 -0
- package/dist/tokens.js +181 -0
- package/dist/tokens.json +169 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.js +5 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @velora-cms/design-tokens
|
|
2
|
+
|
|
3
|
+
The single source of truth for Velora's design tokens — colors, spacing,
|
|
4
|
+
typography, and theme overrides. Generates the Tailwind config and CSS
|
|
5
|
+
variables that `@velora-cms/ui`, the admin UI, and third-party plugin UIs
|
|
6
|
+
all consume, so a theme change here propagates everywhere automatically.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @velora-cms/design-tokens
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { tokens, tailwindTheme, themes } from "@velora-cms/design-tokens";
|
|
18
|
+
|
|
19
|
+
console.log(tokens.color.primary[500]);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```css
|
|
23
|
+
@import "@velora-cms/design-tokens/tokens.css";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Part of [Velora](https://github.com/velora-cms/velora). Apache-2.0.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time generator: emits tokens.css (CSS custom properties on
|
|
3
|
+
* :root) and tokens.json (for theme plugin authors) next to the
|
|
4
|
+
* compiled output. Run via `node dist/generate.js` after tsc.
|
|
5
|
+
*/
|
|
6
|
+
import { writeFile } from 'node:fs/promises';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { tokens } from './tokens.js';
|
|
10
|
+
import { themes } from './themes/index.js';
|
|
11
|
+
import { flatten, themeOverridesToCss } from './theme-css.js';
|
|
12
|
+
// The typography group flattens without its section prefix so variables
|
|
13
|
+
// read --font-size-base, not --typography-font-size-base. Everything
|
|
14
|
+
// else keeps its section name (--color-primary-500, --spacing-4, ...).
|
|
15
|
+
const { typography, ...rest } = tokens;
|
|
16
|
+
const cssTree = { ...rest, ...typography };
|
|
17
|
+
const variables = {};
|
|
18
|
+
flatten(cssTree, [], variables);
|
|
19
|
+
// Each theme with overrides gets its own [data-theme="id"] block —
|
|
20
|
+
// the same mechanism a third-party theme plugin will use. Light has
|
|
21
|
+
// no overrides (it IS the :root default) so it emits no block; that's
|
|
22
|
+
// a property of Light's token set, not a special case in this loop.
|
|
23
|
+
const themeBlocks = themes
|
|
24
|
+
.map((theme) => themeOverridesToCss(theme.id, theme.contributions.themeTokens))
|
|
25
|
+
.filter(Boolean);
|
|
26
|
+
const css = [
|
|
27
|
+
'/* Generated by @velora-cms/design-tokens — do not edit by hand. */',
|
|
28
|
+
[':root {', ...Object.entries(variables).map(([name, value]) => ` ${name}: ${value};`), '}'].join('\n'),
|
|
29
|
+
...themeBlocks,
|
|
30
|
+
].join('\n\n') + '\n';
|
|
31
|
+
const outDir = dirname(fileURLToPath(import.meta.url));
|
|
32
|
+
await writeFile(join(outDir, 'tokens.css'), css, 'utf8');
|
|
33
|
+
await writeFile(join(outDir, 'tokens.json'), JSON.stringify(tokens, null, 2) + '\n', 'utf8');
|
|
34
|
+
console.log(`Generated tokens.css (${Object.keys(variables).length} variables) and tokens.json`);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { VeloraDesignTokens, ColorScale, ColorScaleStep, ScaleTokens, SpacingStep, } from './types.js';
|
|
2
|
+
export { tokens } from './tokens.js';
|
|
3
|
+
export { tailwindTheme } from './tailwind-theme.js';
|
|
4
|
+
export type { BuiltInTheme, ThemeTokenOverrides, ThemeColorOverrides, } from './theme-types.js';
|
|
5
|
+
export { themeOverridesToCss } from './theme-css.js';
|
|
6
|
+
export { themes, lightTheme, darkTheme } from './themes/index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const tailwindTheme: {
|
|
2
|
+
colors: {
|
|
3
|
+
transparent: string;
|
|
4
|
+
current: string;
|
|
5
|
+
inherit: string;
|
|
6
|
+
primary: Record<import("./types.js").ColorScaleStep, string>;
|
|
7
|
+
secondary: Record<import("./types.js").ColorScaleStep, string>;
|
|
8
|
+
success: Record<import("./types.js").ColorScaleStep, string>;
|
|
9
|
+
warning: Record<import("./types.js").ColorScaleStep, string>;
|
|
10
|
+
danger: Record<import("./types.js").ColorScaleStep, string>;
|
|
11
|
+
neutral: Record<import("./types.js").ColorScaleStep, string>;
|
|
12
|
+
background: Record<"base" | "elevated" | "overlay" | "hover", string>;
|
|
13
|
+
text: Record<"primary" | "secondary" | "disabled" | "inverse", string>;
|
|
14
|
+
border: Record<"default" | "subtle" | "strong", string>;
|
|
15
|
+
};
|
|
16
|
+
fontFamily: {
|
|
17
|
+
sans: string;
|
|
18
|
+
mono: string;
|
|
19
|
+
};
|
|
20
|
+
fontSize: Record<"xs" | "sm" | "base" | "lg" | "xl", string>;
|
|
21
|
+
fontWeight: Record<"normal" | "medium" | "semibold" | "bold", string>;
|
|
22
|
+
lineHeight: Record<"normal" | "tight" | "relaxed", string>;
|
|
23
|
+
spacing: Record<import("./types.js").SpacingStep, string>;
|
|
24
|
+
borderRadius: Record<"sm" | "lg" | "none" | "md" | "full", string>;
|
|
25
|
+
boxShadow: Record<"sm" | "lg" | "xl" | "md", string>;
|
|
26
|
+
transitionDuration: Record<string, string>;
|
|
27
|
+
transitionTimingFunction: Record<string, string>;
|
|
28
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind theme built from the token definitions — every value is a
|
|
3
|
+
* var(--...) reference into tokens.css, never a raw value. Utilities
|
|
4
|
+
* like bg-primary-500 therefore resolve through the CSS custom
|
|
5
|
+
* property at runtime, which is what lets theme plugins re-skin the
|
|
6
|
+
* admin (and every plugin UI rendered with host components) by
|
|
7
|
+
* overriding variables — no build-time theme baking.
|
|
8
|
+
*
|
|
9
|
+
* Variable names here must stay in sync with generate.ts's flattening
|
|
10
|
+
* (color/spacing/radius/shadow/motion keep their section prefix,
|
|
11
|
+
* typography flattens without one).
|
|
12
|
+
*/
|
|
13
|
+
import { tokens } from './tokens.js';
|
|
14
|
+
function scaleRefs(scale, prefix) {
|
|
15
|
+
const out = {};
|
|
16
|
+
for (const key of Object.keys(scale)) {
|
|
17
|
+
out[key] = `var(--${prefix}-${key})`;
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
export const tailwindTheme = {
|
|
22
|
+
colors: {
|
|
23
|
+
// CSS keywords, not theme values — the only non-var entries
|
|
24
|
+
transparent: 'transparent',
|
|
25
|
+
current: 'currentColor',
|
|
26
|
+
inherit: 'inherit',
|
|
27
|
+
primary: scaleRefs(tokens.color.primary, 'color-primary'),
|
|
28
|
+
secondary: scaleRefs(tokens.color.secondary, 'color-secondary'),
|
|
29
|
+
success: scaleRefs(tokens.color.success, 'color-success'),
|
|
30
|
+
warning: scaleRefs(tokens.color.warning, 'color-warning'),
|
|
31
|
+
danger: scaleRefs(tokens.color.danger, 'color-danger'),
|
|
32
|
+
neutral: scaleRefs(tokens.color.neutral, 'color-neutral'),
|
|
33
|
+
background: scaleRefs(tokens.color.background, 'color-background'),
|
|
34
|
+
text: scaleRefs(tokens.color.text, 'color-text'),
|
|
35
|
+
border: scaleRefs(tokens.color.border, 'color-border'),
|
|
36
|
+
},
|
|
37
|
+
fontFamily: {
|
|
38
|
+
sans: 'var(--font-family-sans)',
|
|
39
|
+
mono: 'var(--font-family-mono)',
|
|
40
|
+
},
|
|
41
|
+
fontSize: scaleRefs(tokens.typography.fontSize, 'font-size'),
|
|
42
|
+
fontWeight: scaleRefs(tokens.typography.fontWeight, 'font-weight'),
|
|
43
|
+
lineHeight: scaleRefs(tokens.typography.lineHeight, 'line-height'),
|
|
44
|
+
spacing: scaleRefs(tokens.spacing, 'spacing'),
|
|
45
|
+
borderRadius: scaleRefs(tokens.radius, 'radius'),
|
|
46
|
+
boxShadow: scaleRefs(tokens.shadow, 'shadow'),
|
|
47
|
+
transitionDuration: scaleRefs(tokens.motion.duration, 'motion-duration'),
|
|
48
|
+
transitionTimingFunction: scaleRefs(tokens.motion.easing, 'motion-easing'),
|
|
49
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ThemeTokenOverrides } from './theme-types.js';
|
|
2
|
+
export declare function toKebab(key: string): string;
|
|
3
|
+
export declare function flatten(value: unknown, path: string[], out: Record<string, string>): void;
|
|
4
|
+
/** THE theme mechanism: one token-override set → one [data-theme] CSS
|
|
5
|
+
* block. The build-time generator bakes built-ins through this exact
|
|
6
|
+
* function; the admin injects installed themes through it at runtime —
|
|
7
|
+
* "same mechanism as a third-party theme" is true by construction, not
|
|
8
|
+
* by convention. Empty overrides → empty string (Light IS the :root
|
|
9
|
+
* default and emits no block). Entries whose name or value contain a
|
|
10
|
+
* CSS-escaping character are skipped (with a warning) rather than
|
|
11
|
+
* emitted — see UNSAFE_CSS_CHARS. */
|
|
12
|
+
export declare function themeOverridesToCss(themeDomId: string, overrides: ThemeTokenOverrides): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function toKebab(key) {
|
|
2
|
+
return key.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
3
|
+
}
|
|
4
|
+
export function flatten(value, path, out) {
|
|
5
|
+
if (typeof value === 'object' && value !== null) {
|
|
6
|
+
for (const [key, child] of Object.entries(value)) {
|
|
7
|
+
flatten(child, [...path, toKebab(key)], out);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
out[`--${path.join('-')}`] = String(value);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// A variable name or value containing any of these could break out of its
|
|
15
|
+
// ` --name: value;` declaration and inject arbitrary rules into the
|
|
16
|
+
// shared admin-wide style block (both the baked tokens.css path and the
|
|
17
|
+
// runtime-injected theme path go through this same emission loop).
|
|
18
|
+
// Braces/semicolons/control characters are never legitimate inside a
|
|
19
|
+
// single CSS custom-property name or value.
|
|
20
|
+
const UNSAFE_CSS_CHARS = new RegExp('[{};\\u0000-\\u001f\\u007f]');
|
|
21
|
+
/** THE theme mechanism: one token-override set → one [data-theme] CSS
|
|
22
|
+
* block. The build-time generator bakes built-ins through this exact
|
|
23
|
+
* function; the admin injects installed themes through it at runtime —
|
|
24
|
+
* "same mechanism as a third-party theme" is true by construction, not
|
|
25
|
+
* by convention. Empty overrides → empty string (Light IS the :root
|
|
26
|
+
* default and emits no block). Entries whose name or value contain a
|
|
27
|
+
* CSS-escaping character are skipped (with a warning) rather than
|
|
28
|
+
* emitted — see UNSAFE_CSS_CHARS. */
|
|
29
|
+
export function themeOverridesToCss(themeDomId, overrides) {
|
|
30
|
+
const vars = {};
|
|
31
|
+
flatten(overrides, [], vars);
|
|
32
|
+
const entries = Object.entries(vars).filter(([name, value]) => {
|
|
33
|
+
if (UNSAFE_CSS_CHARS.test(name) || UNSAFE_CSS_CHARS.test(value)) {
|
|
34
|
+
console.warn(`themeOverridesToCss: skipping unsafe token "${name}" for theme "${themeDomId}" (contains CSS-escaping characters)`);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
if (entries.length === 0)
|
|
40
|
+
return '';
|
|
41
|
+
return [`[data-theme="${themeDomId}"] {`, ...entries.map(([n, v]) => ` ${n}: ${v};`), '}'].join('\n');
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ColorScale, VeloraDesignTokens } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a theme is allowed to touch: color scales/semantic groups and
|
|
4
|
+
* radius. Deliberately excludes typography, spacing, shadow, and motion
|
|
5
|
+
* — the Theme System section's "tokens only, never components" rule
|
|
6
|
+
* still leaves room for a theme to accidentally reshape layout-adjacent
|
|
7
|
+
* tokens if the type allowed it; keeping the override surface to
|
|
8
|
+
* color + radius keeps themes cosmetic by construction, not just by
|
|
9
|
+
* convention.
|
|
10
|
+
*/
|
|
11
|
+
export interface ThemeColorOverrides {
|
|
12
|
+
primary?: Partial<ColorScale>;
|
|
13
|
+
secondary?: Partial<ColorScale>;
|
|
14
|
+
success?: Partial<ColorScale>;
|
|
15
|
+
warning?: Partial<ColorScale>;
|
|
16
|
+
danger?: Partial<ColorScale>;
|
|
17
|
+
neutral?: Partial<ColorScale>;
|
|
18
|
+
background?: Partial<VeloraDesignTokens['color']['background']>;
|
|
19
|
+
text?: Partial<VeloraDesignTokens['color']['text']>;
|
|
20
|
+
border?: Partial<VeloraDesignTokens['color']['border']>;
|
|
21
|
+
}
|
|
22
|
+
export interface ThemeTokenOverrides {
|
|
23
|
+
color?: ThemeColorOverrides;
|
|
24
|
+
radius?: Partial<VeloraDesignTokens['radius']>;
|
|
25
|
+
}
|
|
26
|
+
/** A built-in theme, shaped like a theme plugin MANIFEST's relevant
|
|
27
|
+
* slice ({id, name, type, contributions.themeTokens}) rather than the
|
|
28
|
+
* retired pre-SDK {tokens} shape. DELIBERATE WAIVER: built-in ids stay
|
|
29
|
+
* "light"/"dark" (not reverse-domain) — they are statically registered,
|
|
30
|
+
* never pass marketplace validation, and every [data-theme] consumer
|
|
31
|
+
* (tokens.css, docs pages, tests) keys on these historical ids. */
|
|
32
|
+
export interface BuiltInTheme {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
type: 'theme';
|
|
36
|
+
contributions: {
|
|
37
|
+
themeTokens: ThemeTokenOverrides;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuiltInTheme } from '../theme-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Dark theme overrides, per the Theme System section of
|
|
4
|
+
* PROJECT_CONTEXT.md. Every value here is drawn from tokens the base
|
|
5
|
+
* set already declares — no new colors invented outside the
|
|
6
|
+
* VeloraDesignTokens shape. The background/text/border remaps make
|
|
7
|
+
* #0F1117 (the brand dark bg reserved for this theme since Session 25)
|
|
8
|
+
* and #F3F4F6 text actually apply; primary/secondary swap in the
|
|
9
|
+
* lighter tint their own scale already defines (400/500) so accents
|
|
10
|
+
* stay legible against the dark background, with the hover shade
|
|
11
|
+
* shifting to what was the light theme's base shade.
|
|
12
|
+
*/
|
|
13
|
+
export declare const darkTheme: BuiltInTheme;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dark theme overrides, per the Theme System section of
|
|
3
|
+
* PROJECT_CONTEXT.md. Every value here is drawn from tokens the base
|
|
4
|
+
* set already declares — no new colors invented outside the
|
|
5
|
+
* VeloraDesignTokens shape. The background/text/border remaps make
|
|
6
|
+
* #0F1117 (the brand dark bg reserved for this theme since Session 25)
|
|
7
|
+
* and #F3F4F6 text actually apply; primary/secondary swap in the
|
|
8
|
+
* lighter tint their own scale already defines (400/500) so accents
|
|
9
|
+
* stay legible against the dark background, with the hover shade
|
|
10
|
+
* shifting to what was the light theme's base shade.
|
|
11
|
+
*/
|
|
12
|
+
export const darkTheme = {
|
|
13
|
+
id: 'dark',
|
|
14
|
+
name: 'Dark',
|
|
15
|
+
type: 'theme',
|
|
16
|
+
contributions: {
|
|
17
|
+
themeTokens: {
|
|
18
|
+
color: {
|
|
19
|
+
background: {
|
|
20
|
+
base: '#0F1117',
|
|
21
|
+
elevated: '#171923',
|
|
22
|
+
overlay: 'rgba(0, 0, 0, 0.6)',
|
|
23
|
+
// one step lighter than elevated (neutral.800) — the missing dark
|
|
24
|
+
// remap behind the Session 41 outline-hover bug
|
|
25
|
+
hover: '#1F2937',
|
|
26
|
+
},
|
|
27
|
+
text: {
|
|
28
|
+
primary: '#F3F4F6',
|
|
29
|
+
secondary: '#9CA3AF',
|
|
30
|
+
disabled: '#4B5563',
|
|
31
|
+
},
|
|
32
|
+
border: {
|
|
33
|
+
default: '#1F2937',
|
|
34
|
+
subtle: '#171923',
|
|
35
|
+
strong: '#374151',
|
|
36
|
+
},
|
|
37
|
+
primary: { '500': '#818CF8', '600': '#6366F1' },
|
|
38
|
+
secondary: { '500': '#A78BFA', '600': '#8B5CF6' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BuiltInTheme } from '../theme-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Light needs no overrides — the base token set generated to :root
|
|
4
|
+
* (tokens.ts) already IS the light theme. Still modeled as a real
|
|
5
|
+
* BuiltInTheme, not a special case: applying any theme is always
|
|
6
|
+
* "set data-theme to this id," whether or not that theme happens to
|
|
7
|
+
* define overrides.
|
|
8
|
+
*/
|
|
9
|
+
export declare const lightTheme: BuiltInTheme;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Light needs no overrides — the base token set generated to :root
|
|
3
|
+
* (tokens.ts) already IS the light theme. Still modeled as a real
|
|
4
|
+
* BuiltInTheme, not a special case: applying any theme is always
|
|
5
|
+
* "set data-theme to this id," whether or not that theme happens to
|
|
6
|
+
* define overrides.
|
|
7
|
+
*/
|
|
8
|
+
export const lightTheme = {
|
|
9
|
+
id: 'light',
|
|
10
|
+
name: 'Light',
|
|
11
|
+
type: 'theme',
|
|
12
|
+
contributions: { themeTokens: {} },
|
|
13
|
+
};
|
package/dist/tokens.css
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/* Generated by @velora-cms/design-tokens — do not edit by hand. */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--color-primary-50: #EEF2FF;
|
|
5
|
+
--color-primary-100: #E0E7FF;
|
|
6
|
+
--color-primary-200: #C7D2FE;
|
|
7
|
+
--color-primary-300: #A5B4FC;
|
|
8
|
+
--color-primary-400: #818CF8;
|
|
9
|
+
--color-primary-500: #6366F1;
|
|
10
|
+
--color-primary-600: #4F46E5;
|
|
11
|
+
--color-primary-700: #4338CA;
|
|
12
|
+
--color-primary-800: #3730A3;
|
|
13
|
+
--color-primary-900: #312E81;
|
|
14
|
+
--color-primary-950: #1E1B4B;
|
|
15
|
+
--color-secondary-50: #F5F3FF;
|
|
16
|
+
--color-secondary-100: #EDE9FE;
|
|
17
|
+
--color-secondary-200: #DDD6FE;
|
|
18
|
+
--color-secondary-300: #C4B5FD;
|
|
19
|
+
--color-secondary-400: #A78BFA;
|
|
20
|
+
--color-secondary-500: #8B5CF6;
|
|
21
|
+
--color-secondary-600: #7C3AED;
|
|
22
|
+
--color-secondary-700: #6D28D9;
|
|
23
|
+
--color-secondary-800: #5B21B6;
|
|
24
|
+
--color-secondary-900: #4C1D95;
|
|
25
|
+
--color-secondary-950: #2E1065;
|
|
26
|
+
--color-success-50: #ECFDF5;
|
|
27
|
+
--color-success-100: #D1FAE5;
|
|
28
|
+
--color-success-200: #A7F3D0;
|
|
29
|
+
--color-success-300: #6EE7B7;
|
|
30
|
+
--color-success-400: #34D399;
|
|
31
|
+
--color-success-500: #10B981;
|
|
32
|
+
--color-success-600: #059669;
|
|
33
|
+
--color-success-700: #047857;
|
|
34
|
+
--color-success-800: #065F46;
|
|
35
|
+
--color-success-900: #064E3B;
|
|
36
|
+
--color-success-950: #022C22;
|
|
37
|
+
--color-warning-50: #FFFBEB;
|
|
38
|
+
--color-warning-100: #FEF3C7;
|
|
39
|
+
--color-warning-200: #FDE68A;
|
|
40
|
+
--color-warning-300: #FCD34D;
|
|
41
|
+
--color-warning-400: #FBBF24;
|
|
42
|
+
--color-warning-500: #F59E0B;
|
|
43
|
+
--color-warning-600: #D97706;
|
|
44
|
+
--color-warning-700: #B45309;
|
|
45
|
+
--color-warning-800: #92400E;
|
|
46
|
+
--color-warning-900: #78350F;
|
|
47
|
+
--color-warning-950: #451A03;
|
|
48
|
+
--color-danger-50: #FEF2F2;
|
|
49
|
+
--color-danger-100: #FEE2E2;
|
|
50
|
+
--color-danger-200: #FECACA;
|
|
51
|
+
--color-danger-300: #FCA5A5;
|
|
52
|
+
--color-danger-400: #F87171;
|
|
53
|
+
--color-danger-500: #EF4444;
|
|
54
|
+
--color-danger-600: #DC2626;
|
|
55
|
+
--color-danger-700: #B91C1C;
|
|
56
|
+
--color-danger-800: #991B1B;
|
|
57
|
+
--color-danger-900: #7F1D1D;
|
|
58
|
+
--color-danger-950: #450A0A;
|
|
59
|
+
--color-neutral-50: #F9FAFB;
|
|
60
|
+
--color-neutral-100: #F3F4F6;
|
|
61
|
+
--color-neutral-200: #E5E7EB;
|
|
62
|
+
--color-neutral-300: #D1D5DB;
|
|
63
|
+
--color-neutral-400: #9CA3AF;
|
|
64
|
+
--color-neutral-500: #6B7280;
|
|
65
|
+
--color-neutral-600: #4B5563;
|
|
66
|
+
--color-neutral-700: #374151;
|
|
67
|
+
--color-neutral-800: #1F2937;
|
|
68
|
+
--color-neutral-900: #111827;
|
|
69
|
+
--color-neutral-950: #030712;
|
|
70
|
+
--color-background-base: #F9FAFB;
|
|
71
|
+
--color-background-elevated: #FFFFFF;
|
|
72
|
+
--color-background-overlay: rgba(17, 24, 39, 0.5);
|
|
73
|
+
--color-background-hover: #F3F4F6;
|
|
74
|
+
--color-text-primary: #111827;
|
|
75
|
+
--color-text-secondary: #6B7280;
|
|
76
|
+
--color-text-disabled: #9CA3AF;
|
|
77
|
+
--color-text-inverse: #FFFFFF;
|
|
78
|
+
--color-border-default: #E5E7EB;
|
|
79
|
+
--color-border-subtle: #F3F4F6;
|
|
80
|
+
--color-border-strong: #D1D5DB;
|
|
81
|
+
--spacing-0: 0;
|
|
82
|
+
--spacing-1: 0.25rem;
|
|
83
|
+
--spacing-2: 0.5rem;
|
|
84
|
+
--spacing-3: 0.75rem;
|
|
85
|
+
--spacing-4: 1rem;
|
|
86
|
+
--spacing-5: 1.25rem;
|
|
87
|
+
--spacing-6: 1.5rem;
|
|
88
|
+
--spacing-7: 1.75rem;
|
|
89
|
+
--spacing-8: 2rem;
|
|
90
|
+
--spacing-9: 2.25rem;
|
|
91
|
+
--spacing-10: 2.5rem;
|
|
92
|
+
--spacing-11: 2.75rem;
|
|
93
|
+
--spacing-12: 3rem;
|
|
94
|
+
--spacing-14: 3.5rem;
|
|
95
|
+
--spacing-16: 4rem;
|
|
96
|
+
--spacing-20: 5rem;
|
|
97
|
+
--spacing-24: 6rem;
|
|
98
|
+
--spacing-px: 1px;
|
|
99
|
+
--radius-none: 0;
|
|
100
|
+
--radius-sm: 0.25rem;
|
|
101
|
+
--radius-md: 0.375rem;
|
|
102
|
+
--radius-lg: 0.5rem;
|
|
103
|
+
--radius-full: 9999px;
|
|
104
|
+
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
105
|
+
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
|
|
106
|
+
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
|
107
|
+
--shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
|
|
108
|
+
--motion-duration-fast: 150ms;
|
|
109
|
+
--motion-duration-normal: 250ms;
|
|
110
|
+
--motion-duration-slow: 400ms;
|
|
111
|
+
--motion-easing-standard: cubic-bezier(0.4, 0, 0.2, 1);
|
|
112
|
+
--motion-easing-enter: cubic-bezier(0, 0, 0.2, 1);
|
|
113
|
+
--motion-easing-exit: cubic-bezier(0.4, 0, 1, 1);
|
|
114
|
+
--direction: ltr;
|
|
115
|
+
--font-family-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
116
|
+
--font-family-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
|
|
117
|
+
--font-size-xs: 0.75rem;
|
|
118
|
+
--font-size-sm: 0.875rem;
|
|
119
|
+
--font-size-base: 1rem;
|
|
120
|
+
--font-size-lg: 1.125rem;
|
|
121
|
+
--font-size-xl: 1.25rem;
|
|
122
|
+
--font-weight-normal: 400;
|
|
123
|
+
--font-weight-medium: 500;
|
|
124
|
+
--font-weight-semibold: 600;
|
|
125
|
+
--font-weight-bold: 700;
|
|
126
|
+
--line-height-tight: 1.25;
|
|
127
|
+
--line-height-normal: 1.5;
|
|
128
|
+
--line-height-relaxed: 1.75;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[data-theme="dark"] {
|
|
132
|
+
--color-background-base: #0F1117;
|
|
133
|
+
--color-background-elevated: #171923;
|
|
134
|
+
--color-background-overlay: rgba(0, 0, 0, 0.6);
|
|
135
|
+
--color-background-hover: #1F2937;
|
|
136
|
+
--color-text-primary: #F3F4F6;
|
|
137
|
+
--color-text-secondary: #9CA3AF;
|
|
138
|
+
--color-text-disabled: #4B5563;
|
|
139
|
+
--color-border-default: #1F2937;
|
|
140
|
+
--color-border-subtle: #171923;
|
|
141
|
+
--color-border-strong: #374151;
|
|
142
|
+
--color-primary-500: #818CF8;
|
|
143
|
+
--color-primary-600: #6366F1;
|
|
144
|
+
--color-secondary-500: #A78BFA;
|
|
145
|
+
--color-secondary-600: #8B5CF6;
|
|
146
|
+
}
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VeloraDesignTokens } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Velora brand tokens — the default (light) token set.
|
|
4
|
+
*
|
|
5
|
+
* Brand anchors from docs/PROJECT_CONTEXT.md → UI & Design System:
|
|
6
|
+
* every brand color is the 500 step of its scale (indigo #6366F1,
|
|
7
|
+
* violet #8B5CF6, emerald #10B981, amber #F59E0B, red #EF4444), and
|
|
8
|
+
* the light background #F9FAFB is neutral.50. The dark background
|
|
9
|
+
* #0F1117 belongs to the Dark theme's overrides (Session 27), not to
|
|
10
|
+
* this base set — themes override tokens, never components.
|
|
11
|
+
*/
|
|
12
|
+
export declare const tokens: VeloraDesignTokens;
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Velora brand tokens — the default (light) token set.
|
|
3
|
+
*
|
|
4
|
+
* Brand anchors from docs/PROJECT_CONTEXT.md → UI & Design System:
|
|
5
|
+
* every brand color is the 500 step of its scale (indigo #6366F1,
|
|
6
|
+
* violet #8B5CF6, emerald #10B981, amber #F59E0B, red #EF4444), and
|
|
7
|
+
* the light background #F9FAFB is neutral.50. The dark background
|
|
8
|
+
* #0F1117 belongs to the Dark theme's overrides (Session 27), not to
|
|
9
|
+
* this base set — themes override tokens, never components.
|
|
10
|
+
*/
|
|
11
|
+
export const tokens = {
|
|
12
|
+
color: {
|
|
13
|
+
primary: {
|
|
14
|
+
'50': '#EEF2FF',
|
|
15
|
+
'100': '#E0E7FF',
|
|
16
|
+
'200': '#C7D2FE',
|
|
17
|
+
'300': '#A5B4FC',
|
|
18
|
+
'400': '#818CF8',
|
|
19
|
+
'500': '#6366F1',
|
|
20
|
+
'600': '#4F46E5',
|
|
21
|
+
'700': '#4338CA',
|
|
22
|
+
'800': '#3730A3',
|
|
23
|
+
'900': '#312E81',
|
|
24
|
+
'950': '#1E1B4B',
|
|
25
|
+
},
|
|
26
|
+
secondary: {
|
|
27
|
+
'50': '#F5F3FF',
|
|
28
|
+
'100': '#EDE9FE',
|
|
29
|
+
'200': '#DDD6FE',
|
|
30
|
+
'300': '#C4B5FD',
|
|
31
|
+
'400': '#A78BFA',
|
|
32
|
+
'500': '#8B5CF6',
|
|
33
|
+
'600': '#7C3AED',
|
|
34
|
+
'700': '#6D28D9',
|
|
35
|
+
'800': '#5B21B6',
|
|
36
|
+
'900': '#4C1D95',
|
|
37
|
+
'950': '#2E1065',
|
|
38
|
+
},
|
|
39
|
+
success: {
|
|
40
|
+
'50': '#ECFDF5',
|
|
41
|
+
'100': '#D1FAE5',
|
|
42
|
+
'200': '#A7F3D0',
|
|
43
|
+
'300': '#6EE7B7',
|
|
44
|
+
'400': '#34D399',
|
|
45
|
+
'500': '#10B981',
|
|
46
|
+
'600': '#059669',
|
|
47
|
+
'700': '#047857',
|
|
48
|
+
'800': '#065F46',
|
|
49
|
+
'900': '#064E3B',
|
|
50
|
+
'950': '#022C22',
|
|
51
|
+
},
|
|
52
|
+
warning: {
|
|
53
|
+
'50': '#FFFBEB',
|
|
54
|
+
'100': '#FEF3C7',
|
|
55
|
+
'200': '#FDE68A',
|
|
56
|
+
'300': '#FCD34D',
|
|
57
|
+
'400': '#FBBF24',
|
|
58
|
+
'500': '#F59E0B',
|
|
59
|
+
'600': '#D97706',
|
|
60
|
+
'700': '#B45309',
|
|
61
|
+
'800': '#92400E',
|
|
62
|
+
'900': '#78350F',
|
|
63
|
+
'950': '#451A03',
|
|
64
|
+
},
|
|
65
|
+
danger: {
|
|
66
|
+
'50': '#FEF2F2',
|
|
67
|
+
'100': '#FEE2E2',
|
|
68
|
+
'200': '#FECACA',
|
|
69
|
+
'300': '#FCA5A5',
|
|
70
|
+
'400': '#F87171',
|
|
71
|
+
'500': '#EF4444',
|
|
72
|
+
'600': '#DC2626',
|
|
73
|
+
'700': '#B91C1C',
|
|
74
|
+
'800': '#991B1B',
|
|
75
|
+
'900': '#7F1D1D',
|
|
76
|
+
'950': '#450A0A',
|
|
77
|
+
},
|
|
78
|
+
neutral: {
|
|
79
|
+
'50': '#F9FAFB',
|
|
80
|
+
'100': '#F3F4F6',
|
|
81
|
+
'200': '#E5E7EB',
|
|
82
|
+
'300': '#D1D5DB',
|
|
83
|
+
'400': '#9CA3AF',
|
|
84
|
+
'500': '#6B7280',
|
|
85
|
+
'600': '#4B5563',
|
|
86
|
+
'700': '#374151',
|
|
87
|
+
'800': '#1F2937',
|
|
88
|
+
'900': '#111827',
|
|
89
|
+
'950': '#030712',
|
|
90
|
+
},
|
|
91
|
+
background: {
|
|
92
|
+
base: '#F9FAFB',
|
|
93
|
+
elevated: '#FFFFFF',
|
|
94
|
+
overlay: 'rgba(17, 24, 39, 0.5)',
|
|
95
|
+
// neutral.100 — the shade outline/ghost hovers rendered before this
|
|
96
|
+
// was a token, so light theme is visually unchanged
|
|
97
|
+
hover: '#F3F4F6',
|
|
98
|
+
},
|
|
99
|
+
text: {
|
|
100
|
+
primary: '#111827',
|
|
101
|
+
secondary: '#6B7280',
|
|
102
|
+
disabled: '#9CA3AF',
|
|
103
|
+
inverse: '#FFFFFF',
|
|
104
|
+
},
|
|
105
|
+
border: {
|
|
106
|
+
default: '#E5E7EB',
|
|
107
|
+
subtle: '#F3F4F6',
|
|
108
|
+
strong: '#D1D5DB',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
typography: {
|
|
112
|
+
fontFamily: {
|
|
113
|
+
sans: "'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif",
|
|
114
|
+
mono: "'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace",
|
|
115
|
+
},
|
|
116
|
+
fontSize: {
|
|
117
|
+
xs: '0.75rem',
|
|
118
|
+
sm: '0.875rem',
|
|
119
|
+
base: '1rem',
|
|
120
|
+
lg: '1.125rem',
|
|
121
|
+
xl: '1.25rem',
|
|
122
|
+
},
|
|
123
|
+
fontWeight: {
|
|
124
|
+
normal: 400,
|
|
125
|
+
medium: 500,
|
|
126
|
+
semibold: 600,
|
|
127
|
+
bold: 700,
|
|
128
|
+
},
|
|
129
|
+
lineHeight: {
|
|
130
|
+
tight: 1.25,
|
|
131
|
+
normal: 1.5,
|
|
132
|
+
relaxed: 1.75,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
spacing: {
|
|
136
|
+
'0': '0',
|
|
137
|
+
px: '1px',
|
|
138
|
+
'1': '0.25rem',
|
|
139
|
+
'2': '0.5rem',
|
|
140
|
+
'3': '0.75rem',
|
|
141
|
+
'4': '1rem',
|
|
142
|
+
'5': '1.25rem',
|
|
143
|
+
'6': '1.5rem',
|
|
144
|
+
'7': '1.75rem',
|
|
145
|
+
'8': '2rem',
|
|
146
|
+
'9': '2.25rem',
|
|
147
|
+
'10': '2.5rem',
|
|
148
|
+
'11': '2.75rem',
|
|
149
|
+
'12': '3rem',
|
|
150
|
+
'14': '3.5rem',
|
|
151
|
+
'16': '4rem',
|
|
152
|
+
'20': '5rem',
|
|
153
|
+
'24': '6rem',
|
|
154
|
+
},
|
|
155
|
+
radius: {
|
|
156
|
+
none: '0',
|
|
157
|
+
sm: '0.25rem',
|
|
158
|
+
md: '0.375rem',
|
|
159
|
+
lg: '0.5rem',
|
|
160
|
+
full: '9999px',
|
|
161
|
+
},
|
|
162
|
+
shadow: {
|
|
163
|
+
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
164
|
+
md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',
|
|
165
|
+
lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)',
|
|
166
|
+
xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)',
|
|
167
|
+
},
|
|
168
|
+
motion: {
|
|
169
|
+
duration: {
|
|
170
|
+
fast: '150ms',
|
|
171
|
+
normal: '250ms',
|
|
172
|
+
slow: '400ms',
|
|
173
|
+
},
|
|
174
|
+
easing: {
|
|
175
|
+
standard: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
176
|
+
enter: 'cubic-bezier(0, 0, 0.2, 1)',
|
|
177
|
+
exit: 'cubic-bezier(0.4, 0, 1, 1)',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
direction: 'ltr',
|
|
181
|
+
};
|
package/dist/tokens.json
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
{
|
|
2
|
+
"color": {
|
|
3
|
+
"primary": {
|
|
4
|
+
"50": "#EEF2FF",
|
|
5
|
+
"100": "#E0E7FF",
|
|
6
|
+
"200": "#C7D2FE",
|
|
7
|
+
"300": "#A5B4FC",
|
|
8
|
+
"400": "#818CF8",
|
|
9
|
+
"500": "#6366F1",
|
|
10
|
+
"600": "#4F46E5",
|
|
11
|
+
"700": "#4338CA",
|
|
12
|
+
"800": "#3730A3",
|
|
13
|
+
"900": "#312E81",
|
|
14
|
+
"950": "#1E1B4B"
|
|
15
|
+
},
|
|
16
|
+
"secondary": {
|
|
17
|
+
"50": "#F5F3FF",
|
|
18
|
+
"100": "#EDE9FE",
|
|
19
|
+
"200": "#DDD6FE",
|
|
20
|
+
"300": "#C4B5FD",
|
|
21
|
+
"400": "#A78BFA",
|
|
22
|
+
"500": "#8B5CF6",
|
|
23
|
+
"600": "#7C3AED",
|
|
24
|
+
"700": "#6D28D9",
|
|
25
|
+
"800": "#5B21B6",
|
|
26
|
+
"900": "#4C1D95",
|
|
27
|
+
"950": "#2E1065"
|
|
28
|
+
},
|
|
29
|
+
"success": {
|
|
30
|
+
"50": "#ECFDF5",
|
|
31
|
+
"100": "#D1FAE5",
|
|
32
|
+
"200": "#A7F3D0",
|
|
33
|
+
"300": "#6EE7B7",
|
|
34
|
+
"400": "#34D399",
|
|
35
|
+
"500": "#10B981",
|
|
36
|
+
"600": "#059669",
|
|
37
|
+
"700": "#047857",
|
|
38
|
+
"800": "#065F46",
|
|
39
|
+
"900": "#064E3B",
|
|
40
|
+
"950": "#022C22"
|
|
41
|
+
},
|
|
42
|
+
"warning": {
|
|
43
|
+
"50": "#FFFBEB",
|
|
44
|
+
"100": "#FEF3C7",
|
|
45
|
+
"200": "#FDE68A",
|
|
46
|
+
"300": "#FCD34D",
|
|
47
|
+
"400": "#FBBF24",
|
|
48
|
+
"500": "#F59E0B",
|
|
49
|
+
"600": "#D97706",
|
|
50
|
+
"700": "#B45309",
|
|
51
|
+
"800": "#92400E",
|
|
52
|
+
"900": "#78350F",
|
|
53
|
+
"950": "#451A03"
|
|
54
|
+
},
|
|
55
|
+
"danger": {
|
|
56
|
+
"50": "#FEF2F2",
|
|
57
|
+
"100": "#FEE2E2",
|
|
58
|
+
"200": "#FECACA",
|
|
59
|
+
"300": "#FCA5A5",
|
|
60
|
+
"400": "#F87171",
|
|
61
|
+
"500": "#EF4444",
|
|
62
|
+
"600": "#DC2626",
|
|
63
|
+
"700": "#B91C1C",
|
|
64
|
+
"800": "#991B1B",
|
|
65
|
+
"900": "#7F1D1D",
|
|
66
|
+
"950": "#450A0A"
|
|
67
|
+
},
|
|
68
|
+
"neutral": {
|
|
69
|
+
"50": "#F9FAFB",
|
|
70
|
+
"100": "#F3F4F6",
|
|
71
|
+
"200": "#E5E7EB",
|
|
72
|
+
"300": "#D1D5DB",
|
|
73
|
+
"400": "#9CA3AF",
|
|
74
|
+
"500": "#6B7280",
|
|
75
|
+
"600": "#4B5563",
|
|
76
|
+
"700": "#374151",
|
|
77
|
+
"800": "#1F2937",
|
|
78
|
+
"900": "#111827",
|
|
79
|
+
"950": "#030712"
|
|
80
|
+
},
|
|
81
|
+
"background": {
|
|
82
|
+
"base": "#F9FAFB",
|
|
83
|
+
"elevated": "#FFFFFF",
|
|
84
|
+
"overlay": "rgba(17, 24, 39, 0.5)",
|
|
85
|
+
"hover": "#F3F4F6"
|
|
86
|
+
},
|
|
87
|
+
"text": {
|
|
88
|
+
"primary": "#111827",
|
|
89
|
+
"secondary": "#6B7280",
|
|
90
|
+
"disabled": "#9CA3AF",
|
|
91
|
+
"inverse": "#FFFFFF"
|
|
92
|
+
},
|
|
93
|
+
"border": {
|
|
94
|
+
"default": "#E5E7EB",
|
|
95
|
+
"subtle": "#F3F4F6",
|
|
96
|
+
"strong": "#D1D5DB"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"typography": {
|
|
100
|
+
"fontFamily": {
|
|
101
|
+
"sans": "'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif",
|
|
102
|
+
"mono": "'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace"
|
|
103
|
+
},
|
|
104
|
+
"fontSize": {
|
|
105
|
+
"xs": "0.75rem",
|
|
106
|
+
"sm": "0.875rem",
|
|
107
|
+
"base": "1rem",
|
|
108
|
+
"lg": "1.125rem",
|
|
109
|
+
"xl": "1.25rem"
|
|
110
|
+
},
|
|
111
|
+
"fontWeight": {
|
|
112
|
+
"normal": 400,
|
|
113
|
+
"medium": 500,
|
|
114
|
+
"semibold": 600,
|
|
115
|
+
"bold": 700
|
|
116
|
+
},
|
|
117
|
+
"lineHeight": {
|
|
118
|
+
"tight": 1.25,
|
|
119
|
+
"normal": 1.5,
|
|
120
|
+
"relaxed": 1.75
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"spacing": {
|
|
124
|
+
"0": "0",
|
|
125
|
+
"1": "0.25rem",
|
|
126
|
+
"2": "0.5rem",
|
|
127
|
+
"3": "0.75rem",
|
|
128
|
+
"4": "1rem",
|
|
129
|
+
"5": "1.25rem",
|
|
130
|
+
"6": "1.5rem",
|
|
131
|
+
"7": "1.75rem",
|
|
132
|
+
"8": "2rem",
|
|
133
|
+
"9": "2.25rem",
|
|
134
|
+
"10": "2.5rem",
|
|
135
|
+
"11": "2.75rem",
|
|
136
|
+
"12": "3rem",
|
|
137
|
+
"14": "3.5rem",
|
|
138
|
+
"16": "4rem",
|
|
139
|
+
"20": "5rem",
|
|
140
|
+
"24": "6rem",
|
|
141
|
+
"px": "1px"
|
|
142
|
+
},
|
|
143
|
+
"radius": {
|
|
144
|
+
"none": "0",
|
|
145
|
+
"sm": "0.25rem",
|
|
146
|
+
"md": "0.375rem",
|
|
147
|
+
"lg": "0.5rem",
|
|
148
|
+
"full": "9999px"
|
|
149
|
+
},
|
|
150
|
+
"shadow": {
|
|
151
|
+
"sm": "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
152
|
+
"md": "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)",
|
|
153
|
+
"lg": "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",
|
|
154
|
+
"xl": "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"
|
|
155
|
+
},
|
|
156
|
+
"motion": {
|
|
157
|
+
"duration": {
|
|
158
|
+
"fast": "150ms",
|
|
159
|
+
"normal": "250ms",
|
|
160
|
+
"slow": "400ms"
|
|
161
|
+
},
|
|
162
|
+
"easing": {
|
|
163
|
+
"standard": "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
164
|
+
"enter": "cubic-bezier(0, 0, 0.2, 1)",
|
|
165
|
+
"exit": "cubic-bezier(0.4, 0, 1, 1)"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"direction": "ltr"
|
|
169
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design token type definitions — the shape every theme (built-in or
|
|
3
|
+
* plugin) targets. See docs/PROJECT_CONTEXT.md → Design Tokens.
|
|
4
|
+
*/
|
|
5
|
+
export type ColorScaleStep = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950';
|
|
6
|
+
export type ColorScale = Record<ColorScaleStep, string>;
|
|
7
|
+
/**
|
|
8
|
+
* 4px-base spacing scale. Keys are multiples of the base unit
|
|
9
|
+
* (spacing '4' = 4 × 4px = 1rem), plus 'px' for hairline offsets.
|
|
10
|
+
* Dots are avoided in keys so CSS custom property names stay valid
|
|
11
|
+
* without escaping.
|
|
12
|
+
*/
|
|
13
|
+
export type SpacingStep = '0' | 'px' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '14' | '16' | '20' | '24';
|
|
14
|
+
export type ScaleTokens = Record<SpacingStep, string>;
|
|
15
|
+
export interface VeloraDesignTokens {
|
|
16
|
+
color: {
|
|
17
|
+
primary: ColorScale;
|
|
18
|
+
secondary: ColorScale;
|
|
19
|
+
success: ColorScale;
|
|
20
|
+
warning: ColorScale;
|
|
21
|
+
danger: ColorScale;
|
|
22
|
+
neutral: ColorScale;
|
|
23
|
+
background: {
|
|
24
|
+
base: string;
|
|
25
|
+
elevated: string;
|
|
26
|
+
overlay: string;
|
|
27
|
+
hover: string;
|
|
28
|
+
};
|
|
29
|
+
text: {
|
|
30
|
+
primary: string;
|
|
31
|
+
secondary: string;
|
|
32
|
+
disabled: string;
|
|
33
|
+
inverse: string;
|
|
34
|
+
};
|
|
35
|
+
border: {
|
|
36
|
+
default: string;
|
|
37
|
+
subtle: string;
|
|
38
|
+
strong: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
typography: {
|
|
42
|
+
fontFamily: {
|
|
43
|
+
sans: string;
|
|
44
|
+
mono: string;
|
|
45
|
+
};
|
|
46
|
+
fontSize: Record<'xs' | 'sm' | 'base' | 'lg' | 'xl', string>;
|
|
47
|
+
fontWeight: Record<'normal' | 'medium' | 'semibold' | 'bold', number>;
|
|
48
|
+
lineHeight: Record<'tight' | 'normal' | 'relaxed', number>;
|
|
49
|
+
};
|
|
50
|
+
spacing: ScaleTokens;
|
|
51
|
+
radius: Record<'none' | 'sm' | 'md' | 'lg' | 'full', string>;
|
|
52
|
+
shadow: Record<'sm' | 'md' | 'lg' | 'xl', string>;
|
|
53
|
+
motion: {
|
|
54
|
+
duration: Record<string, string>;
|
|
55
|
+
easing: Record<string, string>;
|
|
56
|
+
};
|
|
57
|
+
direction: 'ltr' | 'rtl';
|
|
58
|
+
}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@velora-cms/design-tokens",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/velora-cms/velora.git",
|
|
14
|
+
"directory": "packages/design-tokens"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./tokens.css": "./dist/tokens.css",
|
|
26
|
+
"./tokens.json": "./dist/tokens.json"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "20.19.43"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p . && node dist/generate.js",
|
|
33
|
+
"test": "vitest run"
|
|
34
|
+
}
|
|
35
|
+
}
|