cmat 0.0.21 → 0.0.22

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.
Files changed (92) hide show
  1. package/components/material-color-picker/base-color.d.ts +1 -0
  2. package/fesm2022/cmat-components-adapter.mjs +9 -9
  3. package/fesm2022/cmat-components-breadcrumb.mjs +9 -9
  4. package/fesm2022/cmat-components-card.mjs +4 -4
  5. package/fesm2022/cmat-components-card.mjs.map +1 -1
  6. package/fesm2022/cmat-components-carousel.mjs +12 -12
  7. package/fesm2022/cmat-components-cascade.mjs +9 -9
  8. package/fesm2022/cmat-components-chip-input.mjs +3 -3
  9. package/fesm2022/cmat-components-custom-formly.mjs +94 -94
  10. package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
  11. package/fesm2022/cmat-components-date-range.mjs +3 -3
  12. package/fesm2022/cmat-components-drawer.mjs +6 -6
  13. package/fesm2022/cmat-components-fullscreen.mjs +3 -3
  14. package/fesm2022/cmat-components-highlight.mjs +6 -6
  15. package/fesm2022/cmat-components-image-viewer.mjs +3 -3
  16. package/fesm2022/cmat-components-json-editor.mjs +3 -3
  17. package/fesm2022/cmat-components-knob-input.mjs +3 -3
  18. package/fesm2022/cmat-components-masonry.mjs +3 -3
  19. package/fesm2022/cmat-components-material-color-picker.mjs +16 -4
  20. package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
  21. package/fesm2022/cmat-components-material-datetimepicker.mjs +43 -43
  22. package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
  23. package/fesm2022/cmat-components-navigation.mjs +40 -40
  24. package/fesm2022/cmat-components-navigation.mjs.map +1 -1
  25. package/fesm2022/cmat-components-opt-input.mjs +3 -3
  26. package/fesm2022/cmat-components-org-chart.mjs +9 -9
  27. package/fesm2022/cmat-components-pagination.mjs +15 -13
  28. package/fesm2022/cmat-components-pagination.mjs.map +1 -1
  29. package/fesm2022/cmat-components-password-strength.mjs +9 -9
  30. package/fesm2022/cmat-components-popover.mjs +9 -9
  31. package/fesm2022/cmat-components-progress-bar.mjs +4 -4
  32. package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
  33. package/fesm2022/cmat-components-rating.mjs +3 -3
  34. package/fesm2022/cmat-components-select-search.mjs +9 -9
  35. package/fesm2022/cmat-components-select-table.mjs +4 -4
  36. package/fesm2022/cmat-components-select-table.mjs.map +1 -1
  37. package/fesm2022/cmat-components-select-tree.mjs +3 -3
  38. package/fesm2022/cmat-components-speed-dial.mjs +9 -9
  39. package/fesm2022/cmat-components-timeline.mjs +13 -13
  40. package/fesm2022/cmat-components-timeline.mjs.map +1 -1
  41. package/fesm2022/cmat-components-toast.mjs +9 -9
  42. package/fesm2022/cmat-components-transfer-picker.mjs +19 -19
  43. package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
  44. package/fesm2022/cmat-components-treetable.mjs +6 -6
  45. package/fesm2022/cmat-components-upload.mjs +11 -11
  46. package/fesm2022/cmat-components-upload.mjs.map +1 -1
  47. package/fesm2022/cmat-directives-animate-on-scroll.mjs +9 -11
  48. package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
  49. package/fesm2022/cmat-directives-arrow-cursor.mjs +3 -3
  50. package/fesm2022/cmat-directives-autofocus.mjs +3 -3
  51. package/fesm2022/cmat-directives-data-exporter.mjs +21 -21
  52. package/fesm2022/cmat-directives-debounce.mjs +9 -9
  53. package/fesm2022/cmat-directives-digit-only.mjs +6 -6
  54. package/fesm2022/cmat-directives-equal-validator.mjs +3 -3
  55. package/fesm2022/cmat-lib-mock-api.mjs +6 -6
  56. package/fesm2022/cmat-pipes-bytes.mjs +3 -3
  57. package/fesm2022/cmat-pipes-date-format.mjs +3 -3
  58. package/fesm2022/cmat-pipes-find-by-key.mjs +3 -3
  59. package/fesm2022/cmat-pipes-group-by.mjs +3 -3
  60. package/fesm2022/cmat-pipes-keys.mjs +3 -3
  61. package/fesm2022/cmat-pipes-secure.mjs +3 -3
  62. package/fesm2022/cmat-pipes-uppercase.mjs +3 -3
  63. package/fesm2022/cmat-services-alert.mjs +3 -3
  64. package/fesm2022/cmat-services-config.mjs +6 -6
  65. package/fesm2022/cmat-services-confirmation.mjs +7 -7
  66. package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
  67. package/fesm2022/cmat-services-data.mjs +3 -3
  68. package/fesm2022/cmat-services-export-as.mjs +3 -3
  69. package/fesm2022/cmat-services-loading.mjs +6 -6
  70. package/fesm2022/cmat-services-local-storage.mjs +3 -3
  71. package/fesm2022/cmat-services-media-watcher.mjs +3 -3
  72. package/fesm2022/cmat-services-platform.mjs +3 -3
  73. package/fesm2022/cmat-services-splash-screen.mjs +3 -3
  74. package/fesm2022/cmat-services-title.mjs +3 -3
  75. package/fesm2022/cmat-services-translation.mjs +3 -3
  76. package/fesm2022/cmat-services-utils.mjs +3 -3
  77. package/package.json +35 -35
  78. package/styles/components/bundle.scss +23 -25
  79. package/styles/components/input.scss +2 -0
  80. package/styles/overrides/angular-material.scss +75 -59
  81. package/styles/overrides/fullcalendar.scss +3 -1
  82. package/styles/overrides/quill.scss +8 -6
  83. package/styles/tailwind.scss +101 -13
  84. package/styles/user-themes.scss +1 -1
  85. package/tailwind/plugins/helpers.js +16 -0
  86. package/tailwind/plugins/scrollbar/index.js +31 -0
  87. package/tailwind/plugins/scrollbar/typedefs.js +9 -0
  88. package/tailwind/plugins/scrollbar/utilities.js +201 -0
  89. package/tailwind/plugins/scrollbar/variants.js +30 -0
  90. package/tailwind/plugins/theming.js +257 -256
  91. package/tailwind/plugins/utilities.js +12 -25
  92. package/tailwind/utils/json-to-sass-map.js +28 -36
@@ -1,256 +1,257 @@
1
- const chroma = require('chroma-js');
2
- const _ = require('lodash');
3
- const fs = require('fs');
4
- const path = require('path');
5
- const colors = require('tailwindcss/colors');
6
- const plugin = require('tailwindcss/plugin');
7
- const flattenColorPalette = require('tailwindcss/lib/util/flattenColorPalette').default;
8
- const generateContrasts = require(path.resolve(__dirname, ('../utils/generate-contrasts')));
9
- const jsonToSassMap = require(path.resolve(__dirname, ('../utils/json-to-sass-map')));
10
-
11
- // -----------------------------------------------------------------------------------------------------
12
- // @ Utilities
13
- // -----------------------------------------------------------------------------------------------------
14
-
15
- /**
16
- * Normalizes the provided theme by omitting empty values and values that
17
- * start with "on" from each palette. Also sets the correct DEFAULT value
18
- * of each palette.
19
- *
20
- * @param theme
21
- */
22
- const normalizeTheme = (theme) => {
23
- return _.fromPairs(_.map(_.omitBy(theme, (palette, paletteName) => paletteName.startsWith('on') || _.isEmpty(palette)),
24
- (palette, paletteName) => [
25
- paletteName,
26
- {
27
- ...palette,
28
- DEFAULT: palette['DEFAULT'] || palette[500]
29
- }
30
- ]
31
- ));
32
- };
33
-
34
- // -----------------------------------------------------------------------------------------------------
35
- // @ cmat TailwindCSS Main Plugin
36
- // -----------------------------------------------------------------------------------------------------
37
- const theming = plugin.withOptions((options) => ({
38
- addComponents,
39
- e,
40
- theme
41
- }) => {
42
- /**
43
- * Create user themes object by going through the provided themes and
44
- * merging them with the provided "default" so, we can have a complete
45
- * set of color palettes for each user theme.
46
- */
47
- const userThemes = _.fromPairs(_.map(options.themes, (theme, themeName) => [
48
- themeName,
49
- _.defaults({}, theme, options.themes['default'])
50
- ]));
51
-
52
- /**
53
- * Normalize the themes and assign it to the themes object. This will
54
- * be the final object that we create a SASS map from
55
- */
56
- let themes = _.fromPairs(_.map(userThemes, (theme, themeName) => [
57
- themeName,
58
- normalizeTheme(theme)
59
- ]));
60
-
61
- /**
62
- * Go through the themes to generate the contrasts and filter the
63
- * palettes to only have "primary", "accent" and "warn" objects.
64
- */
65
- themes = _.fromPairs(_.map(themes, (theme, themeName) => [
66
- themeName,
67
- _.pick(
68
- _.fromPairs(_.map(theme, (palette, paletteName) => [
69
- paletteName,
70
- {
71
- ...palette,
72
- contrast: _.fromPairs(_.map(generateContrasts(palette), (color, hue) => [
73
- hue,
74
- _.get(userThemes[themeName], [`on-${paletteName}`, hue]) || color
75
- ]))
76
- }
77
- ])),
78
- ['primary', 'accent', 'warn']
79
- )
80
- ]));
81
-
82
- /**
83
- * Go through the themes and attach appropriate class selectors so,
84
- * we can use them to encapsulate each theme.
85
- */
86
- themes = _.fromPairs(_.map(themes, (theme, themeName) => [
87
- themeName,
88
- {
89
- selector: `".theme-${themeName}"`,
90
- ...theme
91
- }
92
- ]));
93
-
94
- /* Generate the SASS map using the themes object */
95
- const sassMap = jsonToSassMap(JSON.stringify({ 'user-themes': themes }));
96
-
97
- /* Get the file path */
98
- const filename = path.resolve(__dirname, ('../../styles/user-themes.scss'));
99
-
100
- /* Read the file and get its data */
101
- let data;
102
- try {
103
- data = fs.readFileSync(filename, { encoding: 'utf8' });
104
- }
105
- catch (err) {
106
- console.error(err);
107
- }
108
-
109
- /* Write the file if the map has been changed */
110
- if (data !== sassMap) {
111
- try {
112
- fs.writeFileSync(filename, sassMap, { encoding: 'utf8' });
113
- }
114
- catch (err) {
115
- console.error(err);
116
- }
117
- }
118
-
119
- /**
120
- * Iterate through the user's themes and build Tailwind components containing
121
- * CSS Custom Properties using the colors from them. This allows switching
122
- * themes by simply replacing a class name as well as nesting them.
123
- */
124
- addComponents(
125
- _.fromPairs(_.map(options.themes, (theme, themeName) => [
126
- themeName === 'default' ? 'body, .theme-default' : `.theme-${e(themeName)}`,
127
- _.fromPairs(_.flatten(_.map(flattenColorPalette(_.fromPairs(_.flatten(_.map(normalizeTheme(theme), (palette, paletteName) => [
128
- [
129
- e(paletteName),
130
- palette
131
- ],
132
- [
133
- `on-${e(paletteName)}`,
134
- _.fromPairs(_.map(generateContrasts(palette), (color, hue) => [hue, _.get(theme, [`on-${paletteName}`, hue]) || color]))
135
- ]
136
- ])
137
- ))), (value, key) => [[`--cmat-${e(key)}`, value], [`--cmat-${e(key)}-rgb`, chroma(value).rgb().join(',')]])))
138
- ]))
139
- );
140
-
141
- /**
142
- * Generate scheme based css custom properties and utility classes
143
- */
144
- const schemeCustomProps = _.map(['light', 'dark'], (colorScheme) => {
145
- const isDark = colorScheme === 'dark';
146
- const background = theme(`cmat.customProps.background.${colorScheme}`);
147
- const foreground = theme(`cmat.customProps.foreground.${colorScheme}`);
148
- const lightSchemeSelectors = 'body.light, .light, .dark .light';
149
- const darkSchemeSelectors = 'body.dark, .dark, .light .dark';
150
-
151
- return {
152
- [(isDark ? darkSchemeSelectors : lightSchemeSelectors)]: {
153
-
154
- /**
155
- * If a custom property is not available, browsers will use
156
- * the fallback value. In this case, we want to use '--is-dark'
157
- * as the indicator of a dark theme so, we can use it like this:
158
- * background-color: var(--is-dark, red);
159
- *
160
- * If we set '--is-dark' as "true" on dark themes, the above rule
161
- * won't work because of the said "fallback value" logic. Therefore,
162
- * we set the '--is-dark' to "false" on light themes and not set it
163
- * at all on dark themes so that the fallback value can be used on
164
- * dark themes.
165
- *
166
- * On light themes, since '--is-dark' exists, the above rule will be
167
- * interpolated as:
168
- * "background-color: false"
169
- *
170
- * On dark themes, since '--is-dark' doesn't exist, the fallback value
171
- * will be used ('red' in this case) and the rule will be interpolated as:
172
- * "background-color: red"
173
- *
174
- * It's easier to understand and remember like this.
175
- */
176
- ...(!isDark ? { '--is-dark': 'false' } : {}),
177
-
178
- /* Generate custom properties from customProps */
179
- ..._.fromPairs(_.flatten(_.map(background, (value, key) => [[`--cmat-${e(key)}`, value], [`--cmat-${e(key)}-rgb`, chroma(value).rgb().join(',')]]))),
180
- ..._.fromPairs(_.flatten(_.map(foreground, (value, key) => [[`--cmat-${e(key)}`, value], [`--cmat-${e(key)}-rgb`, chroma(value).rgb().join(',')]])))
181
- }
182
- };
183
- });
184
-
185
- const schemeUtilities = (() => {
186
- /* Generate general styles & utilities */
187
- return {};
188
- })();
189
-
190
- addComponents(schemeCustomProps);
191
- addComponents(schemeUtilities);
192
- },
193
- (options) => {
194
- return {
195
- theme: {
196
- extend: {
197
- /**
198
- * Add 'Primary', 'Accent' and 'Warn' palettes as colors so all color utilities
199
- * are generated for them; "bg-primary", "text-on-primary", "bg-accent-600" etc.
200
- * This will also allow using arbitrary values with them such as opacity and such.
201
- */
202
- colors: _.fromPairs(_.flatten(_.map(_.keys(flattenColorPalette(normalizeTheme(options.themes.default))), (name) => [
203
- [name, `rgba(var(--cmat-${name}-rgb), <alpha-value>)`],
204
- [`on-${name}`, `rgba(var(--cmat-on-${name}-rgb), <alpha-value>)`]
205
- ])))
206
- },
207
- cmat: {
208
- customProps: {
209
- background: {
210
- light: {
211
- 'bg-app-bar': '#FFFFFF',
212
- 'bg-card': '#FFFFFF',
213
- 'bg-default': colors.slate[100],
214
- 'bg-dialog': '#FFFFFF',
215
- 'bg-hover': chroma(colors.slate[400]).alpha(0.12).css(),
216
- 'bg-status-bar': colors.slate[300]
217
- },
218
- dark: {
219
- 'bg-app-bar': colors.slate[900],
220
- 'bg-card': colors.slate[800],
221
- 'bg-default': colors.slate[900],
222
- 'bg-dialog': colors.slate[800],
223
- 'bg-hover': 'rgba(255, 255, 255, 0.05)',
224
- 'bg-status-bar': colors.slate[900]
225
- }
226
- },
227
- foreground: {
228
- light: {
229
- 'text-default': colors.slate[800],
230
- 'text-secondary': colors.slate[500],
231
- 'text-hint': colors.slate[400],
232
- 'text-disabled': colors.slate[400],
233
- 'border': colors.slate[200],
234
- 'divider': colors.slate[200],
235
- 'icon': colors.slate[500],
236
- 'mat-icon': colors.slate[500]
237
- },
238
- dark: {
239
- 'text-default': '#FFFFFF',
240
- 'text-secondary': colors.slate[400],
241
- 'text-hint': colors.slate[500],
242
- 'text-disabled': colors.slate[600],
243
- 'border': chroma(colors.slate[100]).alpha(0.12).css(),
244
- 'divider': chroma(colors.slate[100]).alpha(0.12).css(),
245
- 'icon': colors.slate[400],
246
- 'mat-icon': colors.slate[400]
247
- }
248
- }
249
- }
250
- }
251
- }
252
- };
253
- }
254
- );
255
-
256
- module.exports = theming;
1
+ const chroma = require('chroma-js');
2
+ const _ = require('lodash');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const colors = require('tailwindcss/colors');
6
+ const plugin = require('tailwindcss/plugin');
7
+ const flattenColorPaletteImport = require('tailwindcss/lib/util/flattenColorPalette');
8
+ const { importDefault } = require(path.resolve(__dirname, ('./helpers')));
9
+ const flattenColorPalette = importDefault(flattenColorPaletteImport);
10
+ const generateContrasts = require(path.resolve(__dirname, ('../utils/generate-contrasts')));
11
+ const jsonToSassMap = require(path.resolve(__dirname, ('../utils/json-to-sass-map')));
12
+
13
+ // -----------------------------------------------------------------------------------------------------
14
+ // @ Utilities
15
+ // -----------------------------------------------------------------------------------------------------
16
+
17
+ /**
18
+ * Normalizes the provided theme by omitting empty values and values that
19
+ * start with "on" from each palette. Also sets the correct DEFAULT value
20
+ * of each palette.
21
+ *
22
+ * @param theme
23
+ */
24
+ const normalizeTheme = (theme) => {
25
+ return _.fromPairs(_.map(_.omitBy(theme, (palette, paletteName) => paletteName.startsWith('on') || _.isEmpty(palette)),
26
+ (palette, paletteName) => [
27
+ paletteName,
28
+ {
29
+ ...palette,
30
+ DEFAULT: palette['DEFAULT'] || palette[500]
31
+ }
32
+ ]
33
+ ));
34
+ };
35
+
36
+ // -----------------------------------------------------------------------------------------------------
37
+ // @ cmat TailwindCSS Main Plugin
38
+ // -----------------------------------------------------------------------------------------------------
39
+ const theming = plugin.withOptions((options) => ({
40
+ addComponents,
41
+ theme
42
+ }) => {
43
+ /**
44
+ * Create user themes object by going through the provided themes and
45
+ * merging them with the provided "default" so, we can have a complete
46
+ * set of color palettes for each user theme.
47
+ */
48
+ const userThemes = _.fromPairs(_.map(options.themes, (theme, themeName) => [
49
+ themeName,
50
+ _.defaults({}, theme, options.themes['default'])
51
+ ]));
52
+
53
+ /**
54
+ * Normalize the themes and assign it to the themes object. This will
55
+ * be the final object that we create a SASS map from
56
+ */
57
+ let themes = _.fromPairs(_.map(userThemes, (theme, themeName) => [
58
+ themeName,
59
+ normalizeTheme(theme)
60
+ ]));
61
+
62
+ /**
63
+ * Go through the themes to generate the contrasts and filter the
64
+ * palettes to only have "primary", "accent" and "warn" objects.
65
+ */
66
+ themes = _.fromPairs(_.map(themes, (theme, themeName) => [
67
+ themeName,
68
+ _.pick(
69
+ _.fromPairs(_.map(theme, (palette, paletteName) => [
70
+ paletteName,
71
+ {
72
+ ...palette,
73
+ contrast: _.fromPairs(_.map(generateContrasts(palette), (color, hue) => [
74
+ hue,
75
+ _.get(userThemes[themeName], [`on-${paletteName}`, hue]) || color
76
+ ]))
77
+ }
78
+ ])),
79
+ ['primary', 'accent', 'warn']
80
+ )
81
+ ]));
82
+
83
+ /**
84
+ * Go through the themes and attach appropriate class selectors so,
85
+ * we can use them to encapsulate each theme.
86
+ */
87
+ themes = _.fromPairs(_.map(themes, (theme, themeName) => [
88
+ themeName,
89
+ {
90
+ selector: `".theme-${themeName}"`,
91
+ ...theme
92
+ }
93
+ ]));
94
+
95
+ /* Generate the SASS map using the themes object */
96
+ const sassMap = jsonToSassMap(JSON.stringify({ 'user-themes': themes }));
97
+
98
+ /* Get the file path */
99
+ const filename = path.resolve(__dirname, ('../../styles/user-themes.scss'));
100
+
101
+ /* Read the file and get its data */
102
+ let data;
103
+ try {
104
+ data = fs.readFileSync(filename, { encoding: 'utf8' });
105
+ }
106
+ catch (err) {
107
+ console.error(err);
108
+ }
109
+
110
+ /* Write the file if the map has been changed */
111
+ if (data !== sassMap) {
112
+ try {
113
+ fs.writeFileSync(filename, sassMap, { encoding: 'utf8' });
114
+ }
115
+ catch (err) {
116
+ console.error(err);
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Iterate through the user's themes and build Tailwind components containing
122
+ * CSS Custom Properties using the colors from them. This allows switching
123
+ * themes by simply replacing a class name as well as nesting them.
124
+ */
125
+ addComponents(
126
+ _.fromPairs(_.map(options.themes, (theme, themeName) => [
127
+ themeName === 'default' ? '.theme-default' : `.theme-${themeName}`,
128
+ _.fromPairs(_.flatten(_.map(flattenColorPalette(_.fromPairs(_.flatten(_.map(normalizeTheme(theme), (palette, paletteName) => [
129
+ [
130
+ paletteName,
131
+ palette
132
+ ],
133
+ [
134
+ `on-${paletteName}`,
135
+ _.fromPairs(_.map(generateContrasts(palette), (color, hue) => [hue, _.get(theme, [`on-${paletteName}`, hue]) || color]))
136
+ ]
137
+ ])
138
+ ))), (value, key) => [[`--cmat-${key}`, value], [`--cmat-${key}-rgb`, chroma(value).rgb().join(',')]])))
139
+ ]))
140
+ );
141
+
142
+ /**
143
+ * Generate scheme based css custom properties and utility classes
144
+ */
145
+ const schemeCustomProps = _.map(['light', 'dark'], (colorScheme) => {
146
+ const isDark = colorScheme === 'dark';
147
+ const background = theme(`cmat.customProps.background.${colorScheme}`);
148
+ const foreground = theme(`cmat.customProps.foreground.${colorScheme}`);
149
+ const lightSchemeSelectors = 'body.light, .light, .dark .light';
150
+ const darkSchemeSelectors = 'body.dark, .dark, .light .dark';
151
+
152
+ return {
153
+ [(isDark ? darkSchemeSelectors : lightSchemeSelectors)]: {
154
+
155
+ /**
156
+ * If a custom property is not available, browsers will use
157
+ * the fallback value. In this case, we want to use '--is-dark'
158
+ * as the indicator of a dark theme so, we can use it like this:
159
+ * background-color: var(--is-dark, red);
160
+ *
161
+ * If we set '--is-dark' as "true" on dark themes, the above rule
162
+ * won't work because of the said "fallback value" logic. Therefore,
163
+ * we set the '--is-dark' to "false" on light themes and not set it
164
+ * at all on dark themes so that the fallback value can be used on
165
+ * dark themes.
166
+ *
167
+ * On light themes, since '--is-dark' exists, the above rule will be
168
+ * interpolated as:
169
+ * "background-color: false"
170
+ *
171
+ * On dark themes, since '--is-dark' doesn't exist, the fallback value
172
+ * will be used ('red' in this case) and the rule will be interpolated as:
173
+ * "background-color: red"
174
+ *
175
+ * It's easier to understand and remember like this.
176
+ */
177
+ ...(!isDark ? { '--is-dark': 'false' } : {}),
178
+
179
+ /* Generate custom properties from customProps */
180
+ ..._.fromPairs(_.flatten(_.map(background, (value, key) => [[`--cmat-${key}`, value], [`--cmat-${key}-rgb`, chroma(value).rgb().join(',')]]))),
181
+ ..._.fromPairs(_.flatten(_.map(foreground, (value, key) => [[`--cmat-${key}`, value], [`--cmat-${key}-rgb`, chroma(value).rgb().join(',')]])))
182
+ }
183
+ };
184
+ });
185
+
186
+ const schemeUtilities = (() => {
187
+ /* Generate general styles & utilities */
188
+ return {};
189
+ })();
190
+
191
+ addComponents(schemeCustomProps);
192
+ addComponents(schemeUtilities);
193
+ },
194
+ (options) => {
195
+ return {
196
+ theme: {
197
+ extend: {
198
+ /**
199
+ * Add 'Primary', 'Accent' and 'Warn' palettes as colors so all color utilities
200
+ * are generated for them; "bg-primary", "text-on-primary", "bg-accent-600" etc.
201
+ * This will also allow using arbitrary values with them such as opacity and such.
202
+ */
203
+ colors: _.fromPairs(_.flatten(_.map(_.keys(flattenColorPalette(normalizeTheme(options.themes.default))), (name) => [
204
+ [name, `rgba(var(--cmat-${name}-rgb), <alpha-value>)`],
205
+ [`on-${name}`, `rgba(var(--cmat-on-${name}-rgb), <alpha-value>)`]
206
+ ])))
207
+ },
208
+ cmat: {
209
+ customProps: {
210
+ background: {
211
+ light: {
212
+ 'bg-app-bar': '#FFFFFF',
213
+ 'bg-card': '#FFFFFF',
214
+ 'bg-default': colors.slate[100],
215
+ 'bg-dialog': '#FFFFFF',
216
+ 'bg-hover': chroma(colors.slate[400]).alpha(0.12).css(),
217
+ 'bg-status-bar': colors.slate[300]
218
+ },
219
+ dark: {
220
+ 'bg-app-bar': colors.slate[900],
221
+ 'bg-card': colors.slate[800],
222
+ 'bg-default': colors.slate[900],
223
+ 'bg-dialog': colors.slate[800],
224
+ 'bg-hover': 'rgba(255, 255, 255, 0.05)',
225
+ 'bg-status-bar': colors.slate[900]
226
+ }
227
+ },
228
+ foreground: {
229
+ light: {
230
+ 'text-default': colors.slate[800],
231
+ 'text-secondary': colors.slate[500],
232
+ 'text-hint': colors.slate[400],
233
+ 'text-disabled': colors.slate[400],
234
+ 'border': colors.slate[200],
235
+ 'divider': colors.slate[200],
236
+ 'icon': colors.slate[500],
237
+ 'mat-icon': colors.slate[500]
238
+ },
239
+ dark: {
240
+ 'text-default': '#FFFFFF',
241
+ 'text-secondary': colors.slate[400],
242
+ 'text-hint': colors.slate[500],
243
+ 'text-disabled': colors.slate[600],
244
+ 'border': chroma(colors.slate[100]).alpha(0.12).css(),
245
+ 'divider': chroma(colors.slate[100]).alpha(0.12).css(),
246
+ 'icon': colors.slate[400],
247
+ 'mat-icon': colors.slate[400]
248
+ }
249
+ }
250
+ }
251
+ }
252
+ }
253
+ };
254
+ }
255
+ );
256
+
257
+ module.exports = theming;
@@ -9,49 +9,36 @@ module.exports = plugin(({
9
9
  * be defined before pretty much everything else.
10
10
  */
11
11
  addComponents(
12
- {
13
- '.mat-icon': {
14
- '--tw-text-opacity': '1',
15
- color: 'rgba(var(--cmat-icon-rgb), var(--tw-text-opacity))'
16
- },
12
+ {
17
13
  '.text-default': {
18
- '--tw-text-opacity': '1 !important',
19
- color: 'rgba(var(--cmat-text-default-rgb), var(--tw-text-opacity)) !important'
14
+ color: 'rgba(var(--cmat-text-default-rgb), 1)'
20
15
  },
21
16
  '.text-secondary': {
22
- '--tw-text-opacity': '1 !important',
23
- color: 'rgba(var(--cmat-text-secondary-rgb), var(--tw-text-opacity)) !important'
17
+ color: 'rgba(var(--cmat-text-secondary-rgb), 1)'
24
18
  },
25
19
  '.text-hint': {
26
- '--tw-text-opacity': '1 !important',
27
- color: 'rgba(var(--cmat-text-hint-rgb), var(--tw-text-opacity)) !important'
20
+ color: 'rgba(var(--cmat-text-hint-rgb), 1)'
28
21
  },
29
22
  '.text-disabled': {
30
- '--tw-text-opacity': '0.8 !important',
31
- color: 'rgba(var(--cmat-text-disabled-rgb), var(--tw-text-opacity)) !important'
23
+ color: 'rgba(var(--cmat-text-disabled-rgb), 1)'
32
24
  },
33
25
  '.divider': {
34
- color: 'var(--cmat-divider) !important'
26
+ color: 'var(--cmat-divider)'
35
27
  },
36
28
  '.bg-card': {
37
- '--tw-bg-opacity': '1 !important',
38
- backgroundColor: 'rgba(var(--cmat-bg-card-rgb), var(--tw-bg-opacity)) !important'
29
+ backgroundColor: 'rgba(var(--cmat-bg-card-rgb), 1)'
39
30
  },
40
31
  '.bg-default': {
41
- '--tw-bg-opacity': '1 !important',
42
- backgroundColor: 'rgba(var(--cmat-bg-default-rgb), var(--tw-bg-opacity)) !important'
32
+ backgroundColor: 'rgba(var(--cmat-bg-default-rgb), 1)'
43
33
  },
44
34
  '.bg-dialog': {
45
- '--tw-bg-opacity': '1 !important',
46
- backgroundColor: 'rgba(var(--cmat-bg-dialog-rgb), var(--tw-bg-opacity)) !important'
35
+ backgroundColor: 'rgba(var(--cmat-bg-dialog-rgb), 1)'
47
36
  },
48
37
  '.ring-bg-default': {
49
- '--tw-ring-opacity': '1 !important',
50
- '--tw-ring-color': 'rgba(var(--cmat-bg-default-rgb), var(--tw-ring-opacity)) !important'
38
+ '--tw-ring-color': 'rgba(var(--cmat-bg-default-rgb), 1)'
51
39
  },
52
40
  '.ring-bg-card': {
53
- '--tw-ring-opacity': '1 !important',
54
- '--tw-ring-color': 'rgba(var(--cmat-bg-card-rgb), var(--tw-ring-opacity)) !important'
41
+ '--tw-ring-color': 'rgba(var(--cmat-bg-card-rgb), 1)'
55
42
  }
56
43
  }
57
44
  );
@@ -59,7 +46,7 @@ module.exports = plugin(({
59
46
  addComponents(
60
47
  {
61
48
  '.bg-hover': {
62
- backgroundColor: 'var(--cmat-bg-hover) !important'
49
+ backgroundColor: 'var(--cmat-bg-hover)'
63
50
  }
64
51
  }
65
52
  );