@udixio/theme 1.0.0-beta.22 → 1.0.0-beta.24

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.
@@ -1,9 +1,9 @@
1
- import { VariantEntity } from '../theme';
2
1
  import { AddColorsOptions } from '../color';
3
- import { PluginConstructor } from '../plugin/plugin.service';
2
+ import { VariantEntity } from '../theme';
3
+ import { PluginConstructor } from '../plugin';
4
4
  export interface ConfigInterface {
5
5
  sourceColor: string;
6
- contrastLevel?: 0;
6
+ contrastLevel?: number;
7
7
  isDark?: boolean;
8
8
  variant?: VariantEntity;
9
9
  colors?: AddColorsOptions | AddColorsOptions[];
@@ -1,5 +1,5 @@
1
- import { PluginAbstract } from '../../plugin';
2
1
  import { AppService } from '../../app.service';
2
+ import { PluginAbstract } from '../../plugin';
3
3
  export declare enum FontFamily {
4
4
  Expressive = "expressive",
5
5
  Neutral = "neutral"
@@ -1,4 +1,10 @@
1
- export declare const themer: (colors: Record<string, {
2
- light: string;
3
- dark: string;
4
- }>, darkMode: "class" | "media") => any;
1
+ import { AppService } from '../../../app.service';
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
+ appService: AppService;
10
+ }) => any;
@@ -1,10 +1,11 @@
1
- import { PluginAbstract } from '../../plugin/plugin.abstract';
1
+ import { PluginAbstract } from '../../plugin';
2
2
  import { AppService } from '../../app.service';
3
3
  import { Theme } from './main';
4
- import { FontPlugin } from '../font/font.plugin';
4
+ import { FontPlugin } from '../font';
5
5
  interface TailwindPluginOptions {
6
6
  darkMode?: 'class' | 'media';
7
7
  responsiveBreakPoints?: Record<string, number>;
8
+ subThemes?: Record<string, string>;
8
9
  }
9
10
  export declare class TailwindPlugin extends PluginAbstract {
10
11
  protected appService: AppService;
@@ -1869,7 +1869,25 @@ var addAllNewComponents = function addAllNewComponents(_ref, _ref2, colorKeys) {
1869
1869
  addComponents(newComponents);
1870
1870
  };
1871
1871
 
1872
- var themer = function themer(colors, darkMode) {
1872
+ function createSubTheme(_ref) {
1873
+ var name = _ref.name,
1874
+ darkMode = _ref.darkMode,
1875
+ isDarkTheme = _ref.isDarkTheme,
1876
+ colors = _ref.colors;
1877
+ var theme = {
1878
+ name: isDarkTheme ? name + 'Dark' : name,
1879
+ selectors: isDarkTheme && darkMode === 'class' ? ['.dark-mode .theme-' + name, '.dark-mode.theme-' + name, '[data-theme="dark"] .theme-' + name, '[data-theme="dark"].theme-' + name] : ['.theme-' + name],
1880
+ mediaQuery: '@media (prefers-color-scheme: dark)',
1881
+ extend: {
1882
+ colors: colors
1883
+ }
1884
+ };
1885
+ return theme;
1886
+ }
1887
+ var themer = function themer(args) {
1888
+ var _args$appService = args.appService,
1889
+ themeService = _args$appService.themeService,
1890
+ colorService = _args$appService.colorService;
1873
1891
  var options = {
1874
1892
  defaultTheme: {
1875
1893
  extend: {
@@ -1883,14 +1901,43 @@ var themer = function themer(colors, darkMode) {
1883
1901
  }
1884
1902
  }]
1885
1903
  };
1886
- Object.entries(colors).forEach(function (_ref) {
1887
- var key = _ref[0],
1888
- value = _ref[1];
1904
+ Object.entries(args.colors).forEach(function (_ref2) {
1905
+ var key = _ref2[0],
1906
+ value = _ref2[1];
1889
1907
  options.defaultTheme.extend.colors[key] = value.light;
1890
1908
  options.themes[0].extend.colors[key] = value.dark;
1891
1909
  });
1892
- options.themes[0].selectors = darkMode === 'class' ? ['.dark-mode', '[data-theme="dark"]'] : undefined;
1893
- options.themes[0].mediaQuery = darkMode === 'media' ? '@media (prefers-color-scheme: dark)' : undefined;
1910
+ options.themes[0].selectors = args.darkMode === 'class' ? ['.dark-mode', '[data-theme="dark"]'] : undefined;
1911
+ options.themes[0].mediaQuery = args.darkMode === 'media' ? '@media (prefers-color-scheme: dark)' : undefined;
1912
+ if (args.subThemes) {
1913
+ Object.entries(args.subThemes).forEach(function (_ref3) {
1914
+ var key = _ref3[0],
1915
+ value = _ref3[1];
1916
+ themeService.update({
1917
+ sourceColorHex: value
1918
+ });
1919
+ for (var _i = 0, _arr = [true, false]; _i < _arr.length; _i++) {
1920
+ var isDarkTheme = _arr[_i];
1921
+ var colors = {};
1922
+ themeService.update({
1923
+ isDark: isDarkTheme
1924
+ });
1925
+ for (var _iterator = _createForOfIteratorHelperLoose(colorService.getColors().entries()), _step; !(_step = _iterator()).done;) {
1926
+ var _step$value = _step.value,
1927
+ _key = _step$value[0],
1928
+ _value = _step$value[1];
1929
+ var newKey = _key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
1930
+ colors[newKey] = _value.getHex();
1931
+ }
1932
+ options.themes.push(createSubTheme({
1933
+ name: key,
1934
+ isDarkTheme: isDarkTheme,
1935
+ darkMode: args.darkMode,
1936
+ colors: colors
1937
+ }));
1938
+ }
1939
+ });
1940
+ }
1894
1941
  return require('tailwindcss-themer')(options);
1895
1942
  };
1896
1943
 
@@ -1992,7 +2039,12 @@ var TailwindPlugin = /*#__PURE__*/function (_PluginAbstract) {
1992
2039
  return {
1993
2040
  colors: {},
1994
2041
  fontFamily: fontFamily,
1995
- plugins: [state(Object.keys(colors)), themer(colors, this.options.darkMode), font(fontStyles, this.options.responsiveBreakPoints)]
2042
+ plugins: [state(Object.keys(colors)), font(fontStyles, this.options.responsiveBreakPoints), themer({
2043
+ colors: colors,
2044
+ darkMode: this.options.darkMode,
2045
+ subThemes: this.options.subThemes,
2046
+ appService: this.appService
2047
+ })]
1996
2048
  };
1997
2049
  };
1998
2050
  return TailwindPlugin;