@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.
- package/dist/config/config.interface.d.ts +3 -3
- package/dist/plugins/font/font.plugin.d.ts +1 -1
- package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +10 -4
- package/dist/plugins/tailwind/tailwind.plugin.d.ts +3 -2
- package/dist/theme.cjs.development.js +59 -7
- package/dist/theme.cjs.development.js.map +1 -1
- package/dist/theme.cjs.production.min.js +1 -1
- package/dist/theme.cjs.production.min.js.map +1 -1
- package/dist/theme.esm.js +59 -7
- package/dist/theme.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/config/config.interface.ts +3 -3
- package/src/plugins/font/font.plugin.ts +1 -1
- package/src/plugins/tailwind/plugins-tailwind/themer.ts +82 -9
- package/src/plugins/tailwind/tailwind.plugin.ts +10 -5
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { VariantEntity } from '../theme';
|
|
2
1
|
import { AddColorsOptions } from '../color';
|
|
3
|
-
import {
|
|
2
|
+
import { VariantEntity } from '../theme';
|
|
3
|
+
import { PluginConstructor } from '../plugin';
|
|
4
4
|
export interface ConfigInterface {
|
|
5
5
|
sourceColor: string;
|
|
6
|
-
contrastLevel?:
|
|
6
|
+
contrastLevel?: number;
|
|
7
7
|
isDark?: boolean;
|
|
8
8
|
variant?: VariantEntity;
|
|
9
9
|
colors?: AddColorsOptions | AddColorsOptions[];
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
1
|
+
import { PluginAbstract } from '../../plugin';
|
|
2
2
|
import { AppService } from '../../app.service';
|
|
3
3
|
import { Theme } from './main';
|
|
4
|
-
import { FontPlugin } from '../font
|
|
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
|
-
|
|
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 (
|
|
1887
|
-
var key =
|
|
1888
|
-
value =
|
|
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)),
|
|
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;
|