anubis-ui 1.2.24 → 1.2.25
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 +19 -8
- package/package.json +1 -1
- package/src/interfaces/config.interface.ts +2 -2
- package/src/interfaces/preset.interface.ts +1 -1
- package/src/tools/config.tool.ts +4 -4
- package/src/tools/extraction/extractClasses.ts +3 -3
- package/src/tools/mapping/mapClassIntoRule.ts +1 -2
- package/src/tools/output/css.output.ts +2 -2
package/README.md
CHANGED
|
@@ -129,6 +129,15 @@ For every config you want to change, add the corresponding section in your confi
|
|
|
129
129
|
"default": "4px",
|
|
130
130
|
"thin": "2px"
|
|
131
131
|
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"prefix": "rounded",
|
|
135
|
+
"declaration": "border-radius: ${value}",
|
|
136
|
+
"variations": {
|
|
137
|
+
"default": "8px",
|
|
138
|
+
"lg": "12px"
|
|
139
|
+
},
|
|
140
|
+
"export-variations": false
|
|
132
141
|
}
|
|
133
142
|
],
|
|
134
143
|
|
|
@@ -243,21 +252,23 @@ QoL utilities include:
|
|
|
243
252
|
1. `prefix` - The class name prefix
|
|
244
253
|
2. `declaration` - CSS rule using `${value}` placeholder for variations
|
|
245
254
|
3. `variations` - Key-value pairs of variation names and their CSS values
|
|
246
|
-
4. `
|
|
247
|
-
5. `export-variations` (optional) - Generates CSS variables for all variations
|
|
248
|
-
|
|
249
|
-
**The `standalone` flag**:
|
|
250
|
-
- `standalone: true` → Can use `rounded` or `rounded-lg` (both valid)
|
|
251
|
-
- `standalone: false` or omitted → Must use `border-solid` (requires variation)
|
|
255
|
+
4. `export-variations` (optional) - Generates CSS variables for all variations
|
|
252
256
|
|
|
253
257
|
**The `export-variations` flag**:
|
|
254
258
|
- `export-variations: true` → Generates `--size-xs`, `--size-md`, etc. as CSS variables
|
|
255
259
|
- These can be used in custom CSS: `font-size: var(--size-xl)`
|
|
256
260
|
|
|
261
|
+
**Color support**:
|
|
262
|
+
- Use `${color}` in declaration to indicate the utility requires a color
|
|
263
|
+
- Colors are automatically injected as CSS variables: `var(--{color})`
|
|
264
|
+
|
|
265
|
+
**Standalone usage**:
|
|
266
|
+
- Utilities with a `default` variation and no color requirement can be used without specifying a variation (e.g., `rounded` uses `rounded-default`)
|
|
267
|
+
|
|
257
268
|
Example usage:
|
|
258
269
|
```html
|
|
259
|
-
<div class="
|
|
260
|
-
<div class="rounded smooth blur" /> <!--
|
|
270
|
+
<div class="bg-primary-low border-neutral-medium hover:shadow-wide rounded-lg" />
|
|
271
|
+
<div class="rounded smooth blur" /> <!-- Uses default variations -->
|
|
261
272
|
<p class="size-2xl weight-bold">Typography utilities</p>
|
|
262
273
|
```
|
|
263
274
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IColor } from './color.interface';
|
|
2
|
-
import {
|
|
2
|
+
import { IUtility } from './preset.interface';
|
|
3
3
|
import { IFileConfig } from './files.interface';
|
|
4
4
|
|
|
5
5
|
export interface IEnvConfig {
|
|
6
|
-
utilities:
|
|
6
|
+
utilities: IUtility[];
|
|
7
7
|
files: IFileConfig;
|
|
8
8
|
|
|
9
9
|
/** User-given classes to force the css rule creation */
|
package/src/tools/config.tool.ts
CHANGED
|
@@ -37,7 +37,7 @@ const init = () => {
|
|
|
37
37
|
} else {
|
|
38
38
|
const filePath = path.join(anubisConfigFolder, `${file}.config.json`)
|
|
39
39
|
const fileExists = fs.existsSync(filePath)
|
|
40
|
-
if (!fileExists) {
|
|
40
|
+
if (!fileExists) { continue }
|
|
41
41
|
|
|
42
42
|
const configContent = fs.readFileSync(filePath, { encoding: 'utf-8' })
|
|
43
43
|
if (!configContent) { continue }
|
|
@@ -45,9 +45,11 @@ const init = () => {
|
|
|
45
45
|
configToUse = JSON.parse(configContent)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
config[file as keyof typeof config] = configToUse
|
|
49
|
+
|
|
48
50
|
switch (file) {
|
|
49
51
|
case 'colors':
|
|
50
|
-
validateColors(config
|
|
52
|
+
validateColors(config.colors)
|
|
51
53
|
break
|
|
52
54
|
|
|
53
55
|
case 'force':
|
|
@@ -57,8 +59,6 @@ const init = () => {
|
|
|
57
59
|
}
|
|
58
60
|
break
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
config[file as keyof typeof config] = configToUse
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
return config
|
|
@@ -116,7 +116,7 @@ const buildClassDetectionRegex = (): RegExp => {
|
|
|
116
116
|
const hasDefaultVariation = hasVariations && variations.includes('default')
|
|
117
117
|
const needColor = declaration.includes('${color}')
|
|
118
118
|
|
|
119
|
-
/** If variation has default key
|
|
119
|
+
/** If variation has default key and doesn't need color, can be used solo */
|
|
120
120
|
if (hasVariations && hasDefaultVariation && !needColor) {
|
|
121
121
|
return `${prefix}`
|
|
122
122
|
}
|
|
@@ -137,8 +137,8 @@ const buildClassDetectionRegex = (): RegExp => {
|
|
|
137
137
|
|
|
138
138
|
/** Get cached regex or build a new one if config changed */
|
|
139
139
|
const getClassDetectionRegex = (): RegExp => {
|
|
140
|
-
const { states,
|
|
141
|
-
const configHash = JSON.stringify({ states,
|
|
140
|
+
const { states, utilities } = config;
|
|
141
|
+
const configHash = JSON.stringify({ states, utilities });
|
|
142
142
|
|
|
143
143
|
if (cachedRegex && cachedConfigHash === configHash) {
|
|
144
144
|
return cachedRegex;
|
|
@@ -120,8 +120,7 @@ const getUtilityInfos = ({
|
|
|
120
120
|
}) => {
|
|
121
121
|
/**
|
|
122
122
|
* Find utility variations matching the prefix from the config
|
|
123
|
-
* Since a prefix can be in multiple
|
|
124
|
-
* TODO fix first default occurence getting picked when duplicate
|
|
123
|
+
* Since a prefix can be in multiple utilities, filter every matching prefixes
|
|
125
124
|
*/
|
|
126
125
|
const possibleUtility = [...config.utilities].filter(
|
|
127
126
|
p => p.prefix === prefix
|
|
@@ -61,7 +61,7 @@ const COLOR_COMMENT = `/**
|
|
|
61
61
|
|
|
62
62
|
const VARIANT_COMMENT = `/**
|
|
63
63
|
* These css variables are generated automatically when Anubis
|
|
64
|
-
* detects that they are used in
|
|
64
|
+
* detects that they are used in utilities in your config.
|
|
65
65
|
*
|
|
66
66
|
* It allows you to write custom css/scss classes in your web
|
|
67
67
|
* components like:
|
|
@@ -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
|
-
*
|
|
75
|
+
* utility by setting the 'export-variations' to 'true')
|
|
76
76
|
*/`;
|
|
77
77
|
|
|
78
78
|
const CLASS_COMMENT = `/**
|