anubis-ui 1.2.3 → 1.2.5
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/index.d.ts +10 -4
- package/index.js +10 -2
- package/package.json +1 -1
- package/src/config/qol.config.json +1 -1
- package/src/manual/build.js +2 -1
- package/src/tools/mapping/mapClassIntoRule.ts +14 -7
package/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { IEnvConfig } from './dist/interfaces/config.interface';
|
|
2
|
-
|
|
3
1
|
declare module 'anubis-ui' {
|
|
4
2
|
import type { Plugin } from 'vite';
|
|
3
|
+
import type { IEnvConfig } from './dist/interfaces/config.interface';
|
|
4
|
+
|
|
5
|
+
const plugin: Plugin;
|
|
6
|
+
const config: IEnvConfig;
|
|
7
|
+
|
|
8
|
+
const anubis: {
|
|
9
|
+
plugin: typeof plugin;
|
|
10
|
+
config: typeof config;
|
|
11
|
+
};
|
|
5
12
|
|
|
6
|
-
export
|
|
7
|
-
export const config: IEnvConfig;
|
|
13
|
+
export default anubis;
|
|
8
14
|
}
|
package/index.js
CHANGED
|
@@ -40,11 +40,19 @@ function AnubisUI() {
|
|
|
40
40
|
name: 'anubis-ui',
|
|
41
41
|
configureServer(server) {
|
|
42
42
|
server.watcher.on('change', async (file) => {
|
|
43
|
-
|
|
43
|
+
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
|
|
44
|
+
await refresh(file)
|
|
45
|
+
} else {
|
|
46
|
+
log('Trying to build in a not Node environment, aborting')
|
|
47
|
+
}
|
|
44
48
|
});
|
|
45
49
|
},
|
|
46
50
|
async buildStart() {
|
|
47
|
-
|
|
51
|
+
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
|
|
52
|
+
await init();
|
|
53
|
+
} else {
|
|
54
|
+
log('Trying to build in a not Node environment, aborting')
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
};
|
|
50
58
|
}
|
package/package.json
CHANGED
package/src/manual/build.js
CHANGED
|
@@ -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
|
}
|