@webmate-studio/builder 0.2.157 → 0.2.159
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/package.json +1 -1
- package/src/design-tokens-v2-css.js +48 -4
- package/src/design-tokens-v2.js +50 -0
package/package.json
CHANGED
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
calculateOnColor,
|
|
16
16
|
DEFAULT_SURFACE_TOKENS,
|
|
17
17
|
defaultDesignTokensV2,
|
|
18
|
-
normalizeShadowValue
|
|
18
|
+
normalizeShadowValue,
|
|
19
|
+
isGradientValue
|
|
19
20
|
} from './design-tokens-v2.js';
|
|
20
21
|
|
|
21
22
|
|
|
@@ -600,9 +601,9 @@ function resolveShadowToCSS(shadowValue, t) {
|
|
|
600
601
|
}
|
|
601
602
|
|
|
602
603
|
function addButtonVariantVars(lines, prefix, variant, t) {
|
|
603
|
-
if (variant.bg) lines.push(` --${prefix}-bg: ${
|
|
604
|
-
if (variant.bgHover) lines.push(` --${prefix}-bg-hover: ${
|
|
605
|
-
if (variant.bgActive) lines.push(` --${prefix}-bg-active: ${
|
|
604
|
+
if (variant.bg) lines.push(` --${prefix}-bg: ${resolveBackgroundValue(variant.bg, t)};`);
|
|
605
|
+
if (variant.bgHover) lines.push(` --${prefix}-bg-hover: ${resolveBackgroundValue(variant.bgHover, t)};`);
|
|
606
|
+
if (variant.bgActive) lines.push(` --${prefix}-bg-active: ${resolveBackgroundValue(variant.bgActive, t)};`);
|
|
606
607
|
if (variant.text) lines.push(` --${prefix}-text: ${resolveColorRef(variant.text, t)};`);
|
|
607
608
|
if (variant.textHover) lines.push(` --${prefix}-text-hover: ${resolveColorRef(variant.textHover, t)};`);
|
|
608
609
|
if (variant.textActive) lines.push(` --${prefix}-text-active: ${resolveColorRef(variant.textActive, t)};`);
|
|
@@ -652,6 +653,49 @@ function resolveColorRef(ref, t) {
|
|
|
652
653
|
return `var(--color-${ref})`;
|
|
653
654
|
}
|
|
654
655
|
|
|
656
|
+
/**
|
|
657
|
+
* Löst einen Hintergrundwert auf — entweder Farbreferenz (String) oder Gradient (Object).
|
|
658
|
+
* String → delegiert an resolveColorRef()
|
|
659
|
+
* Object → buildGradientCSS()
|
|
660
|
+
*/
|
|
661
|
+
function resolveBackgroundValue(val, t) {
|
|
662
|
+
if (!val) return 'none';
|
|
663
|
+
if (isGradientValue(val)) return buildGradientCSS(val, t);
|
|
664
|
+
return resolveColorRef(val, t);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Baut einen CSS-Gradient-String aus einem Gradient-Objekt.
|
|
669
|
+
* Unterstützt linear-gradient, radial-gradient und conic-gradient.
|
|
670
|
+
*/
|
|
671
|
+
function buildGradientCSS(gradient, t) {
|
|
672
|
+
const stops = (gradient.stops || []).map(stop => {
|
|
673
|
+
const color = resolveColorRef(stop.color, t);
|
|
674
|
+
const colorCSS = (stop.opacity != null && stop.opacity < 100)
|
|
675
|
+
? `color-mix(in srgb, ${color} ${stop.opacity}%, transparent)`
|
|
676
|
+
: color;
|
|
677
|
+
return `${colorCSS} ${stop.position}%`;
|
|
678
|
+
}).join(', ');
|
|
679
|
+
|
|
680
|
+
switch (gradient.type) {
|
|
681
|
+
case 'radial': {
|
|
682
|
+
const shape = gradient.shape || 'circle';
|
|
683
|
+
const size = gradient.size || 'farthest-corner';
|
|
684
|
+
const pos = gradient.position || 'center';
|
|
685
|
+
return `radial-gradient(${shape} ${size} at ${pos}, ${stops})`;
|
|
686
|
+
}
|
|
687
|
+
case 'conic': {
|
|
688
|
+
const fromAngle = gradient.fromAngle || 0;
|
|
689
|
+
const pos = gradient.position || 'center';
|
|
690
|
+
return `conic-gradient(from ${fromAngle}deg at ${pos}, ${stops})`;
|
|
691
|
+
}
|
|
692
|
+
default: { // linear
|
|
693
|
+
const angle = gradient.angle ?? 135;
|
|
694
|
+
return `linear-gradient(${angle}deg, ${stops})`;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
655
699
|
|
|
656
700
|
// ─── Button-Klassen ─────────────────────────────────────────────────────────
|
|
657
701
|
|
package/src/design-tokens-v2.js
CHANGED
|
@@ -1399,6 +1399,56 @@ export const defaultDesignTokensV2 = {
|
|
|
1399
1399
|
};
|
|
1400
1400
|
|
|
1401
1401
|
|
|
1402
|
+
// ─── Gradient-Hilfsfunktionen ───────────────────────────────────────────────
|
|
1403
|
+
|
|
1404
|
+
/**
|
|
1405
|
+
* Position-Keywords für radial/conic Gradients.
|
|
1406
|
+
*/
|
|
1407
|
+
export const GRADIENT_POSITIONS = [
|
|
1408
|
+
'center', 'top', 'right', 'bottom', 'left',
|
|
1409
|
+
'top left', 'top right', 'bottom left', 'bottom right'
|
|
1410
|
+
];
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Size-Keywords für radial Gradients.
|
|
1414
|
+
*/
|
|
1415
|
+
export const RADIAL_SIZES = [
|
|
1416
|
+
'farthest-corner', 'closest-side', 'farthest-side', 'closest-corner'
|
|
1417
|
+
];
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Prüft ob ein Wert ein Gradient-Objekt ist (statt einer Farbreferenz-String).
|
|
1421
|
+
*/
|
|
1422
|
+
export function isGradientValue(val) {
|
|
1423
|
+
return val != null && typeof val === 'object' && val.type && Array.isArray(val.stops);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
/**
|
|
1427
|
+
* Erzeugt einen Standard-Gradient-Stop.
|
|
1428
|
+
*/
|
|
1429
|
+
export function createDefaultGradientStop(position = 0) {
|
|
1430
|
+
return { color: 'primary-9', position, opacity: 100 };
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Erzeugt ein Standard-Gradient-Objekt mit 2 Stops.
|
|
1435
|
+
*/
|
|
1436
|
+
export function createDefaultGradient() {
|
|
1437
|
+
return {
|
|
1438
|
+
type: 'linear',
|
|
1439
|
+
angle: 135,
|
|
1440
|
+
shape: 'circle',
|
|
1441
|
+
position: 'center',
|
|
1442
|
+
size: 'farthest-corner',
|
|
1443
|
+
fromAngle: 0,
|
|
1444
|
+
stops: [
|
|
1445
|
+
{ color: 'primary-9', position: 0, opacity: 100 },
|
|
1446
|
+
{ color: 'primary-6', position: 100, opacity: 100 }
|
|
1447
|
+
]
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
|
|
1402
1452
|
// ─── Erkennung ──────────────────────────────────────────────────────────────
|
|
1403
1453
|
|
|
1404
1454
|
/**
|