anubis-ui 1.2.25 → 1.2.26

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/README.md CHANGED
@@ -80,7 +80,7 @@ css: [
80
80
 
81
81
  6. Enjoy
82
82
 
83
- > **Note**: Generated CSS variables (from colors and export-variations) are available for custom styling:
83
+ > **Note**: Generated CSS variables (from colors and export) are available for custom styling:
84
84
  > ```css
85
85
  > .custom-class {
86
86
  > background: var(--primary-low);
@@ -116,7 +116,8 @@ For every config you want to change, add the corresponding section in your confi
116
116
  "qol": [
117
117
  {
118
118
  "prefix": "bg",
119
- "declaration": "background: ${color}"
119
+ "declaration": "background: ${color}",
120
+ "export": "all"
120
121
  }
121
122
  ],
122
123
 
@@ -128,7 +129,8 @@ For every config you want to change, add the corresponding section in your confi
128
129
  "variations": {
129
130
  "default": "4px",
130
131
  "thin": "2px"
131
- }
132
+ },
133
+ "export": "variation"
132
134
  },
133
135
  {
134
136
  "prefix": "rounded",
@@ -137,7 +139,6 @@ For every config you want to change, add the corresponding section in your confi
137
139
  "default": "8px",
138
140
  "lg": "12px"
139
141
  },
140
- "export-variations": false
141
142
  }
142
143
  ],
143
144
 
@@ -252,10 +253,11 @@ QoL utilities include:
252
253
  1. `prefix` - The class name prefix
253
254
  2. `declaration` - CSS rule using `${value}` placeholder for variations
254
255
  3. `variations` - Key-value pairs of variation names and their CSS values
255
- 4. `export-variations` (optional) - Generates CSS variables for all variations
256
+ 4. `export` (optional) - Controls how variations are exported as CSS variables
256
257
 
257
- **The `export-variations` flag**:
258
- - `export-variations: true` → Generates `--size-xs`, `--size-md`, etc. as CSS variables
258
+ **The `export` flag**:
259
+ - `export: "variation"` → Generates CSS variables every variations
260
+ - `export: "all"` → Generates classes for every possible color
259
261
  - These can be used in custom CSS: `font-size: var(--size-xl)`
260
262
 
261
263
  **Color support**:
@@ -391,7 +393,7 @@ Examples:
391
393
  | size | `font-size: {value} !important;` |
392
394
  | weight | `font-weight: {value} !important;` |
393
395
 
394
- **Note**: When `export-variations: true` is set, `{value}` becomes `var(--{prefix}-{variation})` instead of the direct value.
396
+ **Note**: When `export: "variation"` is set, `{value}` becomes `var(--{prefix}-{variation})` instead of the direct value.
395
397
 
396
398
  ## Architecture
397
399
 
@@ -421,7 +423,7 @@ Examples:
421
423
 
422
424
  5. **CSS Output** (`src/tools/fileStuff/css.file.ts`)
423
425
  - Generates color CSS variables with light/dark theme support
424
- - Generates variation CSS variables (from `export-variations: true`)
426
+ - Generates variation CSS variables (from `export: "variation"` or `export: "all"`)
425
427
  - Writes final CSS rules
426
428
  - Outputs to `src/css/_anubis.scss`
427
429
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anubis-ui",
3
- "version": "1.2.25",
3
+ "version": "1.2.26",
4
4
  "description": "Class-based css generator",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -1,11 +1,13 @@
1
1
  [
2
2
  {
3
3
  "prefix": "bg",
4
- "declaration": "background: ${color}"
4
+ "declaration": "background: ${color}",
5
+ "export": "all"
5
6
  },
6
7
  {
7
8
  "prefix": "text",
8
- "declaration": "color: ${color}"
9
+ "declaration": "color: ${color}",
10
+ "export": "all"
9
11
  },
10
12
  {
11
13
  "prefix": "text",
@@ -113,7 +115,7 @@
113
115
  {
114
116
  "prefix": "size",
115
117
  "declaration": "font-size: ${value} !important",
116
- "export-variations": true,
118
+ "export": "variation",
117
119
  "variations": {
118
120
  "2xs": "10px",
119
121
  "xs": "12px",
@@ -134,7 +136,7 @@
134
136
  {
135
137
  "prefix": "weight",
136
138
  "declaration": "font-weight: ${value} !important",
137
- "export-variations": true,
139
+ "export": "variation",
138
140
  "variations": {
139
141
  "thin": "100",
140
142
  "extra-light": "200",
@@ -12,11 +12,11 @@ export interface IUtility {
12
12
 
13
13
  /**
14
14
  * Controls how variations are exported as SCSS variables:
15
- * - true: export only variations that are used in the codebase
16
- * - "always": export all variations regardless of usage
17
- * - undefined/false: do not export variations
15
+ * - "variation": export every variations
16
+ * - "all": export every possible color class (utility prefix + every colors)
17
+ * - undefined: do not export variations
18
18
  */
19
- 'export-variations'?: boolean | 'always';
19
+ 'export'?: 'variations' | 'all';
20
20
 
21
21
  /** List of every possible variations */
22
22
  variations: IVariation;
@@ -67,11 +67,14 @@ const init = async () => {
67
67
  config.colors
68
68
  )}`;
69
69
 
70
- // Get all variations that should be exported (export-variations: true)
71
- const allExportVariations = getAllExportVariations();
70
+ // Get all variations that should be exported (export: "variations")
71
+ const exportVariations = getExportVariations();
72
72
 
73
73
  // Merge used variations with all export variations (all export variations take priority)
74
- const finalVariations = { ...variationsFromRules, ...allExportVariations };
74
+ const finalVariations = {
75
+ ...variationsFromRules,
76
+ ...exportVariations
77
+ };
75
78
 
76
79
  // Generate CSS variables for variations
77
80
  const variationsCss = Object.entries(finalVariations)
@@ -95,7 +98,13 @@ const getUniqueClasses = async (files: string[]): Promise<string[]> => {
95
98
  await pLimit(files, extractClasses, MAX_CONCURRENT_FILE_READS)
96
99
  ).flat();
97
100
 
98
- const classes = [...extractedClasses, ...config.force].sort();
101
+ const exportClasses = getExportAllClasses()
102
+
103
+ const classes = [
104
+ ...extractedClasses,
105
+ ...exportClasses,
106
+ ...config.force,
107
+ ].sort();
99
108
 
100
109
  const uniqueClasses = Array.from(new Set(classes));
101
110
  return uniqueClasses;
@@ -162,23 +171,45 @@ const extractClasses = async (filePath: string): Promise<string[]> => {
162
171
  return matches;
163
172
  };
164
173
 
165
- /** Get all variations from utilitys with export-variations: true */
166
- const getAllExportVariations = (): Record<string, string> => {
167
- const allExportVariations: Record<string, string> = {};
168
- const allUtilities = [...config.utilities];
174
+ /** Get all variations from utilities with export: "all" */
175
+ const getExportAllClasses = (): string[] => {
176
+ const possiblesClasses: string[] = [];
177
+
178
+ const utilities = [...config.utilities];
179
+ const colors = Object.keys(config.colors);
180
+
181
+ for (const utility of utilities) {
182
+ const exportValue = utility['export'];
183
+ // Pour "all", exporter toutes les possibilités de couleurs
184
+ if (exportValue === 'all') {
185
+ possiblesClasses.push(
186
+ ...colors.map(c => `${utility.prefix}-${c}`)
187
+ )
188
+ }
189
+ }
190
+
191
+ return possiblesClasses;
192
+ };
193
+
194
+ /** Get all variations from utilities with export: "variations" */
195
+ const getExportVariations = (): Record<string, string> => {
196
+ const exportAllVariations: Record<string, string> = {};
197
+ const utilities = [...config.utilities];
169
198
 
170
- for (const utility of allUtilities) {
171
- if (utility['export-variations'] === true && utility.variations) {
199
+ for (const utility of utilities) {
200
+ const exportValue = utility['export'];
201
+ // Pour "variations", exporter toutes les variations
202
+ if (exportValue === 'variations' && utility.variations) {
172
203
  for (const [variantName, variantValue] of Object.entries(
173
204
  utility.variations
174
205
  )) {
175
206
  const variableName = `${utility.prefix}-${variantName}`;
176
- allExportVariations[variableName] = variantValue as string;
207
+ exportAllVariations[variableName] = variantValue as string;
177
208
  }
178
209
  }
179
210
  }
180
211
 
181
- return allExportVariations;
212
+ return exportAllVariations;
182
213
  };
183
214
 
184
215
  export { init };
@@ -250,8 +250,8 @@ const buildRuleInfo = ({
250
250
  let variantInfo = undefined;
251
251
 
252
252
  // Vérifier si on doit exporter les variations en tant que variables CSS
253
- const exportVariations = utility['export-variations'];
254
- const useVariables = exportVariations === true;
253
+ const exportVariations = utility['export'];
254
+ const useVariables = exportVariations === 'variations' || exportVariations === 'all';
255
255
 
256
256
  if (variationName && variationName !== 'default') {
257
257
  const variablePrefix = prefix;
@@ -72,7 +72,7 @@ const VARIANT_COMMENT = `/**
72
72
  * }
73
73
  *
74
74
  * (You can also force the generation of all variants from a
75
- * utility by setting the 'export-variations' to 'true')
75
+ * utility by setting the 'export' to 'variations')
76
76
  */`;
77
77
 
78
78
  const CLASS_COMMENT = `/**