@uni-design-system/uni-core 5.0.0 → 5.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/dist/cjs/index.cjs +80 -24
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +80 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/types/concepts/generation/generation.types.d.ts +3 -2
- package/dist/types/concepts/generation/generation.types.d.ts.map +1 -1
- package/dist/types/concepts/generation/index.d.ts +1 -0
- package/dist/types/concepts/generation/index.d.ts.map +1 -1
- package/dist/types/concepts/generation/shadow.generator.d.ts +13 -0
- package/dist/types/concepts/generation/shadow.generator.d.ts.map +1 -0
- package/dist/types/concepts/generation/theme-file.emitter.d.ts.map +1 -1
- package/dist/types/concepts/generation/theme.generator.d.ts.map +1 -1
- package/dist/types/concepts/theme/themes/base.theme.d.ts.map +1 -1
- package/dist/types/concepts/theme/themes/dark.theme.d.ts.map +1 -1
- package/dist/types/concepts/theme/themes/light.theme.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -762,6 +762,43 @@ var Z_INDEX = {
|
|
|
762
762
|
overlay: 1080
|
|
763
763
|
};
|
|
764
764
|
//#endregion
|
|
765
|
+
//#region src/concepts/generation/shadow.generator.ts
|
|
766
|
+
var rgba = (hex, alpha) => {
|
|
767
|
+
const { red, green, blue } = hexToRgb(hex);
|
|
768
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* Brand-tinted, theme-scoped elevation shadows (PRD §3.5.C).
|
|
772
|
+
*
|
|
773
|
+
* Light mode replaces the dead-neutral black stacks with a shadow ink pulled
|
|
774
|
+
* toward the brand hue — dark and low-chroma enough to read as shadow, tinted
|
|
775
|
+
* enough to kill the grey "mud" where shadows meet brand surfaces. Dark mode
|
|
776
|
+
* goes near-zero: elevation is carried by the surface lightness steps, with
|
|
777
|
+
* only a faint veil kept on floating overlays (menus/dialogs genuinely need
|
|
778
|
+
* separation) and the `warn` glow tinted by the theme's own error color.
|
|
779
|
+
*/
|
|
780
|
+
var generateShadows = (colors, mode = "light") => {
|
|
781
|
+
const error = colors["error"] ?? "#CC2827";
|
|
782
|
+
if (mode === "dark") return {
|
|
783
|
+
raised: "none",
|
|
784
|
+
menu: `0px 4px 12px ${rgba("#000000", .45)}`,
|
|
785
|
+
dialog: `0px 8px 28px ${rgba("#000000", .55)}`,
|
|
786
|
+
warn: `0 0 5px ${rgba(error, .55)}, inset 0 0 5px ${rgba(error, .35)}`
|
|
787
|
+
};
|
|
788
|
+
const { h } = hexToOklch(colors["primary"] ?? "#000000");
|
|
789
|
+
const ink = oklchToHex({
|
|
790
|
+
l: .22,
|
|
791
|
+
c: .035,
|
|
792
|
+
h
|
|
793
|
+
});
|
|
794
|
+
return {
|
|
795
|
+
raised: `${rgba(ink, .2)} 0px 2px 1px -1px, ${rgba(ink, .14)} 0px 1px 1px 0px, ${rgba(ink, .12)} 0px 1px 3px 0px`,
|
|
796
|
+
menu: `${rgba(ink, .2)} 0px 3px 3px -2px, ${rgba(ink, .14)} 0px 3px 4px 0px, ${rgba(ink, .12)} 0px 1px 8px 0px`,
|
|
797
|
+
dialog: `${rgba(ink, .2)} 0px 3px 5px -1px, ${rgba(ink, .14)} 0px 6px 10px 0px, ${rgba(ink, .12)} 0px 1px 18px 0px`,
|
|
798
|
+
warn: `0 0 5px ${rgba(error, .5)}, inset 0 0 5px ${rgba(error, .3)}`
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
//#endregion
|
|
765
802
|
//#region src/concepts/theme/themes/base.theme.ts
|
|
766
803
|
var BaseTypography = {
|
|
767
804
|
"display-large": {
|
|
@@ -1337,12 +1374,16 @@ var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows =
|
|
|
1337
1374
|
* one-call path a theme builder uses to turn a brand color (or a seed +
|
|
1338
1375
|
* scheme + category) into a complete, ready-to-apply theme.
|
|
1339
1376
|
*/
|
|
1340
|
-
var createThemeFromPalette = (config) =>
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1377
|
+
var createThemeFromPalette = (config) => {
|
|
1378
|
+
const colors = generatePalette(config);
|
|
1379
|
+
return createTheme({
|
|
1380
|
+
id: config.id ?? "CustomTheme",
|
|
1381
|
+
name: config.name ?? "Custom Theme",
|
|
1382
|
+
colors,
|
|
1383
|
+
shadows: generateShadows(colors, config.mode ?? "light"),
|
|
1384
|
+
icons: config.icons
|
|
1385
|
+
});
|
|
1386
|
+
};
|
|
1346
1387
|
/**
|
|
1347
1388
|
* Seed for the shipped Light/Dark themes. Swap these three values (or call
|
|
1348
1389
|
* `generatePalette` with your own) to reskin the entire system — every color
|
|
@@ -1465,6 +1506,8 @@ var generateThemes = (input) => {
|
|
|
1465
1506
|
lightColors,
|
|
1466
1507
|
darkColors,
|
|
1467
1508
|
radii: input.shape ? ShapeRadii[input.shape] : void 0,
|
|
1509
|
+
lightShadows: generateShadows(lightColors, "light"),
|
|
1510
|
+
darkShadows: generateShadows(darkColors, "dark"),
|
|
1468
1511
|
report: {
|
|
1469
1512
|
checks,
|
|
1470
1513
|
worstRatio,
|
|
@@ -1477,7 +1520,7 @@ var generateThemes = (input) => {
|
|
|
1477
1520
|
* returning a registration-ready light/dark {@link UniTheme} pair.
|
|
1478
1521
|
*/
|
|
1479
1522
|
var generateUniThemes = (input) => {
|
|
1480
|
-
const { lightColors, darkColors, radii } = generateThemes(input);
|
|
1523
|
+
const { lightColors, darkColors, radii, lightShadows, darkShadows } = generateThemes(input);
|
|
1481
1524
|
const name = input.name ?? "Brand";
|
|
1482
1525
|
const id = name.replace(/\W+/g, "") || "Brand";
|
|
1483
1526
|
return {
|
|
@@ -1485,13 +1528,15 @@ var generateUniThemes = (input) => {
|
|
|
1485
1528
|
id: `${id}Light`,
|
|
1486
1529
|
name: `${name} Light`,
|
|
1487
1530
|
colors: lightColors,
|
|
1488
|
-
radii
|
|
1531
|
+
radii,
|
|
1532
|
+
shadows: lightShadows
|
|
1489
1533
|
}),
|
|
1490
1534
|
dark: createTheme({
|
|
1491
1535
|
id: `${id}Dark`,
|
|
1492
1536
|
name: `${name} Dark`,
|
|
1493
1537
|
colors: darkColors,
|
|
1494
|
-
radii
|
|
1538
|
+
radii,
|
|
1539
|
+
shadows: darkShadows
|
|
1495
1540
|
})
|
|
1496
1541
|
};
|
|
1497
1542
|
};
|
|
@@ -1508,24 +1553,25 @@ var bordersLiteral = () => [
|
|
|
1508
1553
|
" * shared token picks up the change.",
|
|
1509
1554
|
" */",
|
|
1510
1555
|
"const borders = (colors: Colors): Borders => ({",
|
|
1511
|
-
" primary: `1px solid ${colors
|
|
1512
|
-
" secondary: `1px solid ${colors
|
|
1513
|
-
" tertiary: `1px solid ${colors
|
|
1514
|
-
" quaternary: `1px solid ${colors
|
|
1515
|
-
" warn: `1px solid ${colors
|
|
1516
|
-
" success: `1px solid ${colors
|
|
1517
|
-
" light: `1px solid ${colors
|
|
1556
|
+
" primary: `1px solid ${colors['primary']}`,",
|
|
1557
|
+
" secondary: `1px solid ${colors['secondary']}`,",
|
|
1558
|
+
" tertiary: `1px solid ${colors['tertiary']}`,",
|
|
1559
|
+
" quaternary: `1px solid ${colors['quaternary']}`,",
|
|
1560
|
+
" warn: `1px solid ${colors['warn']}`,",
|
|
1561
|
+
" success: `1px solid ${colors['success']}`,",
|
|
1562
|
+
" light: `1px solid ${colors['outline']}`,",
|
|
1518
1563
|
" dark: `1px solid ${colors['on-background']}`,",
|
|
1519
1564
|
" dotted: `1px dotted ${colors['on-background']}`,",
|
|
1520
1565
|
"});"
|
|
1521
1566
|
].join("\n");
|
|
1522
|
-
var themeExport = (exportName, displayName, colorsConst, radii) => [
|
|
1567
|
+
var themeExport = (exportName, displayName, colorsConst, shadowsConst, radii) => [
|
|
1523
1568
|
`export const ${exportName}: UniTheme = createTheme({`,
|
|
1524
1569
|
` id: '${exportName}',`,
|
|
1525
1570
|
` name: '${displayName}',`,
|
|
1526
1571
|
` colors: ${colorsConst},`,
|
|
1527
1572
|
` borders: borders(${colorsConst}),`,
|
|
1528
1573
|
` components: components(${colorsConst}),`,
|
|
1574
|
+
` shadows: ${shadowsConst},`,
|
|
1529
1575
|
...radii ? [" radii,"] : [],
|
|
1530
1576
|
"});"
|
|
1531
1577
|
].join("\n");
|
|
@@ -1540,7 +1586,7 @@ var themeExport = (exportName, displayName, colorsConst, radii) => [
|
|
|
1540
1586
|
*/
|
|
1541
1587
|
var emitThemeFile = (input) => {
|
|
1542
1588
|
const { darkMode = true, name = "Brand" } = input;
|
|
1543
|
-
const { lightColors, darkColors, radii, report } = generateThemes(input);
|
|
1589
|
+
const { lightColors, darkColors, radii, lightShadows, darkShadows, report } = generateThemes(input);
|
|
1544
1590
|
const id = name.replace(/\W+/g, "") || "Brand";
|
|
1545
1591
|
const regenerate = [
|
|
1546
1592
|
`--brand=${(Array.isArray(input.seed) ? input.seed : [input.seed]).join(",")}`,
|
|
@@ -1554,12 +1600,16 @@ var emitThemeFile = (input) => {
|
|
|
1554
1600
|
exportName: `${id}Light`,
|
|
1555
1601
|
displayName: `${name} Light`,
|
|
1556
1602
|
colorsConst: "lightColors",
|
|
1557
|
-
colors: lightColors
|
|
1603
|
+
colors: lightColors,
|
|
1604
|
+
shadowsConst: "lightShadows",
|
|
1605
|
+
shadows: lightShadows
|
|
1558
1606
|
}, ...darkMode ? [{
|
|
1559
1607
|
exportName: `${id}Dark`,
|
|
1560
1608
|
displayName: `${name} Dark`,
|
|
1561
1609
|
colorsConst: "darkColors",
|
|
1562
|
-
colors: darkColors
|
|
1610
|
+
colors: darkColors,
|
|
1611
|
+
shadowsConst: "darkShadows",
|
|
1612
|
+
shadows: darkShadows
|
|
1563
1613
|
}] : []];
|
|
1564
1614
|
return {
|
|
1565
1615
|
content: [
|
|
@@ -1576,16 +1626,19 @@ var emitThemeFile = (input) => {
|
|
|
1576
1626
|
" type Borders,",
|
|
1577
1627
|
" type Colors,",
|
|
1578
1628
|
" type ComponentThemes,",
|
|
1629
|
+
" type Shadows,",
|
|
1579
1630
|
" type UniTheme,",
|
|
1580
1631
|
"} from '@uni-design-system/uni-core';",
|
|
1581
1632
|
"",
|
|
1582
1633
|
...modes.map(({ colorsConst, colors }) => `const ${colorsConst}: Colors = {\n${recordLiteral(colors, " ")}\n};\n`),
|
|
1634
|
+
"/** Brand-tinted elevation shadows — theme-scoped, edit freely. */",
|
|
1635
|
+
...modes.map(({ shadowsConst, shadows }) => `const ${shadowsConst}: Shadows = {\n${recordLiteral(shadows, " ")}\n};\n`),
|
|
1583
1636
|
bordersLiteral(),
|
|
1584
1637
|
"",
|
|
1585
1638
|
"/**",
|
|
1586
1639
|
" * Sparse component overrides, deep-merged over Uni component defaults: only",
|
|
1587
1640
|
" * what you write here changes. Point components at your own primitives, e.g.:",
|
|
1588
|
-
" * button: { variants: { secondary: { border: `2px dashed ${colors
|
|
1641
|
+
" * button: { variants: { secondary: { border: `2px dashed ${colors['tertiary']}` } } },",
|
|
1589
1642
|
" * input: { options: { borderRadius: 'max' } },",
|
|
1590
1643
|
" */",
|
|
1591
1644
|
"const components = (colors: Colors): ComponentThemes => ({});",
|
|
@@ -1595,7 +1648,7 @@ var emitThemeFile = (input) => {
|
|
|
1595
1648
|
`const radii = {\n${recordLiteral(radii, " ")}\n};`,
|
|
1596
1649
|
""
|
|
1597
1650
|
] : [],
|
|
1598
|
-
...modes.map(({ exportName, displayName, colorsConst }) => `${themeExport(exportName, displayName, colorsConst, !!radii)}\n`),
|
|
1651
|
+
...modes.map(({ exportName, displayName, colorsConst, shadowsConst }) => `${themeExport(exportName, displayName, colorsConst, shadowsConst, !!radii)}\n`),
|
|
1599
1652
|
"/** First key wins as the default theme when registered via UNI_THEMES. */",
|
|
1600
1653
|
`export const ${id}Themes = { ${modes.map((m) => m.exportName).join(", ")} };`,
|
|
1601
1654
|
""
|
|
@@ -1730,14 +1783,16 @@ var darkColors = generatePalette({
|
|
|
1730
1783
|
var DarkTheme = createTheme({
|
|
1731
1784
|
id: "DarkTheme",
|
|
1732
1785
|
name: "Dark Theme",
|
|
1733
|
-
colors: darkColors
|
|
1786
|
+
colors: darkColors,
|
|
1787
|
+
shadows: generateShadows(darkColors, "dark")
|
|
1734
1788
|
});
|
|
1735
1789
|
//#endregion
|
|
1736
1790
|
//#region src/concepts/theme/themes/light.theme.ts
|
|
1737
1791
|
var LightTheme = createTheme({
|
|
1738
1792
|
id: "LightTheme",
|
|
1739
1793
|
name: "Light Theme",
|
|
1740
|
-
colors: lightColors
|
|
1794
|
+
colors: lightColors,
|
|
1795
|
+
shadows: generateShadows(lightColors, "light")
|
|
1741
1796
|
});
|
|
1742
1797
|
//#endregion
|
|
1743
1798
|
//#region src/concepts/theme/theme.records.ts
|
|
@@ -1830,6 +1885,7 @@ exports.fadeIn = fadeIn;
|
|
|
1830
1885
|
exports.fadeOut = fadeOut;
|
|
1831
1886
|
exports.generateColors = generateColors;
|
|
1832
1887
|
exports.generatePalette = generatePalette;
|
|
1888
|
+
exports.generateShadows = generateShadows;
|
|
1833
1889
|
exports.generateThemes = generateThemes;
|
|
1834
1890
|
exports.generateUniThemes = generateUniThemes;
|
|
1835
1891
|
exports.getAnalogousHues = getAnalogousHues;
|