@acorex/styles 19.11.6 → 19.11.7

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.
@@ -3,21 +3,17 @@
3
3
  */
4
4
 
5
5
  export const createPalette = function (colorName) {
6
- return {
6
+ const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
7
+ const palette = {
7
8
  DEFAULT: `rgba(var(--ax-sys-color-${colorName}-500), <alpha-value>)`,
8
9
  default: `rgba(var(--ax-sys-color-${colorName}-500), <alpha-value>)`,
9
- 50: `rgba(var(--ax-sys-color-${colorName}-50), <alpha-value>)`,
10
- 100: `rgba(var(--ax-sys-color-${colorName}-100), <alpha-value>)`,
11
- 200: `rgba(var(--ax-sys-color-${colorName}-200), <alpha-value>)`,
12
- 300: `rgba(var(--ax-sys-color-${colorName}-300), <alpha-value>)`,
13
- 400: `rgba(var(--ax-sys-color-${colorName}-400), <alpha-value>)`,
14
- 500: `rgba(var(--ax-sys-color-${colorName}-500), <alpha-value>)`,
15
- 600: `rgba(var(--ax-sys-color-${colorName}-600), <alpha-value>)`,
16
- 700: `rgba(var(--ax-sys-color-${colorName}-700), <alpha-value>)`,
17
- 800: `rgba(var(--ax-sys-color-${colorName}-800), <alpha-value>)`,
18
- 900: `rgba(var(--ax-sys-color-${colorName}-900), <alpha-value>)`,
19
- 950: `rgba(var(--ax-sys-color-${colorName}-950), <alpha-value>)`,
20
10
  };
11
+
12
+ shades.forEach((shade) => {
13
+ palette[shade] = `rgba(var(--ax-sys-color-${colorName}-${shade}), <alpha-value>)`;
14
+ });
15
+
16
+ return palette;
21
17
  };
22
18
 
23
19
  /**
@@ -25,16 +21,12 @@ export const createPalette = function (colorName) {
25
21
  * This function generates seven surface colors. Also, if you want to have surfaces in all Tailwind properties, you can put them in colors.
26
22
  */
27
23
  export const createSurfaces = function (colorName) {
28
- return {
29
- lightest: `rgba(var(--ax-sys-color-${colorName}-lightest-surface), <alpha-value>)`,
30
- lighter: `rgba(var(--ax-sys-color-${colorName}-lighter-surface), <alpha-value>)`,
31
- light: `rgba(var(--ax-sys-color-${colorName}-light-surface), <alpha-value>)`,
32
- surface: `rgba(var(--ax-sys-color-${colorName}-surface), <alpha-value>)`,
33
- dark: `rgba(var(--ax-sys-color-${colorName}-dark-surface), <alpha-value>)`,
34
- darker: `rgba(var(--ax-sys-color-${colorName}-darker-surface), <alpha-value>)`,
35
- darkest: `rgba(var(--ax-sys-color-${colorName}-darkest-surface), <alpha-value>)`,
36
- on: `rgba(var(--ax-sys-color-on-${colorName}), <alpha-value>)`,
37
- };
24
+ const variations = ['lightest', 'lighter', 'light', 'surface', 'dark', 'darker', 'darkest'];
25
+
26
+ return variations.reduce((surfaces, variation) => {
27
+ surfaces[variation] = `rgba(var(--ax-sys-color-${colorName}-${variation}-surface), <alpha-value>)`;
28
+ return surfaces;
29
+ }, {});
38
30
  };
39
31
 
40
32
  /**
@@ -42,29 +34,45 @@ export const createSurfaces = function (colorName) {
42
34
  * so you can generate it with createOnSurface for both text and other colors.
43
35
  */
44
36
  export const createOnSurfaces = function (colorName) {
45
- return {
46
- 'on-lightest': `rgba(var(--ax-sys-color-on-${colorName}-lightest-surface), <alpha-value>)`,
47
- 'on-lighter': `rgba(var(--ax-sys-color-on-${colorName}-lighter-surface), <alpha-value>)`,
48
- 'on-light': `rgba(var(--ax-sys-color-on-${colorName}-light-surface), <alpha-value>)`,
49
- 'on-surface': `rgba(var(--ax-sys-color-on-${colorName}-surface), <alpha-value>)`,
50
- 'on-dark': `rgba(var(--ax-sys-color-on-${colorName}-dark-surface), <alpha-value>)`,
51
- 'on-darker': `rgba(var(--ax-sys-color-on-${colorName}-darker-surface), <alpha-value>)`,
52
- 'on-darkest': `rgba(var(--ax-sys-color-on-${colorName}-darkest-surface), <alpha-value>)`,
53
- 'on-contrast': `rgba(var(--ax-sys-color-on-contrast-${colorName}), <alpha-value>)`,
54
- };
37
+ const variations = ['lightest', 'lighter', 'light', 'surface', 'dark', 'darker', 'darkest', 'contrast'];
38
+
39
+ return variations.reduce((onSurfaces, variation) => {
40
+ const key = variation === 'contrast' ? `on-${variation}` : `on-${variation}`;
41
+ onSurfaces[key] = `rgba(var(--ax-sys-color-on-${colorName}-${variation}-surface), <alpha-value>)`;
42
+ return onSurfaces;
43
+ }, {});
55
44
  };
56
45
 
57
46
  /**
58
47
  * The board color is only used for border colors, which you can generate with the createBorderSurfaces function.
59
48
  */
60
49
  export const createBorderSurfaces = function (colorName) {
61
- return {
62
- lightest: `rgba(var(--ax-sys-color-border-${colorName}-lightest-surface), <alpha-value>)`,
63
- lighter: `rgba(var(--ax-sys-color-border-${colorName}-lighter-surface), <alpha-value>)`,
64
- light: `rgba(var(--ax-sys-color-border-${colorName}-light-surface), <alpha-value>)`,
65
- surface: `rgba(var(--ax-sys-color-border-${colorName}-surface), <alpha-value>)`,
66
- dark: `rgba(var(--ax-sys-color-border-${colorName}-dark-surface), <alpha-value>)`,
67
- darker: `rgba(var(--ax-sys-color-border-${colorName}-darker-surface), <alpha-value>)`,
68
- darkest: `rgba(var(--ax-sys-color-border-${colorName}-darkest-surface), <alpha-value>)`,
69
- };
50
+ const variations = ['lightest', 'lighter', 'light', 'surface', 'dark', 'darker', 'darkest'];
51
+
52
+ return variations.reduce((borderSurfaces, variation) => {
53
+ borderSurfaces[variation] = `rgba(var(--ax-sys-color-border-${colorName}-${variation}-surface), <alpha-value>)`;
54
+ return borderSurfaces;
55
+ }, {});
70
56
  };
57
+
58
+ export function createColoredSurfaces(colorName) {
59
+ const variations = [
60
+ 'surface',
61
+ 'lightest-surface',
62
+ 'lighter-surface',
63
+ 'light-surface',
64
+ 'dark-surface',
65
+ 'darker-surface',
66
+ 'darkest-surface',
67
+ ];
68
+
69
+ return variations.reduce((classes, variation) => {
70
+ const baseName = variation.replace('-surface', ''); // Extract the base name (e.g., 'lightest', 'lighter', etc.)
71
+ classes[`.${colorName}-${variation}`] = {
72
+ backgroundColor: `rgb(var(--ax-sys-color-${colorName}-${baseName || 'surface'}))`,
73
+ color: `rgb(var(--ax-sys-color-on-${colorName}-${baseName || 'surface'}))`,
74
+ borderColor: `rgb(var(--ax-sys-color-border-${colorName}-${baseName || 'surface'}))`,
75
+ };
76
+ return classes;
77
+ }, {});
78
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acorex/styles",
3
- "version": "19.11.6",
3
+ "version": "19.11.7",
4
4
  "main": "index.js",
5
5
  "author": "Ali Safari",
6
6
  "license": "ISC",
package/tailwind-base.js CHANGED
@@ -1,6 +1,13 @@
1
1
  const plugin = require('tailwindcss/plugin');
2
2
  const { withAnimations } = require('animated-tailwindcss');
3
- const { createBorderSurfaces, createOnSurfaces, createPalette, createSurfaces } = require('./generators/index');
3
+ const {
4
+ createBorderSurfaces,
5
+ createOnSurfaces,
6
+ createPalette,
7
+ createSurfaces,
8
+ createColorSurfaces,
9
+ createColoredSurfaces,
10
+ } = require('./generators/index');
4
11
 
5
12
  const childSelector = plugin(function ({ addVariant }) {
6
13
  addVariant('child', '& > *');
@@ -56,7 +63,16 @@ const SURFACE_BORDER = {
56
63
  darkest: 'rgba(var(--ax-sys-color-border-darkest-surface), <alpha-value>)',
57
64
  };
58
65
 
66
+ const dynamicSurfaceClasses = {
67
+ ...createColoredSurfaces('primary'),
68
+ ...createColoredSurfaces('secondary'),
69
+ ...createColoredSurfaces('success'),
70
+ ...createColoredSurfaces('warning'),
71
+ ...createColoredSurfaces('danger'),
72
+ };
73
+
59
74
  const UTILITY_CLASSES = {
75
+ ...dynamicSurfaceClasses,
60
76
  '.h1': {
61
77
  'font-size': '2.5rem',
62
78
  'font-weight': '500',
@@ -205,7 +221,8 @@ module.exports = withAnimations({
205
221
  pattern: /(?:(?:on|border)-)?(?:lightest|lighter|light|surface|dark|darker|darkest)/,
206
222
  },
207
223
  {
208
- pattern: /(?:bg|text)(?:-(?:primary|secondary|danger|success|warning|ghost))?-(?:50|100|200|300|400|500|600|700|800|900|950)/,
224
+ pattern:
225
+ /(?:bg|text)(?:-(?:primary|secondary|danger|success|warning|ghost))?-(?:50|100|200|300|400|500|600|700|800|900|950)/,
209
226
  },
210
227
  ],
211
228
  theme: {
@@ -289,7 +306,7 @@ module.exports = withAnimations({
289
306
 
290
307
  plugins: [
291
308
  plugin(function ({ addUtilities }) {
292
- UTILITY_CLASSES, addUtilities(UTILITY_CLASSES, ['responsive', 'hover', 'focus']);
309
+ addUtilities(UTILITY_CLASSES, ['responsive', 'hover', 'focus']);
293
310
  }),
294
311
  childSelector,
295
312
  ],