@dreamtree-org/twreact-ui 2.0.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +3 -0
- package/README.md +9 -4
- package/ai-skills/dreamtree-ui.md +12 -8
- package/dist/ai-schema.json +314 -70
- package/dist/components/blocks/AppShell.d.ts.map +1 -1
- package/dist/components/blocks/ProductCard.d.ts +4 -0
- package/dist/components/blocks/ProductCard.d.ts.map +1 -0
- package/dist/components/blocks/ProductCardParts.d.ts +19 -0
- package/dist/components/blocks/ProductCardParts.d.ts.map +1 -0
- package/dist/components/blocks/StatCard.d.ts.map +1 -1
- package/dist/components/core/Button.d.ts.map +1 -1
- package/dist/components/core/OptionCard.d.ts +14 -0
- package/dist/components/core/OptionCard.d.ts.map +1 -0
- package/dist/components/core/OptionCardGroup.d.ts +2 -0
- package/dist/components/core/OptionCardGroup.d.ts.map +1 -0
- package/dist/components/core/QuantityStepper.d.ts +8 -0
- package/dist/components/core/QuantityStepper.d.ts.map +1 -0
- package/dist/components/utility/ImageGallery.d.ts +4 -0
- package/dist/components/utility/ImageGallery.d.ts.map +1 -0
- package/dist/components/utility/imageGalleryParts.d.ts +55 -0
- package/dist/components/utility/imageGalleryParts.d.ts.map +1 -0
- package/dist/esm/components/blocks/AppShell.js +17 -6
- package/dist/esm/components/blocks/ProductCard.js +122 -0
- package/dist/esm/components/blocks/ProductCardParts.js +128 -0
- package/dist/esm/components/blocks/StatCard.js +20 -5
- package/dist/esm/components/core/Button.js +17 -2
- package/dist/esm/components/core/OptionCard.js +340 -0
- package/dist/esm/components/core/QuantityStepper.js +194 -0
- package/dist/esm/components/utility/ImageGallery.js +150 -0
- package/dist/esm/components/utility/imageGalleryParts.js +380 -0
- package/dist/esm/index.js +4 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +1843 -502
- package/dist/index.js +1847 -501
- package/dist/tokens/tailwind3-preset.cjs +4 -1
- package/dist/tokens/theme.css +3 -0
- package/dist/tokens/tokens.json +7 -0
- package/dist/tokens/vars.css +2 -0
- package/dist/types/blocks.d.ts +61 -1
- package/dist/types/blocks.d.ts.map +1 -1
- package/dist/types/index.d.ts +102 -1
- package/dist/types/index.d.ts.map +1 -1
- package/doc/README.md +5 -1
- package/mcp/catalog.snapshot.json +479 -8
- package/package.json +1 -1
- package/tokens/brand.schema.json +22 -0
- package/tokens/lib.cjs +26 -0
- package/tokens/tokens.json +2 -1
package/package.json
CHANGED
package/tokens/brand.schema.json
CHANGED
|
@@ -573,6 +573,28 @@
|
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
575
|
]
|
|
576
|
+
},
|
|
577
|
+
"primary-foreground": {
|
|
578
|
+
"oneOf": [
|
|
579
|
+
{
|
|
580
|
+
"type": "string",
|
|
581
|
+
"pattern": "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
"type": "object",
|
|
585
|
+
"additionalProperties": false,
|
|
586
|
+
"properties": {
|
|
587
|
+
"light": {
|
|
588
|
+
"type": "string",
|
|
589
|
+
"pattern": "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
|
|
590
|
+
},
|
|
591
|
+
"dark": {
|
|
592
|
+
"type": "string",
|
|
593
|
+
"pattern": "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
]
|
|
576
598
|
}
|
|
577
599
|
}
|
|
578
600
|
},
|
package/tokens/lib.cjs
CHANGED
|
@@ -122,6 +122,26 @@ function roles(tokens) {
|
|
|
122
122
|
return out;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
// WCAG relative luminance and contrast ratio of two hex colours.
|
|
126
|
+
function luminance(hex) {
|
|
127
|
+
const [r, g, b] = hexToChannels(hex).split(' ').map((c) => {
|
|
128
|
+
const v = Number(c) / 255;
|
|
129
|
+
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
130
|
+
});
|
|
131
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
132
|
+
}
|
|
133
|
+
const contrast = (a, b) => {
|
|
134
|
+
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
|
135
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** The colour for text on a primary fill: white or role.foreground, whichever contrasts more with primary-700. */
|
|
139
|
+
function onPrimary(tokens) {
|
|
140
|
+
const fill = tokens.color.primary['700'].$value;
|
|
141
|
+
const dark = tokens.role.foreground.$value;
|
|
142
|
+
return contrast('#ffffff', fill) >= contrast(dark, fill) ? '#ffffff' : dark;
|
|
143
|
+
}
|
|
144
|
+
|
|
125
145
|
/** Merge a brand file over the tokens: brand.color.<scale>.<step> and brand.role.<name> (string or {light,dark}). */
|
|
126
146
|
function applyBrand(tokens, brand) {
|
|
127
147
|
if (!brand) return tokens;
|
|
@@ -133,6 +153,11 @@ function applyBrand(tokens, brand) {
|
|
|
133
153
|
next.color[scale][step] = { $value: hex };
|
|
134
154
|
}
|
|
135
155
|
}
|
|
156
|
+
// #189: a light primary needs dark text on it; the brand can still set the role itself.
|
|
157
|
+
if (brand.color && brand.color.primary && next.role['primary-foreground']) {
|
|
158
|
+
const on = onPrimary(next);
|
|
159
|
+
next.role['primary-foreground'] = { ...next.role['primary-foreground'], $value: on, $extensions: { [DARK_KEY]: on } };
|
|
160
|
+
}
|
|
136
161
|
for (const [name, value] of Object.entries(brand.role || {})) {
|
|
137
162
|
if (!next.role[name]) throw new Error(`Brand "${brandId(brand)}" sets unknown role "${name}". Known: ${Object.keys(roles(tokens)).join(', ')}.`);
|
|
138
163
|
// A plain string overrides light only; dark keeps the shared value unless {light, dark} is given.
|
|
@@ -278,6 +303,7 @@ module.exports = {
|
|
|
278
303
|
brandCss,
|
|
279
304
|
applyBrand,
|
|
280
305
|
hexToChannels,
|
|
306
|
+
contrast,
|
|
281
307
|
scales,
|
|
282
308
|
roles,
|
|
283
309
|
tailwindColors,
|
package/tokens/tokens.json
CHANGED
|
@@ -111,7 +111,8 @@
|
|
|
111
111
|
"line": { "$value": "#e2e8f0", "$description": "Card and divider borders.", "$extensions": { "org.dreamtree.dark": "#1f2937" } },
|
|
112
112
|
"shell": { "$value": "#0f172a", "$description": "App shell sidebar background.", "$extensions": { "org.dreamtree.dark": "#020617" } },
|
|
113
113
|
"shell-foreground": { "$value": "#cbd5e1", "$description": "Sidebar text.", "$extensions": { "org.dreamtree.dark": "#cbd5e1" } },
|
|
114
|
-
"shell-active": { "$value": "#1e293b", "$description": "Active sidebar item fill.", "$extensions": { "org.dreamtree.dark": "#1e293b" } }
|
|
114
|
+
"shell-active": { "$value": "#1e293b", "$description": "Active sidebar item fill.", "$extensions": { "org.dreamtree.dark": "#1e293b" } },
|
|
115
|
+
"primary-foreground": { "$value": "#ffffff", "$description": "Text, icons, tiles (primary-foreground/12) and focus rings on a primary-600 to primary-900 fill, such as a brand band. A brand that changes color.primary gets white or role.foreground, whichever contrasts more with its primary-700.", "$extensions": { "org.dreamtree.dark": "#ffffff" } }
|
|
115
116
|
},
|
|
116
117
|
"font": {
|
|
117
118
|
"family": {
|