@10up/block-renderer-theme-json 0.1.4

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.
@@ -0,0 +1,212 @@
1
+ export const minimalThemeJson = {
2
+ version: 3,
3
+ settings: {},
4
+ styles: {},
5
+ };
6
+ export const fullThemeJson = {
7
+ version: 3,
8
+ $schema: 'https://schemas.wp.org/trunk/theme.json',
9
+ settings: {
10
+ color: {
11
+ palette: [
12
+ { slug: 'primary', color: '#0073aa', name: 'Primary' },
13
+ { slug: 'secondary', color: '#23282d', name: 'Secondary' },
14
+ { slug: 'accent', color: '#00a0d2', name: 'Accent' },
15
+ { slug: 'contrast', color: '#ffffff', name: 'Contrast' },
16
+ { slug: 'base', color: '#1e1e1e', name: 'Base' },
17
+ ],
18
+ gradients: [
19
+ {
20
+ slug: 'primary-to-accent',
21
+ gradient: 'linear-gradient(135deg, #0073aa 0%, #00a0d2 100%)',
22
+ name: 'Primary to Accent',
23
+ },
24
+ {
25
+ slug: 'vertical-secondary',
26
+ gradient: 'linear-gradient(to bottom, #23282d 0%, #1e1e1e 100%)',
27
+ name: 'Vertical Secondary',
28
+ },
29
+ ],
30
+ duotone: [
31
+ {
32
+ slug: 'dark-grayscale',
33
+ colors: ['#000000', '#ffffff'],
34
+ name: 'Dark Grayscale',
35
+ },
36
+ {
37
+ slug: 'primary-contrast',
38
+ colors: ['#0073aa', '#ffffff'],
39
+ name: 'Primary Contrast',
40
+ },
41
+ ],
42
+ },
43
+ typography: {
44
+ fontFamilies: [
45
+ {
46
+ slug: 'system-sans',
47
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
48
+ name: 'System Sans',
49
+ },
50
+ {
51
+ slug: 'heading',
52
+ fontFamily: '"Playfair Display", Georgia, serif',
53
+ name: 'Heading',
54
+ },
55
+ {
56
+ slug: 'body',
57
+ fontFamily: '"Open Sans", sans-serif',
58
+ name: 'Body',
59
+ },
60
+ ],
61
+ fontSizes: [
62
+ { slug: 'small', size: '0.875rem', name: 'Small' },
63
+ { slug: 'medium', size: '1rem', name: 'Medium' },
64
+ { slug: 'large', size: '1.25rem', name: 'Large' },
65
+ { slug: 'x-large', size: '1.5rem', name: 'Extra Large' },
66
+ { slug: 'xx-large', size: '2rem', name: 'Huge' },
67
+ ],
68
+ },
69
+ spacing: {
70
+ spacingSizes: [
71
+ { slug: '20', size: '0.5rem', name: 'Extra Small' },
72
+ { slug: '30', size: '0.75rem', name: 'Small' },
73
+ { slug: '40', size: '1rem', name: 'Medium' },
74
+ { slug: '50', size: '1.5rem', name: 'Large' },
75
+ { slug: '60', size: '2rem', name: 'Extra Large' },
76
+ { slug: '70', size: '3rem', name: 'Huge' },
77
+ { slug: '80', size: '4rem', name: 'Giant' },
78
+ ],
79
+ units: ['px', 'em', 'rem', '%', 'vw', 'vh'],
80
+ },
81
+ shadow: {
82
+ presets: [
83
+ {
84
+ slug: 'natural',
85
+ shadow: '0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24)',
86
+ name: 'Natural',
87
+ },
88
+ {
89
+ slug: 'deep',
90
+ shadow: '0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22)',
91
+ name: 'Deep',
92
+ },
93
+ {
94
+ slug: 'sharp',
95
+ shadow: '0 4px 6px rgba(0, 0, 0, 0.3)',
96
+ name: 'Sharp',
97
+ },
98
+ ],
99
+ },
100
+ layout: {
101
+ contentSize: '800px',
102
+ wideSize: '1200px',
103
+ },
104
+ custom: {
105
+ lineHeight: {
106
+ tight: '1.2',
107
+ normal: '1.6',
108
+ loose: '1.8',
109
+ },
110
+ borderRadius: {
111
+ small: '4px',
112
+ medium: '8px',
113
+ large: '16px',
114
+ },
115
+ },
116
+ },
117
+ styles: {
118
+ color: {
119
+ background: 'var(--wp--preset--color--base)',
120
+ text: 'var(--wp--preset--color--contrast)',
121
+ },
122
+ typography: {
123
+ fontFamily: 'var(--wp--preset--font-family--body)',
124
+ fontSize: 'var(--wp--preset--font-size--medium)',
125
+ lineHeight: '1.6',
126
+ },
127
+ spacing: {
128
+ blockGap: 'var(--wp--preset--spacing--40)',
129
+ padding: {
130
+ top: 'var(--wp--preset--spacing--50)',
131
+ right: 'var(--wp--preset--spacing--50)',
132
+ bottom: 'var(--wp--preset--spacing--50)',
133
+ left: 'var(--wp--preset--spacing--50)',
134
+ },
135
+ },
136
+ elements: {
137
+ heading: {
138
+ color: {
139
+ text: 'var(--wp--preset--color--primary)',
140
+ },
141
+ typography: {
142
+ fontFamily: 'var(--wp--preset--font-family--heading)',
143
+ fontWeight: '700',
144
+ },
145
+ },
146
+ link: {
147
+ color: {
148
+ text: 'var(--wp--preset--color--accent)',
149
+ },
150
+ },
151
+ button: {
152
+ color: {
153
+ background: 'var(--wp--preset--color--primary)',
154
+ text: 'var(--wp--preset--color--contrast)',
155
+ },
156
+ border: {
157
+ radius: '4px',
158
+ },
159
+ },
160
+ },
161
+ blocks: {
162
+ 'core/paragraph': {
163
+ spacing: {
164
+ margin: {
165
+ bottom: 'var(--wp--preset--spacing--40)',
166
+ },
167
+ },
168
+ },
169
+ 'core/heading': {
170
+ spacing: {
171
+ margin: {
172
+ top: 'var(--wp--preset--spacing--50)',
173
+ bottom: 'var(--wp--preset--spacing--30)',
174
+ },
175
+ },
176
+ },
177
+ 'core/group': {
178
+ spacing: {
179
+ padding: {
180
+ top: 'var(--wp--preset--spacing--50)',
181
+ bottom: 'var(--wp--preset--spacing--50)',
182
+ },
183
+ },
184
+ },
185
+ },
186
+ },
187
+ };
188
+ export const emptySettingsThemeJson = {
189
+ version: 2,
190
+ styles: {
191
+ color: {
192
+ background: '#ffffff',
193
+ text: '#000000',
194
+ },
195
+ },
196
+ };
197
+ export const partialThemeJson = {
198
+ version: 3,
199
+ settings: {
200
+ color: {
201
+ palette: [
202
+ { slug: 'primary', color: '#0000ff', name: 'Primary' },
203
+ ],
204
+ },
205
+ typography: {
206
+ fontSizes: [
207
+ { slug: 'normal', size: '16px', name: 'Normal' },
208
+ ],
209
+ },
210
+ },
211
+ };
212
+ //# sourceMappingURL=theme-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-json.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/theme-json.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,yCAAyC;IAClD,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;gBACtD,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;gBAC1D,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACpD,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE;gBACxD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE;aACjD;YACD,SAAS,EAAE;gBACT;oBACE,IAAI,EAAE,mBAAmB;oBACzB,QAAQ,EAAE,mDAAmD;oBAC7D,IAAI,EAAE,mBAAmB;iBAC1B;gBACD;oBACE,IAAI,EAAE,oBAAoB;oBAC1B,QAAQ,EAAE,sDAAsD;oBAChE,IAAI,EAAE,oBAAoB;iBAC3B;aACF;YACD,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,gBAAgB;oBACtB,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;oBAC9B,IAAI,EAAE,gB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O,EAAE;gBACP,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;aACvD;SACF;QACD,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;aACjD;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { SectionStyle } from './types.js';
2
+ /**
3
+ * Convert block type to CSS class selector
4
+ * e.g., core/group -> .wp-block-group, tenup/tabs -> .wp-block-tenup-tabs
5
+ */
6
+ export declare function blockTypeToSelector(blockType: string): string;
7
+ /**
8
+ * Flatten nested object to CSS custom properties
9
+ * { color: { button: { bg: "red" } } } -> { "--wp--custom--color--button--bg": "red" }
10
+ */
11
+ export declare function flattenCustomToProperties(obj: Record<string, unknown>, prefix?: string): Record<string, string>;
12
+ /**
13
+ * Generate CSS for a single section style
14
+ */
15
+ export declare function generateSectionStyleCss(sectionStyle: SectionStyle): string;
16
+ /**
17
+ * Generate CSS for all section styles
18
+ */
19
+ export declare function generateAllSectionStylesCss(sectionStyles: SectionStyle[]): string;
20
+ //# sourceMappingURL=css-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-generator.d.ts","sourceRoot":"","sources":["../src/css-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,YAAY,CAAC;AAS5D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS7D;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,MAAM,SAAiB,GACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBxB;AAwID;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAwD1E;AAsBD;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,MAAM,CAKjF"}
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Convert camelCase to kebab-case
3
+ */
4
+ function toKebabCase(str) {
5
+ return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
6
+ }
7
+ /**
8
+ * Convert block type to CSS class selector
9
+ * e.g., core/group -> .wp-block-group, tenup/tabs -> .wp-block-tenup-tabs
10
+ */
11
+ export function blockTypeToSelector(blockType) {
12
+ // Replace namespace separator with dash and add wp-block- prefix
13
+ const className = blockType.replace('/', '-');
14
+ // For core blocks: core-group -> wp-block-group
15
+ // For other blocks: tenup-tabs -> wp-block-tenup-tabs
16
+ if (className.startsWith('core-')) {
17
+ return `.wp-block-${className.slice(5)}`;
18
+ }
19
+ return `.wp-block-${className}`;
20
+ }
21
+ /**
22
+ * Flatten nested object to CSS custom properties
23
+ * { color: { button: { bg: "red" } } } -> { "--wp--custom--color--button--bg": "red" }
24
+ */
25
+ export function flattenCustomToProperties(obj, prefix = '--wp--custom') {
26
+ const result = {};
27
+ function recurse(current, path) {
28
+ if (typeof current === 'string') {
29
+ result[path] = current;
30
+ }
31
+ else if (typeof current === 'number') {
32
+ result[path] = String(current);
33
+ }
34
+ else if (typeof current === 'object' && current !== null) {
35
+ for (const [key, value] of Object.entries(current)) {
36
+ recurse(value, `${path}--${toKebabCase(key)}`);
37
+ }
38
+ }
39
+ }
40
+ recurse(obj, prefix);
41
+ return result;
42
+ }
43
+ /**
44
+ * Convert StyleObject to CSS property declarations
45
+ */
46
+ function styleObjectToCssProperties(style) {
47
+ const props = {};
48
+ // Color properties
49
+ if (style.color?.background) {
50
+ props['background-color'] = style.color.background;
51
+ }
52
+ if (style.color?.text) {
53
+ props['color'] = style.color.text;
54
+ }
55
+ if (style.color?.gradient) {
56
+ props['background'] = style.color.gradient;
57
+ }
58
+ // Typography properties
59
+ if (style.typography?.fontFamily) {
60
+ props['font-family'] = style.typography.fontFamily;
61
+ }
62
+ if (style.typography?.fontSize) {
63
+ props['font-size'] = style.typography.fontSize;
64
+ }
65
+ if (style.typography?.fontStyle) {
66
+ props['font-style'] = style.typography.fontStyle;
67
+ }
68
+ if (style.typography?.fontWeight) {
69
+ props['font-weight'] = style.typography.fontWeight;
70
+ }
71
+ if (style.typography?.lineHeight) {
72
+ props['line-height'] = style.typography.lineHeight;
73
+ }
74
+ if (style.typography?.textDecoration) {
75
+ props['text-decoration'] = style.typography.textDecoration;
76
+ }
77
+ if (style.typography?.textTransform) {
78
+ props['text-transform'] = style.typography.textTransform;
79
+ }
80
+ if (style.typography?.letterSpacing) {
81
+ props['letter-spacing'] = style.typography.letterSpacing;
82
+ }
83
+ // Spacing properties
84
+ if (style.spacing?.padding) {
85
+ if (typeof style.spacing.padding === 'string') {
86
+ props['padding'] = style.spacing.padding;
87
+ }
88
+ else {
89
+ if (style.spacing.padding.top)
90
+ props['padding-top'] = style.spacing.padding.top;
91
+ if (style.spacing.padding.right)
92
+ props['padding-right'] = style.spacing.padding.right;
93
+ if (style.spacing.padding.bottom)
94
+ props['padding-bottom'] = style.spacing.padding.bottom;
95
+ if (style.spacing.padding.left)
96
+ props['padding-left'] = style.spacing.padding.left;
97
+ }
98
+ }
99
+ if (style.spacing?.margin) {
100
+ if (typeof style.spacing.margin === 'string') {
101
+ props['margin'] = style.spacing.margin;
102
+ }
103
+ else {
104
+ if (style.spacing.margin.top)
105
+ props['margin-top'] = style.spacing.margin.top;
106
+ if (style.spacing.margin.right)
107
+ props['margin-right'] = style.spacing.margin.right;
108
+ if (style.spacing.margin.bottom)
109
+ props['margin-bottom'] = style.spacing.margin.bottom;
110
+ if (style.spacing.margin.left)
111
+ props['margin-left'] = style.spacing.margin.left;
112
+ }
113
+ }
114
+ if (style.spacing?.blockGap) {
115
+ props['gap'] = style.spacing.blockGap;
116
+ }
117
+ // Border properties
118
+ if (style.border?.color) {
119
+ props['border-color'] = style.border.color;
120
+ }
121
+ if (style.border?.style) {
122
+ props['border-style'] = style.border.style;
123
+ }
124
+ if (style.border?.width) {
125
+ props['border-width'] = style.border.width;
126
+ }
127
+ if (style.border?.radius) {
128
+ if (typeof style.border.radius === 'string') {
129
+ props['border-radius'] = style.border.radius;
130
+ }
131
+ else {
132
+ if (style.border.radius.top)
133
+ props['border-top-left-radius'] = style.border.radius.top;
134
+ if (style.border.radius.right)
135
+ props['border-top-right-radius'] = style.border.radius.right;
136
+ if (style.border.radius.bottom)
137
+ props['border-bottom-right-radius'] = style.border.radius.bottom;
138
+ if (style.border.radius.left)
139
+ props['border-bottom-left-radius'] = style.border.radius.left;
140
+ }
141
+ }
142
+ // Shadow
143
+ if (style.shadow) {
144
+ props['box-shadow'] = style.shadow;
145
+ }
146
+ // Outline
147
+ if (style.outline?.color) {
148
+ props['outline-color'] = style.outline.color;
149
+ }
150
+ if (style.outline?.style) {
151
+ props['outline-style'] = style.outline.style;
152
+ }
153
+ if (style.outline?.width) {
154
+ props['outline-width'] = style.outline.width;
155
+ }
156
+ if (style.outline?.offset) {
157
+ props['outline-offset'] = style.outline.offset;
158
+ }
159
+ // Dimensions
160
+ if (style.dimensions?.minHeight) {
161
+ props['min-height'] = style.dimensions.minHeight;
162
+ }
163
+ if (style.dimensions?.aspectRatio) {
164
+ props['aspect-ratio'] = style.dimensions.aspectRatio;
165
+ }
166
+ return props;
167
+ }
168
+ /**
169
+ * Generate CSS rule block from selector and properties
170
+ */
171
+ function generateCssRule(selector, properties) {
172
+ const entries = Object.entries(properties);
173
+ if (entries.length === 0)
174
+ return '';
175
+ const lines = [`${selector} {`];
176
+ for (const [prop, value] of entries) {
177
+ lines.push(` ${prop}: ${value};`);
178
+ }
179
+ lines.push('}');
180
+ return lines.join('\n');
181
+ }
182
+ /**
183
+ * Generate CSS for a single section style
184
+ */
185
+ export function generateSectionStyleCss(sectionStyle) {
186
+ const rules = [];
187
+ // Build main selector: :is(.wp-block-group, .wp-block-columns).is-style-{slug}
188
+ const blockSelectors = sectionStyle.blockTypes.map(blockTypeToSelector).join(', ');
189
+ const mainSelector = `:is(${blockSelectors}).is-style-${sectionStyle.slug}`;
190
+ // Collect all properties for main rule
191
+ const mainProps = {};
192
+ // Add custom properties from settings.custom
193
+ if (sectionStyle.customSettings) {
194
+ const customProps = flattenCustomToProperties(sectionStyle.customSettings);
195
+ Object.assign(mainProps, customProps);
196
+ }
197
+ // Add styles from global styles section
198
+ if (sectionStyle.styles.global) {
199
+ const styleProps = styleObjectToCssProperties(sectionStyle.styles.global);
200
+ Object.assign(mainProps, styleProps);
201
+ }
202
+ // Generate main rule
203
+ const mainRule = generateCssRule(mainSelector, mainProps);
204
+ if (mainRule) {
205
+ rules.push(mainRule);
206
+ }
207
+ // Generate element rules (e.g., link, heading styles)
208
+ if (sectionStyle.styles.elements) {
209
+ for (const [element, elementStyle] of Object.entries(sectionStyle.styles.elements)) {
210
+ const elementSelector = getElementSelector(element);
211
+ if (!elementSelector)
212
+ continue;
213
+ const fullSelector = `${mainSelector} ${elementSelector}`;
214
+ const elementProps = styleObjectToCssProperties(elementStyle);
215
+ const elementRule = generateCssRule(fullSelector, elementProps);
216
+ if (elementRule) {
217
+ rules.push(elementRule);
218
+ }
219
+ // Handle pseudo-states like :hover, :focus
220
+ for (const [key, value] of Object.entries(elementStyle)) {
221
+ if (key.startsWith(':') && typeof value === 'object' && value !== null) {
222
+ const pseudoSelector = `${fullSelector}${key}`;
223
+ const pseudoProps = styleObjectToCssProperties(value);
224
+ const pseudoRule = generateCssRule(pseudoSelector, pseudoProps);
225
+ if (pseudoRule) {
226
+ rules.push(pseudoRule);
227
+ }
228
+ }
229
+ }
230
+ }
231
+ }
232
+ return rules.join('\n\n');
233
+ }
234
+ /**
235
+ * Map WordPress element names to CSS selectors
236
+ */
237
+ function getElementSelector(element) {
238
+ const elementMap = {
239
+ link: 'a',
240
+ h1: 'h1',
241
+ h2: 'h2',
242
+ h3: 'h3',
243
+ h4: 'h4',
244
+ h5: 'h5',
245
+ h6: 'h6',
246
+ heading: 'h1, h2, h3, h4, h5, h6',
247
+ button: '.wp-element-button, .wp-block-button__link',
248
+ caption: '.wp-element-caption, figcaption',
249
+ cite: 'cite',
250
+ };
251
+ return elementMap[element] || null;
252
+ }
253
+ /**
254
+ * Generate CSS for all section styles
255
+ */
256
+ export function generateAllSectionStylesCss(sectionStyles) {
257
+ return sectionStyles
258
+ .map(generateSectionStyleCss)
259
+ .filter(css => css.length > 0)
260
+ .join('\n\n');
261
+ }
262
+ //# sourceMappingURL=css-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-generator.js","sourceRoot":"","sources":["../src/css-generator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,iEAAiE;IACjE,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9C,gDAAgD;IAChD,sDAAsD;IACtD,IAAI,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,aAAa,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3C,CAAC;IACD,OAAO,aAAa,SAAS,EAAE,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAA4B,EAC5B,MAAM,GAAG,cAAc;IAEvB,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,SAAS,OAAO,CAAC,OAAgB,EAAE,IAAY;QAC7C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;QACzB,CAAC;aAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAA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AC;wBACf,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBACzB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,OAAe;IACzC,MAAM,UAAU,GAA2B;QACzC,IAAI,EAAE,GAAG;QACT,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,OAAO,EAAE,wBAAwB;QACjC,MAAM,EAAE,4CAA4C;QACpD,OAAO,EAAE,iCAAiC;QAC1C,IAAI,EAAE,MAAM;KACb,CAAC;IACF,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,aAA6B;IACvE,OAAO,aAAa;SACjB,GAAG,CAAC,uBAAuB,CAAC;SAC5B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;SAC7B,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,82 @@
1
+ import type { ThemeTokens } from './types.js';
2
+ /**
3
+ * Token type for CSS variable generation
4
+ */
5
+ export type TokenType = 'color' | 'gradient' | 'font-family' | 'font-size' | 'spacing' | 'shadow' | 'duotone';
6
+ /**
7
+ * Generates a WordPress CSS variable reference.
8
+ * WordPress uses a special format: var:preset|type|slug
9
+ *
10
+ * @example
11
+ * generateCssVarReference('color', 'primary') => 'var:preset|color|primary'
12
+ */
13
+ export declare function generateCssVarReference(type: TokenType, slug: string): string;
14
+ /**
15
+ * Generates the actual CSS custom property name.
16
+ * This is what WordPress generates in the CSS output.
17
+ *
18
+ * @example
19
+ * generateCssPropertyName('color', 'primary') => '--wp--preset--color--primary'
20
+ */
21
+ export declare function generateCssPropertyName(type: TokenType, slug: string): string;
22
+ /**
23
+ * Generates a CSS var() function reference.
24
+ *
25
+ * @example
26
+ * generateCssVarFunction('color', 'primary') => 'var(--wp--preset--color--primary)'
27
+ */
28
+ export declare function generateCssVarFunction(type: TokenType, slug: string): string;
29
+ /**
30
+ * Parses a WordPress CSS variable reference back to its components.
31
+ *
32
+ * @example
33
+ * parseCssVarReference('var:preset|color|primary') => { type: 'color', slug: 'primary' }
34
+ */
35
+ export declare function parseCssVarReference(reference: string): {
36
+ type: TokenType;
37
+ slug: string;
38
+ } | null;
39
+ /**
40
+ * Checks if a value is a WordPress CSS variable reference.
41
+ */
42
+ export declare function isCssVarReference(value: string): boolean;
43
+ /**
44
+ * Converts a WordPress CSS variable reference to actual CSS.
45
+ *
46
+ * @example
47
+ * convertToActualCss('var:preset|color|primary') => 'var(--wp--preset--color--primary)'
48
+ */
49
+ export declare function convertToActualCss(reference: string): string;
50
+ /**
51
+ * Gets all available color slugs from theme tokens.
52
+ */
53
+ export declare function getColorSlugs(tokens: ThemeTokens): string[];
54
+ /**
55
+ * Gets all available gradient slugs from theme tokens.
56
+ */
57
+ export declare function getGradientSlugs(tokens: ThemeTokens): string[];
58
+ /**
59
+ * Gets all available font family slugs from theme tokens.
60
+ */
61
+ export declare function getFontFamilySlugs(tokens: ThemeTokens): string[];
62
+ /**
63
+ * Gets all available font size slugs from theme tokens.
64
+ */
65
+ export declare function getFontSizeSlugs(tokens: ThemeTokens): string[];
66
+ /**
67
+ * Gets all available spacing slugs from theme tokens.
68
+ */
69
+ export declare function getSpacingSlugs(tokens: ThemeTokens): string[];
70
+ /**
71
+ * Gets all available shadow slugs from theme tokens.
72
+ */
73
+ export declare function getShadowSlugs(tokens: ThemeTokens): string[];
74
+ /**
75
+ * Validates that a slug exists in the theme tokens.
76
+ */
77
+ export declare function validateSlug(tokens: ThemeTokens, type: TokenType, slug: string): boolean;
78
+ /**
79
+ * Gets the actual value for a token slug.
80
+ */
81
+ export declare function getTokenValue(tokens: ThemeTokens, type: TokenType, slug: string): string | null;
82
+ //# sourceMappingURL=css-variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-variables.d.ts","sourceRoot":"","sources":["../src/css-variables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,UAAU,GACV,aAAa,GACb,WAAW,GACX,SAAS,GACT,QAAQ,GACR,SAAS,CAAC;AAEd;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,GAChB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQ1C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK5D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAE3D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAE9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG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