@nordcraft/core 1.0.50 → 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component/actionUtils.js +2 -0
- package/dist/component/actionUtils.js.map +1 -1
- package/dist/component/component.types.d.ts +11 -9
- package/dist/component/component.types.js.map +1 -1
- package/dist/formula/formula.d.ts +1 -0
- package/dist/formula/formula.js.map +1 -1
- package/dist/formula/formulaUtils.js +18 -14
- package/dist/formula/formulaUtils.js.map +1 -1
- package/dist/styling/customProperty.d.ts +2 -2
- package/dist/styling/customProperty.js +51 -7
- package/dist/styling/customProperty.js.map +1 -1
- package/dist/styling/style.css.d.ts +1 -1
- package/dist/styling/style.css.js +17 -11
- package/dist/styling/style.css.js.map +1 -1
- package/dist/styling/theme.d.ts +15 -13
- package/dist/styling/theme.js +74 -16
- package/dist/styling/theme.js.map +1 -1
- package/package.json +1 -1
- package/src/component/actionUtils.ts +2 -0
- package/src/component/component.types.ts +10 -8
- package/src/formula/formula.ts +1 -0
- package/src/formula/formulaUtils.ts +18 -14
- package/src/styling/customProperty.test.ts +84 -3
- package/src/styling/customProperty.ts +61 -7
- package/src/styling/style.css.ts +26 -15
- package/src/styling/theme.test.ts +40 -0
- package/src/styling/theme.ts +112 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/styling/theme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAsB,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/styling/theme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAsB,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAgG5C,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAuC,EACvC,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AAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;SAC3B,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,IAAI,IAAI,KAAK,GAAG,CAAC;SACxD,IAAI,CAAC,IAAI,CAAC;;;EAGb,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;EAyBZ,CAAA;AACF,CAAC,CAAA;AAED,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,KAAwB,EACxB,UAAmB;IAEnB,IAAI,CAAC,KAAK,EAAE,mBAAmB,EAAE,CAAC;QAChC,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,MAAM,CACjE,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CACjC,CAAA;IACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,QAAQ;IACrB,UAAU;SACT,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,GAAG,YAAY,KAAK,QAAQ,CAAC,KAAK,GAAG,CAAC;SACxE,IAAI,CAAC,MAAM,CAAC;EACf,CAAA;IAEA,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,GAAG,UAAU;QAChB,GAAG;MACL,CAAA;IACJ,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -13,8 +13,10 @@ export function* getActionsInAction(
|
|
|
13
13
|
switch (action.type) {
|
|
14
14
|
case 'SetVariable':
|
|
15
15
|
case 'SetURLParameter':
|
|
16
|
+
case 'SetURLParameters':
|
|
16
17
|
case 'TriggerEvent':
|
|
17
18
|
case 'TriggerWorkflow':
|
|
19
|
+
case 'TriggerWorkflowCallback':
|
|
18
20
|
break
|
|
19
21
|
case 'Fetch':
|
|
20
22
|
for (const [key, a] of Object.entries(action.onSuccess?.actions ?? {})) {
|
|
@@ -106,7 +106,7 @@ export interface ElementNodeModel {
|
|
|
106
106
|
variants?: StyleVariant[]
|
|
107
107
|
animations?: Record<string, Record<string, AnimationKeyframe>>
|
|
108
108
|
children: string[]
|
|
109
|
-
events: Record<string, EventModel | null
|
|
109
|
+
events: Partial<Record<string, EventModel | null>>
|
|
110
110
|
classes: Record<string, { formula?: Formula }>
|
|
111
111
|
'style-variables'?: Array<StyleVariable>
|
|
112
112
|
customProperties?: Record<CustomPropertyName, CustomProperty>
|
|
@@ -150,6 +150,7 @@ export interface MetaEntry {
|
|
|
150
150
|
tag: HeadTagTypes
|
|
151
151
|
attrs: Record<string, Formula>
|
|
152
152
|
content: Formula
|
|
153
|
+
index?: number
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
export interface StaticPathSegment {
|
|
@@ -217,6 +218,7 @@ export interface ComponentWorkflow extends NordcraftMetadata {
|
|
|
217
218
|
callbacks?: Array<{ name: string; testValue: any }>
|
|
218
219
|
actions: ActionModel[]
|
|
219
220
|
exposeInContext?: boolean
|
|
221
|
+
testValue?: unknown
|
|
220
222
|
}
|
|
221
223
|
|
|
222
224
|
export interface ComponentContext {
|
|
@@ -289,7 +291,7 @@ export interface EventModel {
|
|
|
289
291
|
|
|
290
292
|
export interface CustomActionArgument {
|
|
291
293
|
name: string
|
|
292
|
-
formula
|
|
294
|
+
formula?: Formula
|
|
293
295
|
type?: any
|
|
294
296
|
description?: string
|
|
295
297
|
}
|
|
@@ -302,7 +304,7 @@ export interface CustomActionModel {
|
|
|
302
304
|
description?: string
|
|
303
305
|
group?: string
|
|
304
306
|
data?: string | number | boolean | Formula
|
|
305
|
-
arguments?: CustomActionArgument[]
|
|
307
|
+
arguments?: Partial<CustomActionArgument[]>
|
|
306
308
|
events?: Record<string, { actions: ActionModel[] }>
|
|
307
309
|
version?: 2 | never
|
|
308
310
|
label?: string
|
|
@@ -321,7 +323,7 @@ export interface SwitchActionModel {
|
|
|
321
323
|
export interface VariableActionModel {
|
|
322
324
|
type: 'SetVariable'
|
|
323
325
|
variable: string
|
|
324
|
-
data: Formula
|
|
326
|
+
data: Formula | null
|
|
325
327
|
}
|
|
326
328
|
export interface FetchActionModel {
|
|
327
329
|
type: 'Fetch'
|
|
@@ -335,7 +337,7 @@ export interface FetchActionModel {
|
|
|
335
337
|
export interface SetURLParameterAction {
|
|
336
338
|
type: 'SetURLParameter'
|
|
337
339
|
parameter: string
|
|
338
|
-
data: Formula
|
|
340
|
+
data: Formula | null
|
|
339
341
|
historyMode?: 'replace' | 'push' | null
|
|
340
342
|
}
|
|
341
343
|
|
|
@@ -348,13 +350,13 @@ export interface SetMultiUrlParameterAction {
|
|
|
348
350
|
export interface EventActionModel {
|
|
349
351
|
type: 'TriggerEvent'
|
|
350
352
|
event: string
|
|
351
|
-
data: Formula
|
|
353
|
+
data: Formula | null
|
|
352
354
|
}
|
|
353
355
|
|
|
354
356
|
export interface WorkflowActionModel {
|
|
355
357
|
type: 'TriggerWorkflow'
|
|
356
358
|
workflow: string
|
|
357
|
-
parameters: Record<string, { formula
|
|
359
|
+
parameters: Record<string, { formula?: Formula }> | null
|
|
358
360
|
callbacks?: Record<string, { actions: ActionModel[] }>
|
|
359
361
|
contextProvider?: string
|
|
360
362
|
}
|
|
@@ -362,7 +364,7 @@ export interface WorkflowActionModel {
|
|
|
362
364
|
export interface WorkflowCallbackActionModel {
|
|
363
365
|
type: 'TriggerWorkflowCallback'
|
|
364
366
|
event: string
|
|
365
|
-
data: Formula
|
|
367
|
+
data: Formula | null
|
|
366
368
|
}
|
|
367
369
|
|
|
368
370
|
export type ActionModel =
|
package/src/formula/formula.ts
CHANGED
|
@@ -239,13 +239,15 @@ export function* getFormulasInAction<Handler>({
|
|
|
239
239
|
})
|
|
240
240
|
}
|
|
241
241
|
for (const [key, a] of Object.entries(action.arguments ?? {})) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
242
|
+
if (a) {
|
|
243
|
+
yield* getFormulasInFormula({
|
|
244
|
+
formula: a.formula,
|
|
245
|
+
globalFormulas,
|
|
246
|
+
path: [...path, 'arguments', key, 'formula'],
|
|
247
|
+
visitedFormulas,
|
|
248
|
+
packageName,
|
|
249
|
+
})
|
|
250
|
+
}
|
|
249
251
|
}
|
|
250
252
|
|
|
251
253
|
for (const [eventKey, event] of Object.entries(action.events ?? {})) {
|
|
@@ -293,13 +295,15 @@ export function* getFormulasInAction<Handler>({
|
|
|
293
295
|
case 'TriggerWorkflow':
|
|
294
296
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
295
297
|
for (const [key, a] of Object.entries(action.parameters ?? {})) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
298
|
+
if (isDefined(a.formula)) {
|
|
299
|
+
yield* getFormulasInFormula({
|
|
300
|
+
formula: a.formula,
|
|
301
|
+
globalFormulas,
|
|
302
|
+
path: [...path, 'parameters', key, 'formula'],
|
|
303
|
+
visitedFormulas,
|
|
304
|
+
packageName,
|
|
305
|
+
})
|
|
306
|
+
}
|
|
303
307
|
}
|
|
304
308
|
break
|
|
305
309
|
case 'Switch':
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test'
|
|
2
2
|
import type { CssSyntax, CssSyntaxNode } from './customProperty'
|
|
3
3
|
import { renderSyntaxDefinition, stringifySyntaxNode } from './customProperty'
|
|
4
|
-
import type { CustomPropertyDefinition } from './theme'
|
|
4
|
+
import type { CustomPropertyDefinition, Theme } from './theme'
|
|
5
5
|
|
|
6
6
|
describe('stringifySyntaxNode()', () => {
|
|
7
|
-
;['length', 'number', 'percentage', 'length
|
|
7
|
+
;['length', 'number', 'percentage', 'length', 'color'].forEach(
|
|
8
8
|
(primitive) => {
|
|
9
9
|
test(
|
|
10
10
|
'it handles a comprehensive list of primitives: ' + primitive,
|
|
@@ -38,9 +38,90 @@ describe('renderSyntaxDefinition()', () => {
|
|
|
38
38
|
description: 'My custom property',
|
|
39
39
|
inherits: true,
|
|
40
40
|
initialValue: '0px',
|
|
41
|
+
value: 'var(--some-other-property)',
|
|
41
42
|
}
|
|
42
|
-
expect(
|
|
43
|
+
expect(
|
|
44
|
+
renderSyntaxDefinition('--my-property', property, {
|
|
45
|
+
fonts: [],
|
|
46
|
+
}),
|
|
47
|
+
).toBe(
|
|
43
48
|
'@property --my-property {\n syntax: "<length>";\n inherits: true;\n initial-value: 0px;\n}',
|
|
44
49
|
)
|
|
45
50
|
})
|
|
51
|
+
|
|
52
|
+
test('it solves var(--...) references', () => {
|
|
53
|
+
const themes: Record<string, Theme> = {
|
|
54
|
+
default: {
|
|
55
|
+
fonts: [],
|
|
56
|
+
propertyDefinitions: {
|
|
57
|
+
'--my-property': {
|
|
58
|
+
syntax: { type: 'primitive', name: 'color' },
|
|
59
|
+
description: '',
|
|
60
|
+
inherits: true,
|
|
61
|
+
initialValue: 'var(--primary-color)',
|
|
62
|
+
value: 'rebeccapurple',
|
|
63
|
+
},
|
|
64
|
+
'--primary-color': {
|
|
65
|
+
syntax: { type: 'primitive', name: 'color' },
|
|
66
|
+
description: '',
|
|
67
|
+
inherits: true,
|
|
68
|
+
initialValue: 'var(--red-500)',
|
|
69
|
+
value: 'rebeccapurple',
|
|
70
|
+
},
|
|
71
|
+
'--red-500': {
|
|
72
|
+
syntax: { type: 'primitive', name: 'color' },
|
|
73
|
+
description: '',
|
|
74
|
+
inherits: true,
|
|
75
|
+
initialValue: '#f00',
|
|
76
|
+
value: 'rebeccapurple',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
expect(
|
|
83
|
+
renderSyntaxDefinition(
|
|
84
|
+
'--my-property',
|
|
85
|
+
themes.default.propertyDefinitions!['--my-property'],
|
|
86
|
+
themes.default,
|
|
87
|
+
),
|
|
88
|
+
).toMatchInlineSnapshot(`
|
|
89
|
+
"@property --my-property {
|
|
90
|
+
syntax: "<color>";
|
|
91
|
+
inherits: true;
|
|
92
|
+
initial-value: #f00;
|
|
93
|
+
}"
|
|
94
|
+
`)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
test('it renders a fallback initial-value on broken references', () => {
|
|
98
|
+
const themes: Record<string, Theme> = {
|
|
99
|
+
default: {
|
|
100
|
+
fonts: [],
|
|
101
|
+
propertyDefinitions: {
|
|
102
|
+
'--my-property': {
|
|
103
|
+
syntax: { type: 'primitive', name: 'color' },
|
|
104
|
+
description: '',
|
|
105
|
+
inherits: true,
|
|
106
|
+
initialValue: 'var(--unknown-color)',
|
|
107
|
+
value: 'rebeccapurple',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
expect(
|
|
114
|
+
renderSyntaxDefinition(
|
|
115
|
+
'--my-property',
|
|
116
|
+
themes.default.propertyDefinitions!['--my-property'],
|
|
117
|
+
themes.default,
|
|
118
|
+
),
|
|
119
|
+
).toMatchInlineSnapshot(`
|
|
120
|
+
"@property --my-property {
|
|
121
|
+
syntax: "<color>";
|
|
122
|
+
inherits: true;
|
|
123
|
+
initial-value: transparent;
|
|
124
|
+
}"
|
|
125
|
+
`)
|
|
126
|
+
})
|
|
46
127
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CustomPropertyName } from '../component/component.types'
|
|
2
|
-
import
|
|
2
|
+
import { isDefined } from '../utils/util'
|
|
3
|
+
import type { CustomPropertyDefinition, Theme } from './theme'
|
|
3
4
|
|
|
4
5
|
// See https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax
|
|
5
6
|
export type CssSyntax =
|
|
@@ -41,18 +42,71 @@ export function stringifySyntaxNode(node: CssSyntaxNode): string {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
/*
|
|
45
|
-
TODO: `initialValue` does not support referencing other properties (e.g. var(--some-other-property))
|
|
46
|
-
To Fix this, we could either statically solve by accessing theme at SSR, but to handle theme-switching at runtime,
|
|
47
|
-
we would instead need to do `:root { --my-property: var(--some-other-property); }` for properties that need to reference other properties.
|
|
48
|
-
*/
|
|
49
45
|
export function renderSyntaxDefinition(
|
|
50
46
|
key: CustomPropertyName,
|
|
51
47
|
{ syntax, inherits, initialValue }: CustomPropertyDefinition,
|
|
48
|
+
defaultTheme: Theme,
|
|
52
49
|
): string {
|
|
50
|
+
let value = initialValue
|
|
51
|
+
if (initialValue?.includes('var(--')) {
|
|
52
|
+
value = solveVarRecursively(initialValue, defaultTheme)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Fallback in-case of no reference
|
|
56
|
+
if (!isDefined(value) && syntax.type === 'primitive') {
|
|
57
|
+
value = FALLBACK_VALUES[syntax.name]
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
return `@property ${key} {
|
|
54
61
|
syntax: "${stringifySyntaxNode(syntax)}";
|
|
55
62
|
inherits: ${String(inherits)};
|
|
56
|
-
initial-value: ${
|
|
63
|
+
initial-value: ${value};
|
|
57
64
|
}`
|
|
58
65
|
}
|
|
66
|
+
|
|
67
|
+
function solveVarRecursively(initialValue: string, theme: Theme, depth = 0) {
|
|
68
|
+
// This makes a crazy assumption that no person would create a web of style-variable referencing deeper than 256
|
|
69
|
+
if (depth > 2 ** 8) {
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const VAR_REGEX = /var\((--[a-zA-Z0-9-_]+)\)/g
|
|
74
|
+
|
|
75
|
+
let match
|
|
76
|
+
while ((match = VAR_REGEX.exec(initialValue))) {
|
|
77
|
+
const varName = match[1]
|
|
78
|
+
const def = theme.propertyDefinitions?.[varName as CustomPropertyName]
|
|
79
|
+
if (!isDefined(def)) {
|
|
80
|
+
return null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const value = def.initialValue
|
|
84
|
+
const returnValue = initialValue.replace(match[0], String(value))
|
|
85
|
+
if (returnValue.includes('var(--')) {
|
|
86
|
+
return solveVarRecursively(returnValue, theme, depth + 1)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return returnValue
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return null
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const FALLBACK_VALUES: Record<CssSyntax, string> = {
|
|
96
|
+
color: 'transparent',
|
|
97
|
+
length: '0px',
|
|
98
|
+
'length-percentage': '0px',
|
|
99
|
+
percentage: '0%',
|
|
100
|
+
number: '0',
|
|
101
|
+
angle: '0deg',
|
|
102
|
+
time: '0s',
|
|
103
|
+
resolution: '0dpi',
|
|
104
|
+
'custom-ident': 'none',
|
|
105
|
+
string: '""',
|
|
106
|
+
image: 'none',
|
|
107
|
+
url: 'none',
|
|
108
|
+
'transform-function': 'none',
|
|
109
|
+
'transform-list': 'none',
|
|
110
|
+
'*': 'initial',
|
|
111
|
+
integer: '0',
|
|
112
|
+
}
|
package/src/styling/style.css.ts
CHANGED
|
@@ -70,7 +70,7 @@ const SIZE_PROPERTIES = new Set([
|
|
|
70
70
|
export const createStylesheet = (
|
|
71
71
|
root: Component,
|
|
72
72
|
components: Component[],
|
|
73
|
-
|
|
73
|
+
themes: Record<string, OldTheme | Theme>,
|
|
74
74
|
options: ThemeOptions,
|
|
75
75
|
// eslint-disable-next-line max-params
|
|
76
76
|
) => {
|
|
@@ -82,19 +82,30 @@ export const createStylesheet = (
|
|
|
82
82
|
|
|
83
83
|
//Exclude fonts that are not used on this page.
|
|
84
84
|
let stylesheet = getThemeCss(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
Object.fromEntries(
|
|
86
|
+
Object.entries(themes).map(([key, theme]) =>
|
|
87
|
+
'breakpoints' in theme
|
|
88
|
+
? [
|
|
89
|
+
key,
|
|
90
|
+
{
|
|
91
|
+
...theme,
|
|
92
|
+
fontFamily: Object.fromEntries(
|
|
93
|
+
Object.entries(theme.fontFamily).filter(
|
|
94
|
+
([key, value]) =>
|
|
95
|
+
value.default ?? fonts.has('--font-' + key),
|
|
96
|
+
),
|
|
97
|
+
),
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
: [
|
|
101
|
+
key,
|
|
102
|
+
{
|
|
103
|
+
...theme,
|
|
104
|
+
fonts: theme.fonts,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
),
|
|
108
|
+
),
|
|
98
109
|
options,
|
|
99
110
|
)
|
|
100
111
|
const styleToCss = (style: StyleDeclarationBlock) => {
|
|
@@ -132,7 +143,7 @@ export const createStylesheet = (
|
|
|
132
143
|
options?: { startingStyle?: boolean },
|
|
133
144
|
) => {
|
|
134
145
|
const scrollbarStyles = Object.entries(style).filter(
|
|
135
|
-
([key]) => key
|
|
146
|
+
([key]) => key === 'scrollbar-width',
|
|
136
147
|
)
|
|
137
148
|
// If selectorCss is empty, we don't need to render the selector
|
|
138
149
|
let styles = styleToCss(style)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Theme } from './theme'
|
|
2
|
+
import { renderTheme } from './theme'
|
|
3
|
+
|
|
4
|
+
describe('renderTheme()', () => {
|
|
5
|
+
test('it renders a theme correctly', () => {
|
|
6
|
+
const theme: Theme = {
|
|
7
|
+
fonts: [],
|
|
8
|
+
propertyDefinitions: {
|
|
9
|
+
'--my-color': {
|
|
10
|
+
syntax: { type: 'primitive', name: 'color' },
|
|
11
|
+
description: 'A custom color',
|
|
12
|
+
inherits: true,
|
|
13
|
+
initialValue: 'red',
|
|
14
|
+
value: 'rebeccapurple',
|
|
15
|
+
},
|
|
16
|
+
'--my-other-color': {
|
|
17
|
+
syntax: { type: 'primitive', name: 'color' },
|
|
18
|
+
description: 'A custom color',
|
|
19
|
+
inherits: true,
|
|
20
|
+
initialValue: 'red',
|
|
21
|
+
value: null,
|
|
22
|
+
},
|
|
23
|
+
'--my-third-prop': {
|
|
24
|
+
syntax: { type: 'primitive', name: 'length-percentage' },
|
|
25
|
+
description: 'A custom length or percentage',
|
|
26
|
+
inherits: true,
|
|
27
|
+
initialValue: null,
|
|
28
|
+
value: 'var(--my-color)',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
expect(renderTheme('[data-theme="my-theme"]', theme))
|
|
33
|
+
.toMatchInlineSnapshot(`
|
|
34
|
+
"[data-theme="my-theme"] {
|
|
35
|
+
--my-color: rebeccapurple;
|
|
36
|
+
--my-third-prop: var(--my-color);
|
|
37
|
+
}"
|
|
38
|
+
`)
|
|
39
|
+
})
|
|
40
|
+
})
|