anubis-ui 1.3.0 → 1.4.0
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 +206 -74
- package/dist/interfaces/color.interface.d.ts +8 -0
- package/dist/interfaces/color.interface.js +2 -0
- package/{src/interfaces/config.interface.ts → dist/interfaces/config.interface.d.ts} +0 -3
- package/dist/interfaces/config.interface.js +2 -0
- package/dist/interfaces/files.interface.d.ts +4 -0
- package/dist/interfaces/files.interface.js +2 -0
- package/{src/interfaces/preset.interface.ts → dist/interfaces/preset.interface.d.ts} +3 -7
- package/dist/interfaces/preset.interface.js +2 -0
- package/dist/tools/config.tool.d.ts +4 -0
- package/dist/tools/config.tool.js +64 -0
- package/dist/tools/extraction/extractClasses.d.ts +5 -0
- package/dist/tools/extraction/extractClasses.js +134 -0
- package/dist/tools/fileStuff/config.file.d.ts +5 -0
- package/dist/tools/fileStuff/config.file.js +41 -0
- package/dist/tools/fileStuff/file.tools.d.ts +19 -0
- package/dist/tools/fileStuff/file.tools.js +88 -0
- package/dist/tools/fileStuff/quasar-variables.file.d.ts +1 -0
- package/dist/tools/fileStuff/quasar-variables.file.js +12 -0
- package/dist/tools/logger.d.ts +5 -0
- package/dist/tools/logger.js +27 -0
- package/dist/tools/main.d.ts +1 -0
- package/dist/tools/main.js +54 -0
- package/dist/tools/mapping/mapClassIntoRule.d.ts +5 -0
- package/dist/tools/mapping/mapClassIntoRule.js +256 -0
- package/dist/tools/mapping/mapColors.d.ts +3 -0
- package/dist/tools/mapping/mapColors.js +18 -0
- package/dist/tools/mapping/mapUtilities.d.ts +1 -0
- package/dist/tools/mapping/mapUtilities.js +17 -0
- package/dist/tools/output/css.output.d.ts +11 -0
- package/dist/tools/output/css.output.js +118 -0
- package/dist/tools/validation/color.validation.d.ts +12 -0
- package/{src/tools/validation/color.validation.ts → dist/tools/validation/color.validation.js} +14 -31
- package/dist/version.d.ts +5 -0
- package/dist/version.js +7 -0
- package/index.js +5 -18
- package/package.json +10 -3
- package/index.html +0 -20
- package/scripts/generate-version.js +0 -15
- package/src/config/colors.config.json +0 -242
- package/src/config/files.config.json +0 -5
- package/src/config/force.config.json +0 -1
- package/src/config/states.config.json +0 -4
- package/src/config/utilities.config.json +0 -152
- package/src/interfaces/color.interface.ts +0 -9
- package/src/interfaces/files.interface.ts +0 -4
- package/src/manual/build.js +0 -4
- package/src/tools/config.tool.ts +0 -70
- package/src/tools/extraction/extractClasses.ts +0 -215
- package/src/tools/fileStuff/config.file.ts +0 -44
- package/src/tools/fileStuff/css.file.ts +0 -47
- package/src/tools/fileStuff/file.tools.ts +0 -12
- package/src/tools/logger.ts +0 -23
- package/src/tools/mapping/mapClassIntoRule.ts +0 -335
- package/src/tools/mapping/mapColorIntoDeclaration.ts +0 -14
- package/src/tools/output/css.output.ts +0 -104
- package/tests/README.md +0 -54
- package/tests/validation/color.validation.test.ts +0 -182
- package/tsconfig.json +0 -22
- package/vitest.config.ts +0 -19
package/README.md
CHANGED
|
@@ -3,13 +3,67 @@
|
|
|
3
3
|
|
|
4
4
|
AnubisUI (Autonomous Nominative Utility Based Intuitive Styler) is a Vite plugin that provides dynamic CSS class generation based on configuration files. It automatically generates CSS rules by scanning your source files and mapping utility classes to their corresponding styles.
|
|
5
5
|
|
|
6
|
+
## 🚀 Quick Start
|
|
7
|
+
|
|
8
|
+
AnubisUI automatically generates the CSS classes you need, simply by using them in your code. No need to write CSS manually!
|
|
9
|
+
|
|
10
|
+
### Concrete Example
|
|
11
|
+
|
|
12
|
+
**In your Vue/HTML component:**
|
|
13
|
+
```html
|
|
14
|
+
<template>
|
|
15
|
+
<div class="bg-primary-low text-primary rounded-lg smooth hover:shadow-accent-wide">
|
|
16
|
+
<button class="bg-accent text-primary size-lg weight-bold hover:bg-accent-high">
|
|
17
|
+
Click me
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**AnubisUI automatically generates the CSS:**
|
|
24
|
+
```css
|
|
25
|
+
.bg-primary-low { background: var(--primary-low) !important; }
|
|
26
|
+
.text-primary { color: var(--primary) !important; }
|
|
27
|
+
.rounded-lg { border-radius: 12px !important; }
|
|
28
|
+
.smooth { transition-duration: 0.1s !important; }
|
|
29
|
+
.hover\:shadow-accent-wide:hover { box-shadow: 0px 0px 10px 2px var(--accent) !important; }
|
|
30
|
+
/* ... and much more */
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Key Benefits
|
|
34
|
+
|
|
35
|
+
✅ **Zero CSS to write** - Use classes, AnubisUI generates the CSS\
|
|
36
|
+
✅ **Light/dark themes** - Automatic support with CSS variables\
|
|
37
|
+
✅ **Hot-reload** - Classes are detected and generated on the fly\
|
|
38
|
+
✅ **Optimized** - Only used classes are generated\
|
|
39
|
+
✅ **Customizable** - Configure your colors, variations and presets
|
|
40
|
+
|
|
41
|
+
### Typical Use Cases
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<!-- Card with border and shadow on hover -->
|
|
45
|
+
<div class="bg-neutral-lowest border-neutral-thin rounded-lg hover:shadow-primary-wide smooth">
|
|
46
|
+
<h2 class="text-primary size-2xl weight-bold">Title</h2>
|
|
47
|
+
<p class="text-neutral-medium size-md">Description</p>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<!-- Button with states -->
|
|
51
|
+
<button class="bg-success text-primary rounded smooth hover:bg-success-high">
|
|
52
|
+
Validate
|
|
53
|
+
</button>
|
|
54
|
+
|
|
55
|
+
<!-- Badge with inner borders -->
|
|
56
|
+
<span class="bg-warning-lowest inner-border-warning-thin rounded-full text-warning-high size-sm">
|
|
57
|
+
New
|
|
58
|
+
</span>
|
|
59
|
+
```
|
|
60
|
+
|
|
6
61
|
> __⚠️ IMPORTANT__ - Dynamic classes like `` `bg-primary-${props.bg}` `` **will NOT work**
|
|
7
62
|
>
|
|
8
63
|
> Classes must be **EXPLICITLY written** in the code to allow the extraction to work correctly. The plugin uses regex pattern matching on your source files.
|
|
9
64
|
>
|
|
10
65
|
> Use the `force` configuration to generate specific classes even if they're not present in the code.
|
|
11
66
|
|
|
12
|
-
|
|
13
67
|
## Table of Contents
|
|
14
68
|
1. [Features](#features)
|
|
15
69
|
2. [Installation](#installation)
|
|
@@ -38,6 +92,8 @@ AnubisUI (Autonomous Nominative Utility Based Intuitive Styler) is a Vite plugin
|
|
|
38
92
|
- 🔍 Smart class detection and parsing
|
|
39
93
|
- 📦 CSS variable generation for reusable values
|
|
40
94
|
- ⚙️ Export variations as CSS variables for custom styling
|
|
95
|
+
- 🎛️ SCSS tokens generation for global color access
|
|
96
|
+
- 🔧 Quasar/global variable overrides from utility defaults
|
|
41
97
|
|
|
42
98
|
# Installation
|
|
43
99
|
|
|
@@ -65,20 +121,27 @@ css: [
|
|
|
65
121
|
```
|
|
66
122
|
<sup>quasar.config.js</sup>
|
|
67
123
|
|
|
68
|
-
4.
|
|
124
|
+
4. AnubisUI generates the following files automatically in `src/css/`:
|
|
125
|
+
- `_anubis.scss` - Main stylesheet with all generated rules
|
|
126
|
+
- `anubis/_mixins.scss` - SCSS mixins for color handling
|
|
127
|
+
- `anubis/_tokens.scss` - Color token variables (`$primary`, `$primary-dark`, etc.)
|
|
128
|
+
- `anubis/_overrides.scss` - Quasar variable overrides from utilities
|
|
129
|
+
- `quasar.variables.scss` - Auto-injected imports for tokens and overrides
|
|
130
|
+
|
|
131
|
+
5. Colors are automatically defined from the configuration
|
|
69
132
|
- AnubisUI generates CSS variables for all colors defined in `colors.config.json`
|
|
70
133
|
- Colors support light/dark themes automatically
|
|
71
134
|
- Each color is exposed as a CSS variable: `--primary`, `--secondary`, etc.
|
|
72
135
|
- Pre-defined color levels: `lowest`, `lower`, `low`, `medium`, `high`, `higher`, `highest`
|
|
73
136
|
|
|
74
|
-
|
|
137
|
+
6. Start adding classes to your .vue files
|
|
75
138
|
```html
|
|
76
139
|
<div class="bg-primary-low border-neutral-medium hover:shadow-wide rounded-lg" />
|
|
77
|
-
<button class="bg-accent text-
|
|
140
|
+
<button class="bg-accent text-primary size-lg weight-bold smooth">Click me</button>
|
|
78
141
|
```
|
|
79
|
-
<sup>any .
|
|
142
|
+
<sup>any .vue file</sup>
|
|
80
143
|
|
|
81
|
-
|
|
144
|
+
7. Enjoy
|
|
82
145
|
|
|
83
146
|
> **Note**: Generated CSS variables (from colors and export) are available for custom styling:
|
|
84
147
|
> ```css
|
|
@@ -89,6 +152,16 @@ css: [
|
|
|
89
152
|
> }
|
|
90
153
|
> ```
|
|
91
154
|
|
|
155
|
+
> **SCSS Tokens**: Color tokens are also available as SCSS variables for compile-time usage:
|
|
156
|
+
> ```scss
|
|
157
|
+
> @use "anubis/_tokens.scss" as tokens;
|
|
158
|
+
>
|
|
159
|
+
> .custom-class {
|
|
160
|
+
> border-color: tokens.$primary;
|
|
161
|
+
> background: tokens.$accent-dark;
|
|
162
|
+
> }
|
|
163
|
+
> ```
|
|
164
|
+
|
|
92
165
|
## Configuration
|
|
93
166
|
AnubisUI uses several configuration files located in the `src/config` directory:
|
|
94
167
|
<br />
|
|
@@ -96,33 +169,29 @@ To override default configuration, add a `anubis.config.json` in project root fo
|
|
|
96
169
|
>Overriding completly replaces default configuration. You need to copy/paste it and add yours if you want to keep the default too.
|
|
97
170
|
<br />
|
|
98
171
|
|
|
99
|
-
|
|
172
|
+
Only the sections you want to override need to be included - other sections will use default values.\
|
|
173
|
+
For every config you want to change, add the corresponding section in your config file
|
|
174
|
+
<br />
|
|
100
175
|
|
|
176
|
+
### Some examples:
|
|
101
177
|
```js
|
|
102
178
|
{
|
|
103
179
|
// files.config.json
|
|
104
180
|
"files": {
|
|
105
181
|
"targets": ["/.vue"],
|
|
106
|
-
"ignore": []
|
|
182
|
+
"ignore": ["**/*specificFile.vue"]
|
|
107
183
|
},
|
|
108
184
|
|
|
109
185
|
// colors.config.json
|
|
110
|
-
"colors": ["primary", "secondary"],
|
|
111
|
-
|
|
112
|
-
// states.config.json
|
|
113
|
-
"states": ["hover"],
|
|
186
|
+
"colors": ["primary", "secondary", "..."],
|
|
114
187
|
|
|
115
|
-
//
|
|
116
|
-
"
|
|
188
|
+
// utilities.config.json
|
|
189
|
+
"utilities": [
|
|
117
190
|
{
|
|
118
191
|
"prefix": "bg",
|
|
119
192
|
"declaration": "background: ${color}",
|
|
120
193
|
"export": "all"
|
|
121
194
|
}
|
|
122
|
-
],
|
|
123
|
-
|
|
124
|
-
// presets.config.json
|
|
125
|
-
"presets": [
|
|
126
195
|
{
|
|
127
196
|
"prefix": "border",
|
|
128
197
|
"declaration": "border-width: ${value} !important; border-color: ${color} !important; border-style: solid;",
|
|
@@ -130,7 +199,7 @@ For every config you want to change, add the corresponding section in your confi
|
|
|
130
199
|
"default": "4px",
|
|
131
200
|
"thin": "2px"
|
|
132
201
|
},
|
|
133
|
-
"export": "
|
|
202
|
+
"export": "variations"
|
|
134
203
|
},
|
|
135
204
|
{
|
|
136
205
|
"prefix": "rounded",
|
|
@@ -145,20 +214,13 @@ For every config you want to change, add the corresponding section in your confi
|
|
|
145
214
|
// force.config.json
|
|
146
215
|
"force": [
|
|
147
216
|
"bg-primary-10",
|
|
148
|
-
"
|
|
149
|
-
"
|
|
217
|
+
"hover:border-neutral-thin",
|
|
218
|
+
"text-danger"
|
|
150
219
|
]
|
|
151
220
|
}
|
|
152
221
|
```
|
|
153
222
|
<sup>anubis.config.json (example)</sup>
|
|
154
223
|
|
|
155
|
-
Only the sections you want to override need to be included - other sections will use default values. Not every
|
|
156
|
-
> Presets is still unstable, use at your own risks
|
|
157
|
-
<br />
|
|
158
|
-
You __MUST__ use the exact same [presets](#presets-presetsconfigjson) names syntax to keep it working, but variations key/values can change.
|
|
159
|
-
<br />
|
|
160
|
-
Copy-paste is recommanded
|
|
161
|
-
|
|
162
224
|
---
|
|
163
225
|
### Colors (`colors.config.json`)
|
|
164
226
|
Define your color palette with light/dark theme support. Colors can be defined in three different ways:
|
|
@@ -173,7 +235,7 @@ Define your color palette with light/dark theme support. Colors can be defined i
|
|
|
173
235
|
"dark": "#1a94db"
|
|
174
236
|
}
|
|
175
237
|
```
|
|
176
|
-
Generates color variables for both light and dark themes with opacity variations
|
|
238
|
+
<sup>Generates color variables for both light and dark themes with opacity variations.</sup>
|
|
177
239
|
|
|
178
240
|
2. **Light theme only** - Define only `light` value:
|
|
179
241
|
```json
|
|
@@ -181,7 +243,7 @@ Define your color palette with light/dark theme support. Colors can be defined i
|
|
|
181
243
|
"light": "#ff00ff"
|
|
182
244
|
}
|
|
183
245
|
```
|
|
184
|
-
Generates color variables only for light theme. Dark theme will not have this color defined
|
|
246
|
+
<sup>Generates color variables only for light theme. Dark theme will not have this color defined.</sup>
|
|
185
247
|
|
|
186
248
|
3. **Dark theme only** - Define only `dark` value:
|
|
187
249
|
```json
|
|
@@ -189,9 +251,30 @@ Define your color palette with light/dark theme support. Colors can be defined i
|
|
|
189
251
|
"dark": "#00ffff"
|
|
190
252
|
}
|
|
191
253
|
```
|
|
192
|
-
Generates color variables only for dark theme. Light theme will not have this color defined
|
|
193
|
-
|
|
194
|
-
Full palette includes
|
|
254
|
+
<sup>Generates color variables only for dark theme. Light theme will not have this color defined.</sup>
|
|
255
|
+
|
|
256
|
+
Full palette includes:\
|
|
257
|
+
<b>Colors</b>
|
|
258
|
+
<ul>
|
|
259
|
+
<li>primary</li>
|
|
260
|
+
<li>secondary</li>
|
|
261
|
+
<li>accent</li>
|
|
262
|
+
<li>neutral</li>
|
|
263
|
+
<li>success</li>
|
|
264
|
+
<li>warning</li>
|
|
265
|
+
<li>danger</lu>
|
|
266
|
+
</ul>
|
|
267
|
+
|
|
268
|
+
<b>Levels</b>
|
|
269
|
+
<ul>
|
|
270
|
+
<li>lowest <i>- lighest</i></li>
|
|
271
|
+
<li>lower</li>
|
|
272
|
+
<li>low</li>
|
|
273
|
+
<li>medium</li>
|
|
274
|
+
<li>high</li>
|
|
275
|
+
<li>higher</li>
|
|
276
|
+
<li>highest <i>- darkest</i></li>
|
|
277
|
+
</ul>
|
|
195
278
|
|
|
196
279
|
**Color naming convention**: Colors are automatically converted to CSS variables as `--{color-name}`. Use semantic color levels to ensure proper theme adaptation.
|
|
197
280
|
|
|
@@ -220,27 +303,20 @@ You can add multiple glob patterns to scan different file types:
|
|
|
220
303
|
```
|
|
221
304
|
|
|
222
305
|
---
|
|
223
|
-
###
|
|
224
|
-
Configure
|
|
306
|
+
### Utilities (`utilities.config.json`)
|
|
307
|
+
Configure all utility classes. This includes both color-based utilities and standalone utilities.
|
|
225
308
|
|
|
226
|
-
**[View default
|
|
309
|
+
**[View default utilities config →](./src/config/utilities.config.json)**
|
|
227
310
|
|
|
228
|
-
|
|
311
|
+
**Color-based utilities** (require a color):
|
|
312
|
+
- `bg` - Background colors
|
|
313
|
+
- `text` - Text colors
|
|
314
|
+
- `border` - Border with width variations and color
|
|
315
|
+
- `inner-border` - Inset box shadow with width variations and color
|
|
316
|
+
- `shadow` - Box shadow with spread variations and color
|
|
229
317
|
|
|
230
|
-
Presets include:
|
|
231
|
-
- `bg` - Background colors (no variations)
|
|
232
|
-
- `text` - Text colors (no variations)
|
|
233
|
-
- `border` - Border with width variations
|
|
234
|
-
- `inner-border` - Inset box shadow with width variations
|
|
235
|
-
- `shadow` - Box shadow with spread variations
|
|
236
318
|
|
|
237
|
-
|
|
238
|
-
### Quality of Life (`qol.config.json`)
|
|
239
|
-
Define simple style rules that can have variations but don't require color values. These are CSS declarations that work independently.
|
|
240
|
-
|
|
241
|
-
**[View default QoL config →](./src/config/qol.config.json)**
|
|
242
|
-
|
|
243
|
-
QoL utilities include:
|
|
319
|
+
**Standalone utilities** (no color required):
|
|
244
320
|
- `blur` - Backdrop filter blur effect
|
|
245
321
|
- `smooth` - Transition duration
|
|
246
322
|
- `rounded` - Border radius
|
|
@@ -251,15 +327,38 @@ QoL utilities include:
|
|
|
251
327
|
|
|
252
328
|
**Configuration options**:
|
|
253
329
|
1. `prefix` - The class name prefix
|
|
254
|
-
2. `declaration` - CSS rule using `${value}`
|
|
330
|
+
2. `declaration` - CSS rule using `${value}` and/or `${color}` placeholders
|
|
255
331
|
3. `variations` - Key-value pairs of variation names and their CSS values
|
|
256
332
|
4. `export` (optional) - Controls how variations are exported as CSS variables
|
|
333
|
+
5. `overrides` (optional) - List of Quasar/global SCSS variables to override with the default variation
|
|
257
334
|
|
|
258
335
|
**The `export` flag**:
|
|
259
|
-
- `export: "
|
|
336
|
+
- `export: "variations"` → Generates CSS variables for every variation
|
|
260
337
|
- `export: "all"` → Generates classes for every possible color
|
|
261
338
|
- These can be used in custom CSS: `font-size: var(--size-xl)`
|
|
262
339
|
|
|
340
|
+
**The `overrides` option**:
|
|
341
|
+
Override Quasar or global SCSS variables with the `default` variation value:
|
|
342
|
+
```json
|
|
343
|
+
{
|
|
344
|
+
"prefix": "border",
|
|
345
|
+
"declaration": "border-width: ${value}; border-color: ${color}; border-style: solid;",
|
|
346
|
+
"overrides": [
|
|
347
|
+
"generic-border-radius",
|
|
348
|
+
"button-border-radius"
|
|
349
|
+
],
|
|
350
|
+
"variations": {
|
|
351
|
+
"default": "4px",
|
|
352
|
+
"thin": "2px"
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
This generates in `anubis/_overrides.scss`:
|
|
357
|
+
```scss
|
|
358
|
+
$generic-border-radius: 4px;
|
|
359
|
+
$button-border-radius: 4px;
|
|
360
|
+
```
|
|
361
|
+
|
|
263
362
|
**Color support**:
|
|
264
363
|
- Use `${color}` in declaration to indicate the utility requires a color
|
|
265
364
|
- Colors are automatically injected as CSS variables: `var(--{color})`
|
|
@@ -313,12 +412,12 @@ These utilities require a color from your config:
|
|
|
313
412
|
|
|
314
413
|
Examples:
|
|
315
414
|
```html
|
|
316
|
-
<div class="bg-primary-low text-
|
|
415
|
+
<div class="bg-primary-low text-primary">Blue background with primary text</div>
|
|
317
416
|
<div class="bg-success-lowest text-success-highest">Success themed element</div>
|
|
318
417
|
```
|
|
319
418
|
|
|
320
|
-
###
|
|
321
|
-
|
|
419
|
+
### Utility Variations (Color + Size)
|
|
420
|
+
Utilities can combine colors with size variations:
|
|
322
421
|
|
|
323
422
|
- `border-{color}-{variation}` - Border with color and width
|
|
324
423
|
- Variations: `thinest`, `thiner`, `thin`, `default`, `thick`, `thicker`, `thickest`, `node`
|
|
@@ -373,7 +472,7 @@ Examples:
|
|
|
373
472
|
|
|
374
473
|
## Prefix/Declaration Relations
|
|
375
474
|
|
|
376
|
-
### Color
|
|
475
|
+
### Color-based Utilities
|
|
377
476
|
| Prefix | CSS Declaration |
|
|
378
477
|
|--------------|---------------------------------------------------------------------------------|
|
|
379
478
|
| bg | `background: var(--{color}) !important;` |
|
|
@@ -393,37 +492,54 @@ Examples:
|
|
|
393
492
|
| size | `font-size: {value} !important;` |
|
|
394
493
|
| weight | `font-weight: {value} !important;` |
|
|
395
494
|
|
|
396
|
-
**Note**: When `export: "
|
|
495
|
+
**Note**: When `export: "variations"` is set, `{value}` becomes `var(--{prefix}-{variation})` instead of the direct value.
|
|
397
496
|
|
|
398
497
|
## Architecture
|
|
399
498
|
|
|
400
499
|
### Build Process Flow
|
|
401
500
|
|
|
501
|
+
The build process is orchestrated by `src/tools/main.ts` which runs the following steps in sequence:
|
|
502
|
+
|
|
402
503
|
1. **Configuration Initialization** (`src/tools/config.tool.ts`)
|
|
403
504
|
- Loads default configs from `src/config/*.config.json`
|
|
404
505
|
- Merges with user's `anubis.config.json` if present
|
|
405
506
|
- User config completely replaces default sections (no deep merge)
|
|
406
507
|
|
|
407
|
-
2. **
|
|
408
|
-
-
|
|
409
|
-
-
|
|
508
|
+
2. **Mixins Generation** (`src/tools/output/css.output.ts`)
|
|
509
|
+
- Generates SCSS mixins for color handling (light/dark theme support)
|
|
510
|
+
- Outputs to `src/css/anubis/_mixins.scss`
|
|
511
|
+
|
|
512
|
+
3. **Tokens Generation** (`src/tools/mapping/mapColors.ts`)
|
|
513
|
+
- Maps all colors from config into SCSS token variables
|
|
514
|
+
- Generates `$colorname`, `$colorname-light`, `$colorname-dark` variables
|
|
515
|
+
- Outputs to `src/css/anubis/_tokens.scss`
|
|
516
|
+
|
|
517
|
+
4. **Overrides Generation** (`src/tools/mapping/mapUtilities.ts`)
|
|
518
|
+
- Maps utilities with `overrides` property to SCSS variable declarations
|
|
519
|
+
- Allows overriding Quasar/global variables with utility defaults
|
|
520
|
+
- Outputs to `src/css/anubis/_overrides.scss`
|
|
410
521
|
|
|
411
|
-
|
|
412
|
-
-
|
|
522
|
+
5. **Quasar Variables Injection** (`src/tools/fileStuff/quasar-variables.file.ts`)
|
|
523
|
+
- Automatically adds `@use` imports for tokens and overrides
|
|
524
|
+
- Updates `src/css/quasar.variables.scss`
|
|
525
|
+
|
|
526
|
+
6. **Class Extraction** (`src/tools/extraction/extractClasses.ts`)
|
|
527
|
+
- Scans files matching glob patterns from `files.config.json`
|
|
528
|
+
- Builds dynamic regex from config (states, utilities prefixes)
|
|
413
529
|
- Extracts classes matching pattern: `(state:)?(prefix-)(-?(color|variation))?`
|
|
414
|
-
- Merges with forced classes from config
|
|
530
|
+
- Merges with forced classes and exported classes from config
|
|
415
531
|
- Deduplicates and returns unique classes
|
|
416
532
|
|
|
417
|
-
|
|
533
|
+
7. **Rule Generation** (`src/tools/mapping/mapClassIntoRule.ts`)
|
|
418
534
|
- Parses each class to identify state, prefix, color, and variation
|
|
419
535
|
- Validates color existence in config
|
|
420
|
-
- Handles
|
|
536
|
+
- Handles utility variations (direct values or CSS variables)
|
|
421
537
|
- Generates CSS rules with proper selectors and declarations
|
|
422
538
|
- Collects variants for CSS variable export
|
|
423
539
|
|
|
424
|
-
|
|
540
|
+
8. **CSS Output** (`src/tools/extraction/extractClasses.ts`)
|
|
425
541
|
- Generates color CSS variables with light/dark theme support
|
|
426
|
-
- Generates variation CSS variables (from `export: "
|
|
542
|
+
- Generates variation CSS variables (from `export: "variations"` or `export: "all"`)
|
|
427
543
|
- Writes final CSS rules
|
|
428
544
|
- Outputs to `src/css/_anubis.scss`
|
|
429
545
|
|
|
@@ -436,10 +552,14 @@ The plugin (`index.js`) provides:
|
|
|
436
552
|
|
|
437
553
|
### Core Components
|
|
438
554
|
|
|
439
|
-
- **
|
|
440
|
-
- **
|
|
441
|
-
- **
|
|
442
|
-
- **
|
|
555
|
+
- **Main Orchestrator** (`main.ts`): Coordinates all initialization steps with timing
|
|
556
|
+
- **Config System** (`config.tool.ts`): Manages configuration loading and merging
|
|
557
|
+
- **Class Extractor** (`extractClasses.ts`): Regex-based pattern matching for class detection
|
|
558
|
+
- **Color Mapper** (`mapColors.ts`): Generates tokens and mixin declarations from colors
|
|
559
|
+
- **Utilities Mapper** (`mapUtilities.ts`): Generates SCSS overrides from utilities config
|
|
560
|
+
- **Rule Mapper** (`mapClassIntoRule.ts`): Complex parsing logic for class-to-CSS conversion
|
|
561
|
+
- **CSS Generator** (`css.output.ts`): Generates variables, mixins and rules with proper formatting
|
|
562
|
+
- **File Tools** (`file.tools.ts`): Centralized file I/O with concurrency control
|
|
443
563
|
|
|
444
564
|
### File Structure
|
|
445
565
|
```
|
|
@@ -447,16 +567,28 @@ The plugin (`index.js`) provides:
|
|
|
447
567
|
├── src/
|
|
448
568
|
│ ├── config/ # Default configuration files
|
|
449
569
|
│ │ ├── colors.config.json # Color palette (light/dark themes)
|
|
450
|
-
│ │ ├──
|
|
451
|
-
│ │ ├── qol.config.json # Standalone utilities
|
|
570
|
+
│ │ ├── utilities.config.json # All utility classes (bg, text, border, etc.)
|
|
452
571
|
│ │ ├── states.config.json # State modifiers
|
|
453
|
-
│ │
|
|
572
|
+
│ │ ├── files.config.json # File scan patterns
|
|
573
|
+
│ │ └── force.config.json # Force specific classes
|
|
574
|
+
│ ├── css/ # Generated CSS output (in user project)
|
|
575
|
+
│ │ ├── _anubis.scss # Main generated stylesheet
|
|
576
|
+
│ │ ├── quasar.variables.scss # Quasar variables with injected imports
|
|
577
|
+
│ │ └── anubis/
|
|
578
|
+
│ │ ├── _mixins.scss # SCSS mixins for color handling
|
|
579
|
+
│ │ ├── _tokens.scss # Color token variables
|
|
580
|
+
│ │ └── _overrides.scss # Quasar/global variable overrides
|
|
454
581
|
│ ├── interfaces/ # TypeScript type definitions
|
|
455
582
|
│ └── tools/
|
|
456
583
|
│ ├── extraction/ # Class extraction logic
|
|
457
584
|
│ ├── fileStuff/ # File I/O operations
|
|
458
585
|
│ ├── mapping/ # Class-to-CSS mapping
|
|
586
|
+
│ │ ├── mapClassIntoRule.ts # Class to CSS rule conversion
|
|
587
|
+
│ │ ├── mapColors.ts # Color to tokens/mixins mapping
|
|
588
|
+
│ │ └── mapUtilities.ts # Utilities to overrides mapping
|
|
589
|
+
│ ├── output/ # CSS output generation
|
|
459
590
|
│ ├── config.tool.ts # Configuration loader
|
|
591
|
+
│ ├── main.ts # Main orchestration entry point
|
|
460
592
|
│ └── logger.ts # Logging utilities
|
|
461
593
|
└── index.js # Vite plugin entry point
|
|
462
594
|
```
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { IColor } from './color.interface';
|
|
2
2
|
import { IUtility } from './preset.interface';
|
|
3
3
|
import { IFileConfig } from './files.interface';
|
|
4
|
-
|
|
5
4
|
export interface IEnvConfig {
|
|
6
5
|
utilities: IUtility[];
|
|
7
6
|
files: IFileConfig;
|
|
8
|
-
|
|
9
7
|
/** User-given classes to force the css rule creation */
|
|
10
8
|
force: string[];
|
|
11
|
-
|
|
12
9
|
colors: IColor;
|
|
13
10
|
states: string[];
|
|
14
11
|
[key: string]: any;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
export interface IVariation {
|
|
2
2
|
[key: string]: string;
|
|
3
3
|
}
|
|
4
|
-
|
|
5
4
|
export interface IUtility {
|
|
6
|
-
// [key: string]: string
|
|
7
5
|
prefix: string;
|
|
8
6
|
declaration: string;
|
|
9
|
-
|
|
10
7
|
/** When true, class can be called without variation, creating a rule with default variation */
|
|
11
8
|
standalone?: boolean;
|
|
12
|
-
|
|
13
9
|
/**
|
|
14
10
|
* Controls how variations are exported as SCSS variables:
|
|
15
11
|
* - "variation": export every variations
|
|
16
12
|
* - "all": export every possible color class (utility prefix + every colors)
|
|
17
13
|
* - undefined: do not export variations
|
|
18
14
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export?: 'variations' | 'all';
|
|
16
|
+
/** Override default global variables with the "default" variation if existing */
|
|
17
|
+
overrides?: string[];
|
|
21
18
|
/** List of every possible variations */
|
|
22
19
|
variations: IVariation;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
export interface IRuleInfo {
|
|
26
22
|
selector: string;
|
|
27
23
|
declaration: string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.config = exports.init = void 0;
|
|
7
|
+
const config_file_1 = require("./fileStuff/config.file");
|
|
8
|
+
const logger_1 = require("./logger");
|
|
9
|
+
const color_validation_1 = require("./validation/color.validation");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const anubisConfigFolder = path_1.default.join(__dirname, '..', '..', 'src', 'config');
|
|
13
|
+
const anubisConfigFiles = [
|
|
14
|
+
'utilities',
|
|
15
|
+
'files',
|
|
16
|
+
'colors',
|
|
17
|
+
'states',
|
|
18
|
+
'force',
|
|
19
|
+
];
|
|
20
|
+
const config = {
|
|
21
|
+
utilities: [],
|
|
22
|
+
force: [],
|
|
23
|
+
files: { targets: [], ignore: [] },
|
|
24
|
+
colors: {},
|
|
25
|
+
states: [],
|
|
26
|
+
};
|
|
27
|
+
exports.config = config;
|
|
28
|
+
const init = () => {
|
|
29
|
+
(0, config_file_1.readUserConfigFile)();
|
|
30
|
+
(0, config_file_1.checkUserConfigFile)(anubisConfigFiles);
|
|
31
|
+
for (const file of anubisConfigFiles) {
|
|
32
|
+
let configToUse = null;
|
|
33
|
+
if (config_file_1.userConfig && config_file_1.userConfig[file]) {
|
|
34
|
+
(0, logger_1.log)(`${file} config found, overriding default.`);
|
|
35
|
+
configToUse = config_file_1.userConfig[file];
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const filePath = path_1.default.join(anubisConfigFolder, `${file}.config.json`);
|
|
39
|
+
const fileExists = fs_1.default.existsSync(filePath);
|
|
40
|
+
if (!fileExists) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const configContent = fs_1.default.readFileSync(filePath, { encoding: 'utf-8' });
|
|
44
|
+
if (!configContent) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
configToUse = JSON.parse(configContent);
|
|
48
|
+
}
|
|
49
|
+
config[file] = configToUse;
|
|
50
|
+
switch (file) {
|
|
51
|
+
case 'colors':
|
|
52
|
+
(0, color_validation_1.validateColors)(config.colors);
|
|
53
|
+
break;
|
|
54
|
+
case 'force':
|
|
55
|
+
const forceClasses = config_file_1.userConfig === null || config_file_1.userConfig === void 0 ? void 0 : config_file_1.userConfig['force'];
|
|
56
|
+
if (forceClasses === null || forceClasses === void 0 ? void 0 : forceClasses.length) {
|
|
57
|
+
(0, logger_1.log)(`Forcing the creation of ${forceClasses === null || forceClasses === void 0 ? void 0 : forceClasses.length} classes`);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return config;
|
|
63
|
+
};
|
|
64
|
+
exports.init = init;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Fetch vue file based on config target patterns */
|
|
2
|
+
export declare const init: () => Promise<string>;
|
|
3
|
+
/** Get all variations from utilities with export: "variations" */
|
|
4
|
+
export declare const getExportedVariations: () => Record<string, string>;
|
|
5
|
+
export declare const handleVariations: (extractedVariations: Record<string, string>) => string;
|