anubis-ui 1.2.4 → 1.2.6
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
|
@@ -7,9 +7,7 @@ AnubisUI (Autonomous Nominative Utility Based Intuitive Styler) is a Vite plugin
|
|
|
7
7
|
> <br />
|
|
8
8
|
> Classes must be EXPLICITY written in the code to allow the extraction to work correctly, dynamic classes will not work
|
|
9
9
|
> <br />
|
|
10
|
-
>
|
|
11
|
-
> <br />
|
|
12
|
-
> Until then, you can create a decoy .vue file filled with the dynamic classes you want
|
|
10
|
+
> You can use the `force` configuration to generate specific classes even if they're not present in the code
|
|
13
11
|
> <br />
|
|
14
12
|
|
|
15
13
|
## Table of Contents
|
|
@@ -167,6 +165,13 @@ For every config you want to change, add the corresponding section in your confi
|
|
|
167
165
|
"thin": "2px"
|
|
168
166
|
}
|
|
169
167
|
}
|
|
168
|
+
],
|
|
169
|
+
|
|
170
|
+
// force.config.json
|
|
171
|
+
"force": [
|
|
172
|
+
"bg-primary-10",
|
|
173
|
+
"bg-primary-20",
|
|
174
|
+
"bg-primary-30"
|
|
170
175
|
]
|
|
171
176
|
}
|
|
172
177
|
```
|
|
@@ -342,6 +347,29 @@ Example usage:
|
|
|
342
347
|
<div class="rounded smooth" /> <!-- Works because these are standalone -->
|
|
343
348
|
```
|
|
344
349
|
|
|
350
|
+
### Force (`force.config.json`)
|
|
351
|
+
Force the generation of specific CSS classes even if they're not found in your code. This is particularly useful for dynamic classes that can't be detected during the extraction process.
|
|
352
|
+
|
|
353
|
+
<details>
|
|
354
|
+
<summary>Default config</summary>
|
|
355
|
+
|
|
356
|
+
```json
|
|
357
|
+
[]
|
|
358
|
+
```
|
|
359
|
+
</details>
|
|
360
|
+
|
|
361
|
+
Example usage:
|
|
362
|
+
```json
|
|
363
|
+
{
|
|
364
|
+
"force": [
|
|
365
|
+
"bg-primary-10",
|
|
366
|
+
"bg-primary-20",
|
|
367
|
+
"bg-primary-30",
|
|
368
|
+
"hover:bg-secondary-50"
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
345
373
|
## Available Utility Classes
|
|
346
374
|
#### Colors
|
|
347
375
|
- `bg-{color}` - Background color
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ const anubisConfigFolder = path.join(__dirname, '..', '..', 'src', 'config');
|
|
|
9
9
|
const anubisConfigFiles = [
|
|
10
10
|
'qol',
|
|
11
11
|
'files',
|
|
12
|
+
'force',
|
|
12
13
|
'colors',
|
|
13
14
|
'states',
|
|
14
15
|
'presets',
|
|
@@ -18,6 +19,9 @@ const config = {
|
|
|
18
19
|
qol: [],
|
|
19
20
|
presets: [],
|
|
20
21
|
|
|
22
|
+
/** User-given classes to force the css rule creation */
|
|
23
|
+
force: [],
|
|
24
|
+
|
|
21
25
|
files: { targets: [], ignore: [] },
|
|
22
26
|
colors: [],
|
|
23
27
|
states: [],
|
|
@@ -37,6 +41,7 @@ const init = () => {
|
|
|
37
41
|
} else {
|
|
38
42
|
const filePath = path.join(anubisConfigFolder, `${file}.config.json`)
|
|
39
43
|
const configContent = fs.readFileSync(filePath, { encoding: 'utf-8' })
|
|
44
|
+
if (!configContent) { continue }
|
|
40
45
|
|
|
41
46
|
configToUse = JSON.parse(configContent)
|
|
42
47
|
}
|
package/src/manual/build.js
CHANGED
|
@@ -22,9 +22,10 @@ const getUniqueClasses = async (files: string[]): Promise<string[]> => {
|
|
|
22
22
|
files.map(async file => extractClasses(file))
|
|
23
23
|
))
|
|
24
24
|
?.flat()
|
|
25
|
-
?.sort()
|
|
26
25
|
|
|
27
|
-
const
|
|
26
|
+
const classes = [...extractedClasses, ...config.force]?.sort()
|
|
27
|
+
|
|
28
|
+
const uniqueClasses = Array.from(new Set(classes))
|
|
28
29
|
return uniqueClasses
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -43,16 +43,17 @@ const mapClassIntoRule = (stringClass: string) => {
|
|
|
43
43
|
const getClassInfos = (stringClass: string) => {
|
|
44
44
|
const { cleanedClass, state } = getStateInfos(stringClass)
|
|
45
45
|
const { cleanedColor, prefix } = getPrefixInfos(cleanedClass)
|
|
46
|
-
const { preset, variation } = getPresetInfos({ cleanedColor, prefix })
|
|
46
|
+
const { baseColor, preset, variation, variationName } = getPresetInfos({ cleanedColor, prefix })
|
|
47
47
|
|
|
48
48
|
return {
|
|
49
49
|
state,
|
|
50
50
|
|
|
51
|
-
color:
|
|
51
|
+
color: baseColor,
|
|
52
52
|
prefix,
|
|
53
53
|
|
|
54
54
|
preset,
|
|
55
|
-
variation
|
|
55
|
+
variation,
|
|
56
|
+
variationName
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -122,18 +123,24 @@ const getPresetInfos = ({ cleanedColor, prefix }: { cleanedColor: string, prefix
|
|
|
122
123
|
|
|
123
124
|
const possibleVariations = (matchingPreset.variations || { default: '' })
|
|
124
125
|
|
|
126
|
+
const defaultVariation = 'default'
|
|
125
127
|
const matchingVariation = Object.keys(possibleVariations)
|
|
126
|
-
?.find(v => cleanedColor.endsWith(v))
|
|
128
|
+
?.find(v => cleanedColor.endsWith(v))
|
|
127
129
|
|
|
128
|
-
const variation = possibleVariations[matchingVariation]
|
|
130
|
+
const variation = possibleVariations[matchingVariation || defaultVariation]
|
|
131
|
+
const baseColor = matchingVariation
|
|
132
|
+
? cleanedColor?.slice(0, -matchingVariation?.length - 1)
|
|
133
|
+
: cleanedColor
|
|
129
134
|
|
|
130
135
|
return {
|
|
136
|
+
baseColor,
|
|
131
137
|
preset: matchingPreset,
|
|
138
|
+
variationName: matchingVariation,
|
|
132
139
|
variation,
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
|
|
136
|
-
const mapIntoRule = ({ state, prefix, color, preset, variation }) => {
|
|
143
|
+
const mapIntoRule = ({ state, prefix, color, preset, variation, variationName }) => {
|
|
137
144
|
// _ Set state selector
|
|
138
145
|
let stateSelector = ''
|
|
139
146
|
switch (state) {
|
|
@@ -146,7 +153,7 @@ const mapIntoRule = ({ state, prefix, color, preset, variation }) => {
|
|
|
146
153
|
break
|
|
147
154
|
}
|
|
148
155
|
|
|
149
|
-
let selector = `${prefix}${color ? `-${color}` : ''}`
|
|
156
|
+
let selector = `${prefix}${color ? `-${color}` : ''}${variationName ? `-${variationName}` : ''}`
|
|
150
157
|
if (state) {
|
|
151
158
|
selector = `${state}\\:${selector}${stateSelector}`
|
|
152
159
|
}
|