@udixio/theme 0.3.0 → 0.3.1

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/index.cjs.js CHANGED
@@ -1684,6 +1684,96 @@ class Variant {
1684
1684
  }
1685
1685
  }
1686
1686
 
1687
+ const tonalSpotVariant = {
1688
+ name: 'tonalSpot',
1689
+ palettes: {
1690
+ primary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 26 : 32),
1691
+ secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16),
1692
+ tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 20, 71, 161, 333, 360], [-40, 48, -32, 40, -32]), 28),
1693
+ neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5),
1694
+ neutralVariant: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5 * 1.7),
1695
+ error: ({ sourceColorHct }) => {
1696
+ const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
1697
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 60);
1698
+ },
1699
+ },
1700
+ customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16),
1701
+ };
1702
+
1703
+ const getVibrantNeutralHue = (sourceColorHct) => {
1704
+ return getRotatedHue(sourceColorHct, [0, 38, 105, 140, 333, 360], [-14, 10, -14, 10, -14]);
1705
+ };
1706
+ const getVibrantNeutralChroma = (sourceColorHct) => {
1707
+ getVibrantNeutralHue(sourceColorHct);
1708
+ return 28;
1709
+ };
1710
+ const vibrantVariant = {
1711
+ name: 'vibrant',
1712
+ palettes: {
1713
+ primary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 74),
1714
+ secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 38, 105, 140, 333, 360], [-14, 10, -14, 10, -14]), 56),
1715
+ tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 38, 71, 105, 140, 161, 253, 333, 360], [-72, 35, 24, -24, 62, 50, 62, -72]), 56),
1716
+ neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getVibrantNeutralHue(sourceColorHct), getVibrantNeutralChroma(sourceColorHct)),
1717
+ neutralVariant: ({ sourceColorHct }) => {
1718
+ const vibrantNeutralHue = getVibrantNeutralHue(sourceColorHct);
1719
+ const vibrantNeutralChroma = getVibrantNeutralChroma(sourceColorHct);
1720
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(vibrantNeutralHue, vibrantNeutralChroma * 1.29);
1721
+ },
1722
+ error: ({ sourceColorHct }) => {
1723
+ const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
1724
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 80);
1725
+ },
1726
+ },
1727
+ customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, [0, 38, 105, 140, 333, 360], [-14, 10, -14, 10, -14]), 56),
1728
+ };
1729
+
1730
+ const getExpressiveNeutralHue = (sourceColorHct) => {
1731
+ const hue = getRotatedHue(sourceColorHct, [0, 71, 124, 253, 278, 300, 360], [10, 0, 10, 0, 10, 0]);
1732
+ return hue;
1733
+ };
1734
+ const getExpressiveNeutralChroma = (sourceColorHct, isDark) => {
1735
+ const neutralHue = getExpressiveNeutralHue(sourceColorHct);
1736
+ return isDark ? (Hct.isYellow(neutralHue) ? 6 : 14) : 18;
1737
+ };
1738
+ const expressiveVariant = {
1739
+ name: 'expressive',
1740
+ palettes: {
1741
+ primary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 36 : 48),
1742
+ secondary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 105, 140, 204, 253, 278, 300, 333, 360], [-160, 155, -100, 96, -96, -156, -165, -160]), isDark ? 16 : 24),
1743
+ tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 105, 140, 204, 253, 278, 300, 333, 360], [-165, 160, -105, 101, -101, -160, -170, -165]), 48),
1744
+ neutral: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getExpressiveNeutralHue(sourceColorHct), getExpressiveNeutralChroma(sourceColorHct, isDark)),
1745
+ neutralVariant: ({ sourceColorHct, isDark }) => {
1746
+ const expressiveNeutralHue = getExpressiveNeutralHue(sourceColorHct);
1747
+ const expressiveNeutralChroma = getExpressiveNeutralChroma(sourceColorHct, isDark);
1748
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(expressiveNeutralHue, expressiveNeutralChroma *
1749
+ (expressiveNeutralHue >= 105 && expressiveNeutralHue < 125
1750
+ ? 1.6
1751
+ : 2.3));
1752
+ },
1753
+ error: ({ sourceColorHct }) => {
1754
+ const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
1755
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 64);
1756
+ },
1757
+ },
1758
+ customPalettes: ({ colorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, [0, 105, 140, 204, 253, 278, 300, 333, 360], [-160, 155, -100, 96, -96, -156, -165, -160]), isDark ? 16 : 24),
1759
+ };
1760
+
1761
+ const neutralVariant = {
1762
+ name: 'neutral',
1763
+ palettes: {
1764
+ primary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, Hct.isBlue(sourceColorHct.hue) ? 12 : 8),
1765
+ secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, Hct.isBlue(sourceColorHct.hue) ? 6 : 4),
1766
+ tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 38, 105, 161, 204, 278, 333, 360], [-32, 26, 10, -39, 24, -15, -32]), 20),
1767
+ neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4),
1768
+ neutralVariant: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4 * 2.2),
1769
+ error: ({ sourceColorHct }) => {
1770
+ const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
1771
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 50);
1772
+ },
1773
+ },
1774
+ customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, Hct.isBlue(colorHct.hue) ? 6 : 4),
1775
+ };
1776
+
1687
1777
  const defaultColors = (colorService) => {
1688
1778
  const getColor = (key) => {
1689
1779
  return colorService.getColor(key).getMaterialColor();
@@ -2431,22 +2521,6 @@ const AppModule = {
2431
2521
  api: awilix.asClass(API).singleton(),
2432
2522
  };
2433
2523
 
2434
- const tonalSpotVariant = {
2435
- name: 'tonalSpot',
2436
- palettes: {
2437
- primary: ({ sourceColorHct, isDark }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 26 : 32),
2438
- secondary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16),
2439
- tertiary: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 20, 71, 161, 333, 360], [-40, 48, -32, 40, -32]), 28),
2440
- neutral: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5),
2441
- neutralVariant: ({ sourceColorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5 * 1.7),
2442
- error: ({ sourceColorHct }) => {
2443
- const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
2444
- return materialColorUtilities.TonalPalette.fromHueAndChroma(errorHue, 60);
2445
- },
2446
- },
2447
- customPalettes: ({ colorHct }) => materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16),
2448
- };
2449
-
2450
2524
  function defineConfig(configObject) {
2451
2525
  if (!configObject || typeof configObject !== 'object') {
2452
2526
  throw new Error('The configuration is missing or not an object');
@@ -3014,87 +3088,6 @@ const addAllNewComponents = ({ addComponents }, { statePrefix, disabledStyles, t
3014
3088
  addComponents(newComponents);
3015
3089
  };
3016
3090
 
3017
- function createSubTheme({ name, darkMode, isDarkTheme, colors, }) {
3018
- const theme = {
3019
- name: isDarkTheme ? name + 'Dark' : name,
3020
- selectors: isDarkTheme && darkMode === 'class'
3021
- ? [
3022
- '.dark-mode .theme-' + name,
3023
- '.dark-mode.theme-' + name,
3024
- '[data-theme="dark"] .theme-' + name,
3025
- '[data-theme="dark"].theme-' + name,
3026
- ]
3027
- : [
3028
- '.theme-' + name,
3029
- `.theme-${name} .light-mode`,
3030
- `.theme-${name} [data-theme="light"]`,
3031
- `.light-mode .theme-${name}`,
3032
- `.light-mode.theme-${name}`,
3033
- `[data-theme="light"] .theme-${name}`,
3034
- `[data-theme="light"].theme-${name}`,
3035
- ],
3036
- mediaQuery: isDarkTheme && darkMode === 'media'
3037
- ? '@media (prefers-color-scheme: dark)'
3038
- : undefined,
3039
- extend: {
3040
- colors: colors,
3041
- },
3042
- };
3043
- return theme;
3044
- }
3045
- const themer = (args) => {
3046
- const api = args.api;
3047
- const options = {
3048
- defaultTheme: {
3049
- extend: {
3050
- colors: {},
3051
- },
3052
- },
3053
- themes: [
3054
- {
3055
- name: 'darkTheme',
3056
- extend: {
3057
- colors: {},
3058
- },
3059
- },
3060
- ],
3061
- };
3062
- Object.entries(args.colors).forEach(([key, value]) => {
3063
- options.defaultTheme.extend.colors[key] = value.light;
3064
- options.themes[0].extend.colors[key] = value.dark;
3065
- });
3066
- options.themes[0].selectors =
3067
- args.darkMode === 'class'
3068
- ? ['.dark-mode', '[data-theme="dark"]']
3069
- : undefined;
3070
- options.themes[0].mediaQuery =
3071
- args.darkMode === 'media'
3072
- ? '@media (prefers-color-scheme: dark)'
3073
- : undefined;
3074
- if (args.subThemes) {
3075
- Object.entries(args.subThemes).forEach(([key, value]) => {
3076
- api.themes.update({ sourceColorHex: value });
3077
- for (const isDarkTheme of [true, false]) {
3078
- const colors = {};
3079
- api.themes.update({ isDark: isDarkTheme });
3080
- for (const [key, value] of api.colors.getColors().entries()) {
3081
- const newKey = key
3082
- .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2')
3083
- .toLowerCase();
3084
- colors[newKey] = value.getHex();
3085
- }
3086
- options.themes.push(createSubTheme({
3087
- name: key,
3088
- isDarkTheme: isDarkTheme,
3089
- darkMode: args.darkMode,
3090
- colors: colors,
3091
- }));
3092
- }
3093
- });
3094
- }
3095
- return require('tailwindcss-themer')(options);
3096
- };
3097
-
3098
3091
  class TailwindPlugin extends PluginAbstract {
3099
3092
  constructor() {
3100
3093
  super(...arguments);
@@ -3119,8 +3112,8 @@ class TailwindImplPlugin extends PluginImplAbstract {
3119
3112
  if (!tailwindCssPath) {
3120
3113
  throw new Error('Tailwind plugin not found. Please use it first. (@plugin "@udixio/tailwind")');
3121
3114
  }
3122
- const searchPattern = /@plugin "@udixio\/tailwind"\s*{\s*}/;
3123
- const replacement = `@plugin "@udixio/tailwind" {\n}\n@import "./udixio.css";`;
3115
+ const searchPattern = /@import 'tailwindcss';/;
3116
+ const replacement = `@import 'tailwindcss';\n@import "./udixio.css";`;
3124
3117
  if (!getFileContent(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
3125
3118
  replaceFileContent(tailwindCssPath, searchPattern, replacement);
3126
3119
  }
@@ -3217,10 +3210,14 @@ exports.bootstrapFromConfig = bootstrapFromConfig;
3217
3210
  exports.createTheme = createTheme;
3218
3211
  exports.defaultColors = defaultColors;
3219
3212
  exports.defineConfig = defineConfig;
3213
+ exports.expressiveVariant = expressiveVariant;
3220
3214
  exports.extendSpecVersion = extendSpecVersion;
3215
+ exports.font = font;
3221
3216
  exports.getPiecewiseHue = getPiecewiseHue;
3222
3217
  exports.getRotatedHue = getRotatedHue;
3223
3218
  exports.highestSurface = highestSurface;
3224
3219
  exports.importContainer = importContainer;
3220
+ exports.neutralVariant = neutralVariant;
3225
3221
  exports.state = state;
3226
- exports.themer = themer;
3222
+ exports.tonalSpotVariant = tonalSpotVariant;
3223
+ exports.vibrantVariant = vibrantVariant;
package/index.esm.js CHANGED
@@ -1663,6 +1663,96 @@ class Variant {
1663
1663
  }
1664
1664
  }
1665
1665
 
1666
+ const tonalSpotVariant = {
1667
+ name: 'tonalSpot',
1668
+ palettes: {
1669
+ primary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 26 : 32),
1670
+ secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16),
1671
+ tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 20, 71, 161, 333, 360], [-40, 48, -32, 40, -32]), 28),
1672
+ neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5),
1673
+ neutralVariant: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5 * 1.7),
1674
+ error: ({ sourceColorHct }) => {
1675
+ const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
1676
+ return TonalPalette.fromHueAndChroma(errorHue, 60);
1677
+ },
1678
+ },
1679
+ customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(colorHct.hue, 16),
1680
+ };
1681
+
1682
+ const getVibrantNeutralHue = (sourceColorHct) => {
1683
+ return getRotatedHue(sourceColorHct, [0, 38, 105, 140, 333, 360], [-14, 10, -14, 10, -14]);
1684
+ };
1685
+ const getVibrantNeutralChroma = (sourceColorHct) => {
1686
+ getVibrantNeutralHue(sourceColorHct);
1687
+ return 28;
1688
+ };
1689
+ const vibrantVariant = {
1690
+ name: 'vibrant',
1691
+ palettes: {
1692
+ primary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 74),
1693
+ secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 38, 105, 140, 333, 360], [-14, 10, -14, 10, -14]), 56),
1694
+ tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 38, 71, 105, 140, 161, 253, 333, 360], [-72, 35, 24, -24, 62, 50, 62, -72]), 56),
1695
+ neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(getVibrantNeutralHue(sourceColorHct), getVibrantNeutralChroma(sourceColorHct)),
1696
+ neutralVariant: ({ sourceColorHct }) => {
1697
+ const vibrantNeutralHue = getVibrantNeutralHue(sourceColorHct);
1698
+ const vibrantNeutralChroma = getVibrantNeutralChroma(sourceColorHct);
1699
+ return TonalPalette.fromHueAndChroma(vibrantNeutralHue, vibrantNeutralChroma * 1.29);
1700
+ },
1701
+ error: ({ sourceColorHct }) => {
1702
+ const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
1703
+ return TonalPalette.fromHueAndChroma(errorHue, 80);
1704
+ },
1705
+ },
1706
+ customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, [0, 38, 105, 140, 333, 360], [-14, 10, -14, 10, -14]), 56),
1707
+ };
1708
+
1709
+ const getExpressiveNeutralHue = (sourceColorHct) => {
1710
+ const hue = getRotatedHue(sourceColorHct, [0, 71, 124, 253, 278, 300, 360], [10, 0, 10, 0, 10, 0]);
1711
+ return hue;
1712
+ };
1713
+ const getExpressiveNeutralChroma = (sourceColorHct, isDark) => {
1714
+ const neutralHue = getExpressiveNeutralHue(sourceColorHct);
1715
+ return isDark ? (Hct.isYellow(neutralHue) ? 6 : 14) : 18;
1716
+ };
1717
+ const expressiveVariant = {
1718
+ name: 'expressive',
1719
+ palettes: {
1720
+ primary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 36 : 48),
1721
+ secondary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 105, 140, 204, 253, 278, 300, 333, 360], [-160, 155, -100, 96, -96, -156, -165, -160]), isDark ? 16 : 24),
1722
+ tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 105, 140, 204, 253, 278, 300, 333, 360], [-165, 160, -105, 101, -101, -160, -170, -165]), 48),
1723
+ neutral: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(getExpressiveNeutralHue(sourceColorHct), getExpressiveNeutralChroma(sourceColorHct, isDark)),
1724
+ neutralVariant: ({ sourceColorHct, isDark }) => {
1725
+ const expressiveNeutralHue = getExpressiveNeutralHue(sourceColorHct);
1726
+ const expressiveNeutralChroma = getExpressiveNeutralChroma(sourceColorHct, isDark);
1727
+ return TonalPalette.fromHueAndChroma(expressiveNeutralHue, expressiveNeutralChroma *
1728
+ (expressiveNeutralHue >= 105 && expressiveNeutralHue < 125
1729
+ ? 1.6
1730
+ : 2.3));
1731
+ },
1732
+ error: ({ sourceColorHct }) => {
1733
+ const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
1734
+ return TonalPalette.fromHueAndChroma(errorHue, 64);
1735
+ },
1736
+ },
1737
+ customPalettes: ({ colorHct, isDark }) => TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, [0, 105, 140, 204, 253, 278, 300, 333, 360], [-160, 155, -100, 96, -96, -156, -165, -160]), isDark ? 16 : 24),
1738
+ };
1739
+
1740
+ const neutralVariant = {
1741
+ name: 'neutral',
1742
+ palettes: {
1743
+ primary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, Hct.isBlue(sourceColorHct.hue) ? 12 : 8),
1744
+ secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, Hct.isBlue(sourceColorHct.hue) ? 6 : 4),
1745
+ tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 38, 105, 161, 204, 278, 333, 360], [-32, 26, 10, -39, 24, -15, -32]), 20),
1746
+ neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4),
1747
+ neutralVariant: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 1.4 * 2.2),
1748
+ error: ({ sourceColorHct }) => {
1749
+ const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
1750
+ return TonalPalette.fromHueAndChroma(errorHue, 50);
1751
+ },
1752
+ },
1753
+ customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(colorHct.hue, Hct.isBlue(colorHct.hue) ? 6 : 4),
1754
+ };
1755
+
1666
1756
  const defaultColors = (colorService) => {
1667
1757
  const getColor = (key) => {
1668
1758
  return colorService.getColor(key).getMaterialColor();
@@ -2410,22 +2500,6 @@ const AppModule = {
2410
2500
  api: asClass(API).singleton(),
2411
2501
  };
2412
2502
 
2413
- const tonalSpotVariant = {
2414
- name: 'tonalSpot',
2415
- palettes: {
2416
- primary: ({ sourceColorHct, isDark }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, isDark ? 26 : 32),
2417
- secondary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16),
2418
- tertiary: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, [0, 20, 71, 161, 333, 360], [-40, 48, -32, 40, -32]), 28),
2419
- neutral: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5),
2420
- neutralVariant: ({ sourceColorHct }) => TonalPalette.fromHueAndChroma(sourceColorHct.hue, 5 * 1.7),
2421
- error: ({ sourceColorHct }) => {
2422
- const errorHue = getPiecewiseHue(sourceColorHct, [0, 3, 13, 23, 33, 43, 153, 273, 360], [12, 22, 32, 12, 22, 32, 22, 12]);
2423
- return TonalPalette.fromHueAndChroma(errorHue, 60);
2424
- },
2425
- },
2426
- customPalettes: ({ colorHct }) => TonalPalette.fromHueAndChroma(colorHct.hue, 16),
2427
- };
2428
-
2429
2503
  function defineConfig(configObject) {
2430
2504
  if (!configObject || typeof configObject !== 'object') {
2431
2505
  throw new Error('The configuration is missing or not an object');
@@ -2993,87 +3067,6 @@ const addAllNewComponents = ({ addComponents }, { statePrefix, disabledStyles, t
2993
3067
  addComponents(newComponents);
2994
3068
  };
2995
3069
 
2996
- function createSubTheme({ name, darkMode, isDarkTheme, colors, }) {
2997
- const theme = {
2998
- name: isDarkTheme ? name + 'Dark' : name,
2999
- selectors: isDarkTheme && darkMode === 'class'
3000
- ? [
3001
- '.dark-mode .theme-' + name,
3002
- '.dark-mode.theme-' + name,
3003
- '[data-theme="dark"] .theme-' + name,
3004
- '[data-theme="dark"].theme-' + name,
3005
- ]
3006
- : [
3007
- '.theme-' + name,
3008
- `.theme-${name} .light-mode`,
3009
- `.theme-${name} [data-theme="light"]`,
3010
- `.light-mode .theme-${name}`,
3011
- `.light-mode.theme-${name}`,
3012
- `[data-theme="light"] .theme-${name}`,
3013
- `[data-theme="light"].theme-${name}`,
3014
- ],
3015
- mediaQuery: isDarkTheme && darkMode === 'media'
3016
- ? '@media (prefers-color-scheme: dark)'
3017
- : undefined,
3018
- extend: {
3019
- colors: colors,
3020
- },
3021
- };
3022
- return theme;
3023
- }
3024
- const themer = (args) => {
3025
- const api = args.api;
3026
- const options = {
3027
- defaultTheme: {
3028
- extend: {
3029
- colors: {},
3030
- },
3031
- },
3032
- themes: [
3033
- {
3034
- name: 'darkTheme',
3035
- extend: {
3036
- colors: {},
3037
- },
3038
- },
3039
- ],
3040
- };
3041
- Object.entries(args.colors).forEach(([key, value]) => {
3042
- options.defaultTheme.extend.colors[key] = value.light;
3043
- options.themes[0].extend.colors[key] = value.dark;
3044
- });
3045
- options.themes[0].selectors =
3046
- args.darkMode === 'class'
3047
- ? ['.dark-mode', '[data-theme="dark"]']
3048
- : undefined;
3049
- options.themes[0].mediaQuery =
3050
- args.darkMode === 'media'
3051
- ? '@media (prefers-color-scheme: dark)'
3052
- : undefined;
3053
- if (args.subThemes) {
3054
- Object.entries(args.subThemes).forEach(([key, value]) => {
3055
- api.themes.update({ sourceColorHex: value });
3056
- for (const isDarkTheme of [true, false]) {
3057
- const colors = {};
3058
- api.themes.update({ isDark: isDarkTheme });
3059
- for (const [key, value] of api.colors.getColors().entries()) {
3060
- const newKey = key
3061
- .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2')
3062
- .toLowerCase();
3063
- colors[newKey] = value.getHex();
3064
- }
3065
- options.themes.push(createSubTheme({
3066
- name: key,
3067
- isDarkTheme: isDarkTheme,
3068
- darkMode: args.darkMode,
3069
- colors: colors,
3070
- }));
3071
- }
3072
- });
3073
- }
3074
- return require('tailwindcss-themer')(options);
3075
- };
3076
-
3077
3070
  class TailwindPlugin extends PluginAbstract {
3078
3071
  constructor() {
3079
3072
  super(...arguments);
@@ -3098,8 +3091,8 @@ class TailwindImplPlugin extends PluginImplAbstract {
3098
3091
  if (!tailwindCssPath) {
3099
3092
  throw new Error('Tailwind plugin not found. Please use it first. (@plugin "@udixio/tailwind")');
3100
3093
  }
3101
- const searchPattern = /@plugin "@udixio\/tailwind"\s*{\s*}/;
3102
- const replacement = `@plugin "@udixio/tailwind" {\n}\n@import "./udixio.css";`;
3094
+ const searchPattern = /@import 'tailwindcss';/;
3095
+ const replacement = `@import 'tailwindcss';\n@import "./udixio.css";`;
3103
3096
  if (!getFileContent(tailwindCssPath, /@import\s+"\.\/udixio\.css";/)) {
3104
3097
  replaceFileContent(tailwindCssPath, searchPattern, replacement);
3105
3098
  }
@@ -3167,4 +3160,4 @@ const createTheme = () => {
3167
3160
  return plugin.load();
3168
3161
  };
3169
3162
 
3170
- export { API, AppContainer, AppModule, ColorApi, ColorManager, ColorModule, ConfigModule, ConfigService, ConfigurableColor, ContrastCurve, DynamicColor, FontFamily, FontPlugin, PluginAbstract, PluginApi, PluginImplAbstract, PluginModule, Scheme, SchemeManager, TailwindPlugin, ThemeApi, ThemeModule, ToneDeltaPair, Variant, VariantManager, bootstrap, bootstrapFromConfig, createTheme, defaultColors, defineConfig, extendSpecVersion, getPiecewiseHue, getRotatedHue, highestSurface, importContainer, state, themer };
3163
+ export { API, AppContainer, AppModule, ColorApi, ColorManager, ColorModule, ConfigModule, ConfigService, ConfigurableColor, ContrastCurve, DynamicColor, FontFamily, FontPlugin, PluginAbstract, PluginApi, PluginImplAbstract, PluginModule, Scheme, SchemeManager, TailwindPlugin, ThemeApi, ThemeModule, ToneDeltaPair, Variant, VariantManager, bootstrap, bootstrapFromConfig, createTheme, defaultColors, defineConfig, expressiveVariant, extendSpecVersion, font, getPiecewiseHue, getRotatedHue, highestSurface, importContainer, neutralVariant, state, tonalSpotVariant, vibrantVariant };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udixio/theme",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "main": "./index.cjs.js",
5
5
  "module": "./index.esm.js",
6
6
  "dependencies": {
@@ -1,2 +1,2 @@
1
1
  export * from './state';
2
- export * from './themer';
2
+ export * from './font';
@@ -1,5 +1,5 @@
1
1
  export * from './theme.module';
2
- export * from './variant';
2
+ export * from './variants';
3
3
  export * from './scheme.manager';
4
4
  export * from './scheme';
5
5
  export * from './theme.api';
@@ -1,10 +0,0 @@
1
- import { API } from '../../../API';
2
- export declare const themer: (args: {
3
- colors: Record<string, {
4
- light: string;
5
- dark: string;
6
- }>;
7
- darkMode: "class" | "media";
8
- subThemes?: Record<string, string>;
9
- api: API;
10
- }) => any;