@nova-design-system/nova-base 3.28.0 → 3.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -32
- package/dist/cjs/generated/nova-tailwind-components.js +3 -0
- package/dist/cjs/generated/nova-tailwind-tokens.js +45 -0
- package/dist/cjs/plugin/index.js +0 -1
- package/dist/cjs/plugin/nova-plugin.js +2 -100
- package/dist/cjs/plugin/typography.js +135 -0
- package/dist/css/nova-utils.css +26768 -24633
- package/dist/css/ocean.css +51 -8
- package/dist/css/spark.css +53 -10
- package/dist/generated/nova-tailwind-components.d.ts +3 -0
- package/dist/generated/nova-tailwind-components.js +3 -0
- package/dist/generated/nova-tailwind-tokens.d.ts +45 -0
- package/dist/generated/nova-tailwind-tokens.js +45 -0
- package/dist/js/ocean_dark.d.ts +15 -0
- package/dist/js/ocean_dark.js +26 -11
- package/dist/js/ocean_light.d.ts +15 -0
- package/dist/js/ocean_light.js +17 -2
- package/dist/js/spacings.d.ts +14 -1
- package/dist/js/spacings.js +14 -1
- package/dist/js/spark_dark.d.ts +15 -0
- package/dist/js/spark_dark.js +29 -14
- package/dist/js/spark_light.d.ts +15 -0
- package/dist/js/spark_light.js +17 -2
- package/dist/plugin/index.d.ts +0 -1
- package/dist/plugin/index.js +0 -1
- package/dist/plugin/nova-plugin.d.ts +2 -4
- package/dist/plugin/nova-plugin.js +2 -99
- package/dist/plugin/typography.d.ts +79 -0
- package/dist/plugin/typography.js +127 -0
- package/generated/figma-to-tailwind-mapping.json +197 -18
- package/generated/nova-tailwind-components.ts +3 -0
- package/generated/nova-tailwind-tokens.ts +45 -0
- package/package.json +6 -3
- package/dist/cjs/plugin/nova-safelist.js +0 -341
- package/dist/plugin/nova-safelist.d.ts +0 -26
- package/dist/plugin/nova-safelist.js +0 -355
package/README.md
CHANGED
|
@@ -36,54 +36,47 @@ Include the tokens CSS in your project (two themes are available: Spark and Ocea
|
|
|
36
36
|
@import '@nova-design-system/nova-base/dist/css/ocean.css';
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
### Recommended Approach: Using Tailwind CSS with Nova Theme and Plugin
|
|
39
|
+
### Recommended Approach: Using Tailwind CSS v4 with Nova Theme and Plugin
|
|
40
40
|
|
|
41
|
-
The recommended approach is to set up Tailwind CSS and use
|
|
41
|
+
The recommended approach is to set up Tailwind CSS v4 and use the Nova theme and plugin via CSS directives. This method provides a smaller CSS bundle and access to more utilities than the precompiled CSS.
|
|
42
42
|
|
|
43
43
|
#### Prerequisites
|
|
44
44
|
|
|
45
|
-
Ensure that Tailwind CSS is installed in your project. If not, you can install it by following the [Tailwind CSS installation guide](https://tailwindcss.com/docs/installation).
|
|
45
|
+
Ensure that Tailwind CSS v4 is installed in your project. If not, you can install it by following the [Tailwind CSS installation guide](https://tailwindcss.com/docs/installation).
|
|
46
46
|
|
|
47
|
-
####
|
|
47
|
+
#### CSS Configuration
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Tailwind CSS v4 uses a CSS-first configuration. In your main CSS file, import Tailwind and configure the Nova plugin and theme:
|
|
50
50
|
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} from '@nova-design-system/nova-base/theme';
|
|
56
|
-
|
|
57
|
-
/** @type {import('tailwindcss').Config} */
|
|
58
|
-
export default {
|
|
59
|
-
// ...
|
|
60
|
-
theme: novaTailwindTheme,
|
|
61
|
-
plugins: [novaTailwindPlugin],
|
|
62
|
-
};
|
|
63
|
-
```
|
|
51
|
+
```css
|
|
52
|
+
/* Import the theme tokens */
|
|
53
|
+
@import '@nova-design-system/nova-base/dist/css/spark.css';
|
|
54
|
+
/* Or: @import '@nova-design-system/nova-base/dist/css/ocean.css'; */
|
|
64
55
|
|
|
65
|
-
|
|
56
|
+
@import "tailwindcss";
|
|
66
57
|
|
|
67
|
-
|
|
58
|
+
@plugin "@nova-design-system/nova-base/theme/plugin";
|
|
59
|
+
@config "./tailwind.config.ts";
|
|
60
|
+
```
|
|
68
61
|
|
|
69
|
-
|
|
62
|
+
Then create a minimal `tailwind.config.ts` with the Nova theme:
|
|
70
63
|
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
```ts
|
|
65
|
+
import type { Config } from 'tailwindcss';
|
|
66
|
+
import { novaTailwindTheme } from '@nova-design-system/nova-base/theme';
|
|
74
67
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
@tailwind utilities;
|
|
68
|
+
const config: Config = {
|
|
69
|
+
theme: novaTailwindTheme,
|
|
70
|
+
};
|
|
79
71
|
|
|
80
|
-
|
|
81
|
-
/* @import '@nova-design-system/nova-base/dist/css/ocean.css'; */
|
|
72
|
+
export default config;
|
|
82
73
|
```
|
|
83
74
|
|
|
75
|
+
The `novaTailwindTheme` maps Nova CSS variable tokens to Tailwind utilities. The `novaTailwindPlugin` (loaded via `@plugin`) adds base styles, components, and custom utilities like `text-high`, `bg-level-00`, and typography classes.
|
|
76
|
+
|
|
84
77
|
#### Benefits of Using Tailwind CSS with Nova Theme and Plugin
|
|
85
78
|
|
|
86
|
-
- **Smaller CSS Bundle:**
|
|
79
|
+
- **Smaller CSS Bundle:** Tailwind CSS v4 only generates CSS for classes actually used in your source files, resulting in a significantly smaller output.
|
|
87
80
|
- **More Utilities:** Gain access to a wider range of utilities beyond those included in the precompiled CSS.
|
|
88
81
|
- **Customization:** Tailwind CSS allows you to customize and extend your styles as needed.
|
|
89
82
|
|
|
@@ -97,4 +90,4 @@ import '@nova-design-system/nova-base/dist/css/spark.css';
|
|
|
97
90
|
import '@nova-design-system/nova-base/dist/css/nova-utils.css';
|
|
98
91
|
```
|
|
99
92
|
|
|
100
|
-
**Note:** The precompiled CSS includes a
|
|
93
|
+
**Note:** The precompiled CSS includes a broad set of pre-generated Tailwind utility classes and is quite large. This approach is only recommended if you cannot set up Tailwind CSS yourself.
|
|
@@ -208,6 +208,9 @@ exports.NOVA_TAILWIND_COMPONENTS = {
|
|
|
208
208
|
'fontStyle': 'normal',
|
|
209
209
|
'lineHeight': 'var(--form-description-line-height)'
|
|
210
210
|
},
|
|
211
|
+
'.nv-fieldtext > .error-description[hidden]': {
|
|
212
|
+
'display': 'none'
|
|
213
|
+
},
|
|
211
214
|
'.nv-button': {
|
|
212
215
|
'textDecoration': 'none',
|
|
213
216
|
'display': 'inline-flex',
|
|
@@ -91,6 +91,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
91
91
|
'.border-feedback-error-low': {
|
|
92
92
|
'border-color': 'var(--color-feedback-error-low-border)'
|
|
93
93
|
},
|
|
94
|
+
'.border-feedback-error-low-subtle': {
|
|
95
|
+
'border-color': 'var(--color-feedback-error-low-border-subtle)'
|
|
96
|
+
},
|
|
94
97
|
'.icon-feedback-error-low': {
|
|
95
98
|
'color': 'var(--color-feedback-error-low-icon)'
|
|
96
99
|
},
|
|
@@ -127,6 +130,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
127
130
|
'.border-feedback-information-low': {
|
|
128
131
|
'border-color': 'var(--color-feedback-information-low-border)'
|
|
129
132
|
},
|
|
133
|
+
'.border-feedback-information-low-subtle': {
|
|
134
|
+
'border-color': 'var(--color-feedback-information-low-border-subtle)'
|
|
135
|
+
},
|
|
130
136
|
'.icon-feedback-information-low': {
|
|
131
137
|
'color': 'var(--color-feedback-information-low-icon)'
|
|
132
138
|
},
|
|
@@ -163,6 +169,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
163
169
|
'.border-feedback-neutral-low': {
|
|
164
170
|
'border-color': 'var(--color-feedback-neutral-low-border)'
|
|
165
171
|
},
|
|
172
|
+
'.border-feedback-neutral-low-subtle': {
|
|
173
|
+
'border-color': 'var(--color-feedback-neutral-low-border-subtle)'
|
|
174
|
+
},
|
|
166
175
|
'.icon-feedback-neutral-low': {
|
|
167
176
|
'color': 'var(--color-feedback-neutral-low-icon)'
|
|
168
177
|
},
|
|
@@ -199,6 +208,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
199
208
|
'.border-feedback-success-low': {
|
|
200
209
|
'border-color': 'var(--color-feedback-success-low-border)'
|
|
201
210
|
},
|
|
211
|
+
'.border-feedback-success-low-subtle': {
|
|
212
|
+
'border-color': 'var(--color-feedback-success-low-border-subtle)'
|
|
213
|
+
},
|
|
202
214
|
'.icon-feedback-success-low': {
|
|
203
215
|
'color': 'var(--color-feedback-success-low-icon)'
|
|
204
216
|
},
|
|
@@ -235,6 +247,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
235
247
|
'.border-feedback-warning-low': {
|
|
236
248
|
'border-color': 'var(--color-feedback-warning-low-border)'
|
|
237
249
|
},
|
|
250
|
+
'.border-feedback-warning-low-subtle': {
|
|
251
|
+
'border-color': 'var(--color-feedback-warning-low-border-subtle)'
|
|
252
|
+
},
|
|
238
253
|
'.icon-feedback-warning-low': {
|
|
239
254
|
'color': 'var(--color-feedback-warning-low-icon)'
|
|
240
255
|
},
|
|
@@ -475,6 +490,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
475
490
|
'.border-rainbow-1': {
|
|
476
491
|
'border-color': 'var(--color-rainbow-1-border)'
|
|
477
492
|
},
|
|
493
|
+
'.border-rainbow-1-light': {
|
|
494
|
+
'border-color': 'var(--color-rainbow-1-border-light)'
|
|
495
|
+
},
|
|
478
496
|
'.icon-rainbow-1': {
|
|
479
497
|
'color': 'var(--color-rainbow-1-icon)'
|
|
480
498
|
},
|
|
@@ -487,6 +505,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
487
505
|
'.border-rainbow-10': {
|
|
488
506
|
'border-color': 'var(--color-rainbow-10-border)'
|
|
489
507
|
},
|
|
508
|
+
'.border-rainbow-10-light': {
|
|
509
|
+
'border-color': 'var(--color-rainbow-10-border-light)'
|
|
510
|
+
},
|
|
490
511
|
'.icon-rainbow-10': {
|
|
491
512
|
'color': 'var(--color-rainbow-10-icon)'
|
|
492
513
|
},
|
|
@@ -499,6 +520,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
499
520
|
'.border-rainbow-2': {
|
|
500
521
|
'border-color': 'var(--color-rainbow-2-border)'
|
|
501
522
|
},
|
|
523
|
+
'.border-rainbow-2-light': {
|
|
524
|
+
'border-color': 'var(--color-rainbow-2-border-light)'
|
|
525
|
+
},
|
|
502
526
|
'.icon-rainbow-2': {
|
|
503
527
|
'color': 'var(--color-rainbow-2-icon)'
|
|
504
528
|
},
|
|
@@ -511,6 +535,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
511
535
|
'.border-rainbow-3': {
|
|
512
536
|
'border-color': 'var(--color-rainbow-3-border)'
|
|
513
537
|
},
|
|
538
|
+
'.border-rainbow-3-light': {
|
|
539
|
+
'border-color': 'var(--color-rainbow-3-border-light)'
|
|
540
|
+
},
|
|
514
541
|
'.icon-rainbow-3': {
|
|
515
542
|
'color': 'var(--color-rainbow-3-icon)'
|
|
516
543
|
},
|
|
@@ -523,6 +550,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
523
550
|
'.border-rainbow-4': {
|
|
524
551
|
'border-color': 'var(--color-rainbow-4-border)'
|
|
525
552
|
},
|
|
553
|
+
'.border-rainbow-4-light': {
|
|
554
|
+
'border-color': 'var(--color-rainbow-4-border-light)'
|
|
555
|
+
},
|
|
526
556
|
'.icon-rainbow-4': {
|
|
527
557
|
'color': 'var(--color-rainbow-4-icon)'
|
|
528
558
|
},
|
|
@@ -535,6 +565,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
535
565
|
'.border-rainbow-5': {
|
|
536
566
|
'border-color': 'var(--color-rainbow-5-border)'
|
|
537
567
|
},
|
|
568
|
+
'.border-rainbow-5-light': {
|
|
569
|
+
'border-color': 'var(--color-rainbow-5-border-light)'
|
|
570
|
+
},
|
|
538
571
|
'.icon-rainbow-5': {
|
|
539
572
|
'color': 'var(--color-rainbow-5-icon)'
|
|
540
573
|
},
|
|
@@ -547,6 +580,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
547
580
|
'.border-rainbow-6': {
|
|
548
581
|
'border-color': 'var(--color-rainbow-6-border)'
|
|
549
582
|
},
|
|
583
|
+
'.border-rainbow-6-light': {
|
|
584
|
+
'border-color': 'var(--color-rainbow-6-border-light)'
|
|
585
|
+
},
|
|
550
586
|
'.icon-rainbow-6': {
|
|
551
587
|
'color': 'var(--color-rainbow-6-icon)'
|
|
552
588
|
},
|
|
@@ -559,6 +595,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
559
595
|
'.border-rainbow-7': {
|
|
560
596
|
'border-color': 'var(--color-rainbow-7-border)'
|
|
561
597
|
},
|
|
598
|
+
'.border-rainbow-7-light': {
|
|
599
|
+
'border-color': 'var(--color-rainbow-7-border-light)'
|
|
600
|
+
},
|
|
562
601
|
'.icon-rainbow-7': {
|
|
563
602
|
'color': 'var(--color-rainbow-7-icon)'
|
|
564
603
|
},
|
|
@@ -571,6 +610,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
571
610
|
'.border-rainbow-8': {
|
|
572
611
|
'border-color': 'var(--color-rainbow-8-border)'
|
|
573
612
|
},
|
|
613
|
+
'.border-rainbow-8-light': {
|
|
614
|
+
'border-color': 'var(--color-rainbow-8-border-light)'
|
|
615
|
+
},
|
|
574
616
|
'.icon-rainbow-8': {
|
|
575
617
|
'color': 'var(--color-rainbow-8-icon)'
|
|
576
618
|
},
|
|
@@ -583,6 +625,9 @@ exports.NOVA_TAILWIND_TOKENS = {
|
|
|
583
625
|
'.border-rainbow-9': {
|
|
584
626
|
'border-color': 'var(--color-rainbow-9-border)'
|
|
585
627
|
},
|
|
628
|
+
'.border-rainbow-9-light': {
|
|
629
|
+
'border-color': 'var(--color-rainbow-9-border-light)'
|
|
630
|
+
},
|
|
586
631
|
'.icon-rainbow-9': {
|
|
587
632
|
'color': 'var(--color-rainbow-9-icon)'
|
|
588
633
|
},
|
package/dist/cjs/plugin/index.js
CHANGED
|
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./nova-plugin.js"), exports);
|
|
18
|
-
__exportStar(require("./nova-safelist.js"), exports);
|
|
19
18
|
__exportStar(require("./nova-theme.js"), exports);
|
|
@@ -21,6 +21,7 @@ exports.novaTailwindPlugin = void 0;
|
|
|
21
21
|
var plugin_js_1 = __importDefault(require("tailwindcss/plugin.js"));
|
|
22
22
|
var nova_tailwind_tokens_js_1 = require("../generated/nova-tailwind-tokens.js");
|
|
23
23
|
var nova_tailwind_components_js_1 = require("../generated/nova-tailwind-components.js");
|
|
24
|
+
var typography_js_1 = require("./typography.js");
|
|
24
25
|
exports.novaTailwindPlugin = (0, plugin_js_1.default)(function (_a) {
|
|
25
26
|
var addUtilities = _a.addUtilities, addComponents = _a.addComponents, addBase = _a.addBase, theme = _a.theme;
|
|
26
27
|
addBase(__assign({ 'body, html': {
|
|
@@ -73,105 +74,6 @@ exports.novaTailwindPlugin = (0, plugin_js_1.default)(function (_a) {
|
|
|
73
74
|
}, {});
|
|
74
75
|
})()));
|
|
75
76
|
addComponents(__assign({}, nova_tailwind_components_js_1.NOVA_TAILWIND_COMPONENTS));
|
|
76
|
-
// Typography configuration for programmatic utility generation
|
|
77
|
-
var typographyConfig = {
|
|
78
|
-
heading: {
|
|
79
|
-
xl: {
|
|
80
|
-
size: '4xl',
|
|
81
|
-
lineHeight: 'leading-px-10',
|
|
82
|
-
letterSpacing: 'heading-xl',
|
|
83
|
-
},
|
|
84
|
-
lg: {
|
|
85
|
-
size: '3xl',
|
|
86
|
-
lineHeight: 'leading-px-8',
|
|
87
|
-
letterSpacing: 'heading-lg',
|
|
88
|
-
},
|
|
89
|
-
md: {
|
|
90
|
-
size: '2xl',
|
|
91
|
-
lineHeight: 'leading-px-7',
|
|
92
|
-
letterSpacing: 'heading-md',
|
|
93
|
-
},
|
|
94
|
-
sm: {
|
|
95
|
-
size: 'xl',
|
|
96
|
-
lineHeight: 'leading-px-6',
|
|
97
|
-
letterSpacing: 'heading-sm',
|
|
98
|
-
},
|
|
99
|
-
xs: {
|
|
100
|
-
size: 'lg',
|
|
101
|
-
lineHeight: 'leading-px-6',
|
|
102
|
-
letterSpacing: 'heading-xs',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
text: {
|
|
106
|
-
xl: {
|
|
107
|
-
size: 'xl',
|
|
108
|
-
lineHeight: 'xl',
|
|
109
|
-
},
|
|
110
|
-
lg: {
|
|
111
|
-
size: 'lg',
|
|
112
|
-
lineHeight: 'lg',
|
|
113
|
-
},
|
|
114
|
-
md: {
|
|
115
|
-
size: 'md',
|
|
116
|
-
lineHeight: 'base',
|
|
117
|
-
},
|
|
118
|
-
sm: {
|
|
119
|
-
size: 'sm',
|
|
120
|
-
lineHeight: 'sm',
|
|
121
|
-
},
|
|
122
|
-
xs: {
|
|
123
|
-
size: 'xs',
|
|
124
|
-
lineHeight: 'xs',
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
mono: {
|
|
128
|
-
md: {
|
|
129
|
-
size: 'md',
|
|
130
|
-
lineHeight: 'base',
|
|
131
|
-
},
|
|
132
|
-
sm: {
|
|
133
|
-
size: 'sm',
|
|
134
|
-
lineHeight: 'sm',
|
|
135
|
-
},
|
|
136
|
-
xs: {
|
|
137
|
-
size: 'xs',
|
|
138
|
-
lineHeight: 'xs',
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
var weights = ['regular', 'medium', 'bold'];
|
|
143
|
-
var weightMap = {
|
|
144
|
-
regular: 'low-emphasis',
|
|
145
|
-
medium: 'medium-emphasis',
|
|
146
|
-
bold: 'high-emphasis',
|
|
147
|
-
};
|
|
148
|
-
// Generate typography utilities programmatically
|
|
149
|
-
var typographyUtilities = {};
|
|
150
|
-
Object.entries(typographyConfig).forEach(function (_a) {
|
|
151
|
-
var type = _a[0], sizes = _a[1];
|
|
152
|
-
Object.entries(sizes).forEach(function (_a) {
|
|
153
|
-
var size = _a[0], config = _a[1];
|
|
154
|
-
weights.forEach(function (weight) {
|
|
155
|
-
var className = ".typo-".concat(type, "-").concat(size, "-").concat(weight);
|
|
156
|
-
var baseStyles = {
|
|
157
|
-
'font-size': "var(--font-size-".concat(config.size, ")"),
|
|
158
|
-
'font-weight': "var(--font-weight-".concat(weightMap[weight], ")"),
|
|
159
|
-
'line-height': "var(--".concat(config.lineHeight.startsWith('leading-')
|
|
160
|
-
? config.lineHeight
|
|
161
|
-
: "line-height-".concat(config.lineHeight), ")"),
|
|
162
|
-
};
|
|
163
|
-
// Add letter-spacing for headings
|
|
164
|
-
if (type === 'heading' && 'letterSpacing' in config) {
|
|
165
|
-
baseStyles['letter-spacing'] = "var(--letter-spacing-".concat(config.letterSpacing, ")");
|
|
166
|
-
}
|
|
167
|
-
// Add font-family for mono
|
|
168
|
-
if (type === 'mono') {
|
|
169
|
-
baseStyles['font-family'] = 'var(--font-family-mono), monospace';
|
|
170
|
-
}
|
|
171
|
-
typographyUtilities[className] = baseStyles;
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
77
|
addUtilities(__assign(__assign(__assign({}, nova_tailwind_tokens_js_1.NOVA_TAILWIND_TOKENS), { '.w-inherit': {
|
|
176
78
|
width: 'inherit',
|
|
177
79
|
}, '.w-initial': {
|
|
@@ -184,6 +86,6 @@ exports.novaTailwindPlugin = (0, plugin_js_1.default)(function (_a) {
|
|
|
184
86
|
width: 'revert',
|
|
185
87
|
}, '.w-unset': {
|
|
186
88
|
width: 'unset',
|
|
187
|
-
} }),
|
|
89
|
+
} }), (0, typography_js_1.getTypographyUtilities)()));
|
|
188
90
|
});
|
|
189
91
|
exports.default = exports.novaTailwindPlugin;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Shared source of truth for the `.typo-{type}-{size}-{weight}`
|
|
4
|
+
* utility classes. Consumed by the Tailwind plugin (runtime utilities), the
|
|
5
|
+
* `@source inline()` generator (CSS safelisting), and the LLM extractor
|
|
6
|
+
* (structured JSON for AI consumers).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getTypographyTokenEntries = exports.getTypographyClassNames = exports.getTypographyUtilities = exports.TYPOGRAPHY_CONFIG = exports.TYPOGRAPHY_WEIGHT_MAP = exports.TYPOGRAPHY_WEIGHTS = void 0;
|
|
10
|
+
exports.TYPOGRAPHY_WEIGHTS = ['regular', 'medium', 'bold'];
|
|
11
|
+
exports.TYPOGRAPHY_WEIGHT_MAP = {
|
|
12
|
+
regular: 'low-emphasis',
|
|
13
|
+
medium: 'medium-emphasis',
|
|
14
|
+
bold: 'high-emphasis',
|
|
15
|
+
};
|
|
16
|
+
exports.TYPOGRAPHY_CONFIG = {
|
|
17
|
+
heading: {
|
|
18
|
+
xl: {
|
|
19
|
+
size: '4xl',
|
|
20
|
+
lineHeight: 'leading-px-10',
|
|
21
|
+
letterSpacing: 'heading-xl',
|
|
22
|
+
},
|
|
23
|
+
lg: {
|
|
24
|
+
size: '3xl',
|
|
25
|
+
lineHeight: 'leading-px-8',
|
|
26
|
+
letterSpacing: 'heading-lg',
|
|
27
|
+
},
|
|
28
|
+
md: {
|
|
29
|
+
size: '2xl',
|
|
30
|
+
lineHeight: 'leading-px-7',
|
|
31
|
+
letterSpacing: 'heading-md',
|
|
32
|
+
},
|
|
33
|
+
sm: { size: 'xl', lineHeight: 'leading-px-6', letterSpacing: 'heading-sm' },
|
|
34
|
+
xs: { size: 'lg', lineHeight: 'leading-px-6', letterSpacing: 'heading-xs' },
|
|
35
|
+
},
|
|
36
|
+
text: {
|
|
37
|
+
xl: { size: 'xl', lineHeight: 'xl' },
|
|
38
|
+
lg: { size: 'lg', lineHeight: 'lg' },
|
|
39
|
+
md: { size: 'md', lineHeight: 'base' },
|
|
40
|
+
sm: { size: 'sm', lineHeight: 'sm' },
|
|
41
|
+
xs: { size: 'xs', lineHeight: 'xs' },
|
|
42
|
+
},
|
|
43
|
+
mono: {
|
|
44
|
+
md: { size: 'md', lineHeight: 'base' },
|
|
45
|
+
sm: { size: 'sm', lineHeight: 'sm' },
|
|
46
|
+
xs: { size: 'xs', lineHeight: 'xs' },
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Resolves a line-height config value to its CSS custom-property name.
|
|
51
|
+
* @param {string} lineHeight - Raw token value (either a `leading-*` utility name or a size suffix).
|
|
52
|
+
* @returns {string} CSS custom-property name including the leading `--`.
|
|
53
|
+
*/
|
|
54
|
+
function resolveLineHeightVar(lineHeight) {
|
|
55
|
+
return lineHeight.startsWith('leading-')
|
|
56
|
+
? "--".concat(lineHeight)
|
|
57
|
+
: "--line-height-".concat(lineHeight);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Expands `TYPOGRAPHY_CONFIG` into the flat list of typography utility entries,
|
|
61
|
+
* one per type × size × weight combination.
|
|
62
|
+
* @returns {TypographyTokenEntry[]} Array of structured typography entries.
|
|
63
|
+
*/
|
|
64
|
+
function buildTypographyEntries() {
|
|
65
|
+
var entries = [];
|
|
66
|
+
Object.entries(exports.TYPOGRAPHY_CONFIG).forEach(function (_a) {
|
|
67
|
+
var type = _a[0], sizes = _a[1];
|
|
68
|
+
Object.entries(sizes).forEach(function (_a) {
|
|
69
|
+
var size = _a[0], config = _a[1];
|
|
70
|
+
exports.TYPOGRAPHY_WEIGHTS.forEach(function (weight) {
|
|
71
|
+
var tokens = {
|
|
72
|
+
fontSize: "--font-size-".concat(config.size),
|
|
73
|
+
fontWeight: "--font-weight-".concat(exports.TYPOGRAPHY_WEIGHT_MAP[weight]),
|
|
74
|
+
lineHeight: resolveLineHeightVar(config.lineHeight),
|
|
75
|
+
};
|
|
76
|
+
if (type === 'heading' && 'letterSpacing' in config) {
|
|
77
|
+
tokens.letterSpacing = "--letter-spacing-".concat(config.letterSpacing);
|
|
78
|
+
}
|
|
79
|
+
if (type === 'mono') {
|
|
80
|
+
tokens.fontFamily = '--font-family-mono';
|
|
81
|
+
}
|
|
82
|
+
entries.push({
|
|
83
|
+
className: "typo-".concat(type, "-").concat(size, "-").concat(weight),
|
|
84
|
+
type: type,
|
|
85
|
+
size: size,
|
|
86
|
+
weight: weight,
|
|
87
|
+
tokens: tokens,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return entries;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns the `{ '.typo-...': { 'font-size': 'var(--...)', ... } }` map
|
|
96
|
+
* consumed by Tailwind's `addUtilities`.
|
|
97
|
+
* @returns {Record<string, Record<string, string>>} Map from utility class selector to CSS declaration block.
|
|
98
|
+
*/
|
|
99
|
+
function getTypographyUtilities() {
|
|
100
|
+
var utilities = {};
|
|
101
|
+
buildTypographyEntries().forEach(function (entry) {
|
|
102
|
+
var styles = {
|
|
103
|
+
'font-size': "var(".concat(entry.tokens.fontSize, ")"),
|
|
104
|
+
'font-weight': "var(".concat(entry.tokens.fontWeight, ")"),
|
|
105
|
+
'line-height': "var(".concat(entry.tokens.lineHeight, ")"),
|
|
106
|
+
};
|
|
107
|
+
if (entry.tokens.letterSpacing) {
|
|
108
|
+
styles['letter-spacing'] = "var(".concat(entry.tokens.letterSpacing, ")");
|
|
109
|
+
}
|
|
110
|
+
if (entry.tokens.fontFamily) {
|
|
111
|
+
styles['font-family'] = "var(".concat(entry.tokens.fontFamily, "), monospace");
|
|
112
|
+
}
|
|
113
|
+
utilities[".".concat(entry.className)] = styles;
|
|
114
|
+
});
|
|
115
|
+
return utilities;
|
|
116
|
+
}
|
|
117
|
+
exports.getTypographyUtilities = getTypographyUtilities;
|
|
118
|
+
/**
|
|
119
|
+
* Returns the typography class names without the leading `.`, suitable for
|
|
120
|
+
* Tailwind v4 `@source inline()` directives.
|
|
121
|
+
* @returns {string[]} List of utility class names.
|
|
122
|
+
*/
|
|
123
|
+
function getTypographyClassNames() {
|
|
124
|
+
return buildTypographyEntries().map(function (entry) { return entry.className; });
|
|
125
|
+
}
|
|
126
|
+
exports.getTypographyClassNames = getTypographyClassNames;
|
|
127
|
+
/**
|
|
128
|
+
* Returns structured, JSON-friendly typography token entries for LLM and
|
|
129
|
+
* documentation consumers.
|
|
130
|
+
* @returns {TypographyTokenEntry[]} Array of structured typography entries.
|
|
131
|
+
*/
|
|
132
|
+
function getTypographyTokenEntries() {
|
|
133
|
+
return buildTypographyEntries();
|
|
134
|
+
}
|
|
135
|
+
exports.getTypographyTokenEntries = getTypographyTokenEntries;
|