anubis-ui 1.0.4 → 1.0.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 +132 -18
- package/package.json +14 -3
- package/src/tools/cssFile.ts +2 -2
- package/src/tools/extract/classes/index.ts +1 -13
- package/src/tools/logger.ts +7 -0
- package/src/tools/mapping/mapClassIntoRule.ts +19 -5
- package/src/tools/extract/colors/index.ts +0 -0
- package/src/tools/extract/presets/index.ts +0 -0
package/README.md
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AnubisUI
|
|
2
2
|
> powered by [__Improba__](https://improba.fr/)
|
|
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 Vue files and mapping utility classes to their corresponding styles.
|
|
5
|
+
|
|
6
|
+
> __THIS DOESN'T WORK__ ```<div :class="`bg-primary-${props.bg || 'low'}\`" />```
|
|
7
|
+
> <br />
|
|
8
|
+
> Classes must be EXPLICITY written in the code to allow the extraction to work correctly, dynamic classes will not work
|
|
9
|
+
> <br />
|
|
10
|
+
> In the future, some config will allow to generate a bunch of specified classes even if not present in the code
|
|
11
|
+
> <br />
|
|
12
|
+
> Until then, you can create a decoy .vue file filled with the dynamic classes you want
|
|
13
|
+
> <br />
|
|
5
14
|
|
|
6
15
|
## Table of Contents
|
|
7
16
|
1. [Features](#features)
|
|
8
17
|
2. [Installation](#installation)
|
|
9
18
|
3. [Configuration](#configuration)
|
|
10
|
-
4. [
|
|
11
|
-
5. [
|
|
19
|
+
4. [Available Utility Classes](#available-utility-classes)
|
|
20
|
+
5. [Prefix/Declaration relations](#prefixdeclaration-relations)
|
|
21
|
+
6. [Architecture](#architecture)
|
|
22
|
+
7. [Credits](#credits)
|
|
12
23
|
|
|
13
24
|
## Features
|
|
14
25
|
- 🎨 Dynamic CSS generation based on utility classes
|
|
@@ -23,10 +34,101 @@ Anubis UI (Autonomous Nominative Utility Based Intuitive Styler) is a Vite plugi
|
|
|
23
34
|
- 🔍 Smart class detection and parsing
|
|
24
35
|
|
|
25
36
|
# Installation
|
|
37
|
+
|
|
38
|
+
1. Add the package to your project
|
|
39
|
+
<br />
|
|
26
40
|
`npm install anubis-ui`
|
|
27
41
|
|
|
42
|
+
2. In the config file, add the package in the plugin section
|
|
43
|
+
```js
|
|
44
|
+
vitePlugins: [
|
|
45
|
+
[
|
|
46
|
+
anubisUI(),
|
|
47
|
+
...
|
|
48
|
+
]
|
|
49
|
+
]
|
|
50
|
+
```
|
|
51
|
+
<sup>quasar.config.js</sup>
|
|
52
|
+
|
|
53
|
+
3. Still in the config file, add the generated file to the css usage
|
|
54
|
+
```js
|
|
55
|
+
css: [
|
|
56
|
+
'app.scss',
|
|
57
|
+
'~anubis-ui/dist/_anubis.scss'
|
|
58
|
+
],
|
|
59
|
+
```
|
|
60
|
+
<sup>quasar.config.js</sup>
|
|
61
|
+
|
|
62
|
+
4. Declare your project colors in the DOM ::root in anyway you want
|
|
63
|
+
<br />
|
|
64
|
+
Personnaly, i use the following method based on a mixin declaration
|
|
65
|
+
|
|
66
|
+
```scss
|
|
67
|
+
$background-opacity: (
|
|
68
|
+
10: 0.1,
|
|
69
|
+
20: 0.2,
|
|
70
|
+
30: 0.3,
|
|
71
|
+
40: 0.4,
|
|
72
|
+
50: 0.5,
|
|
73
|
+
60: 0.6,
|
|
74
|
+
70: 0.7,
|
|
75
|
+
80: 0.8,
|
|
76
|
+
90: 0.9
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
@mixin setGlobalColors($name, $light, $dark) {
|
|
80
|
+
@include setRootColors($name, $light, 'body--light');
|
|
81
|
+
@include setRootColors($name, $dark, 'body--dark');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@mixin setRootColors ($name, $color, $theme) {
|
|
85
|
+
:root {
|
|
86
|
+
body.#{$theme} {
|
|
87
|
+
#{"--"+$name}: $color;
|
|
88
|
+
|
|
89
|
+
@if $color != transparent {
|
|
90
|
+
@each $opacity, $multiplier in $background-opacity {
|
|
91
|
+
#{"--"+$name+"-"+$opacity}: #{rgba(red($color), green($color), blue($color), $multiplier)};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
<sup>src/css/_mixins.scss</sup>
|
|
99
|
+
|
|
100
|
+
```scss
|
|
101
|
+
@import './mixins';
|
|
102
|
+
|
|
103
|
+
/**...highest... */
|
|
104
|
+
/**...higher... */
|
|
105
|
+
/**...high... */
|
|
106
|
+
@include setGlobalColors('primary', $blue-500, $blue-400);
|
|
107
|
+
/**...low... */
|
|
108
|
+
/**...lower... */
|
|
109
|
+
/**...lowest... */
|
|
110
|
+
|
|
111
|
+
@include setGlobalColors('secondary', $blue-grey-500, $blue-grey-400);
|
|
112
|
+
@include setGlobalColors('accent', $blue-500, $blue-400);
|
|
113
|
+
@include setGlobalColors('neutral', $slate-500, $slate-500);
|
|
114
|
+
@include setGlobalColors('success', $green-500, $green-400);
|
|
115
|
+
@include setGlobalColors('danger', $red-500, $red-400);
|
|
116
|
+
```
|
|
117
|
+
<sup>src/css/_colors_.scss</sup>
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
5. Start adding classes however you want to (in *.vue files)
|
|
121
|
+
```html
|
|
122
|
+
<div class="bg-primary border-neutral-low hover:shadow-low" />
|
|
123
|
+
```
|
|
124
|
+
<sup>any .vue file</sup>
|
|
125
|
+
|
|
126
|
+
6. Enjoy
|
|
127
|
+
|
|
28
128
|
## Configuration
|
|
29
|
-
|
|
129
|
+
AnubisUI uses several configuration files located in the `src/config` directory:
|
|
130
|
+
<br />
|
|
131
|
+
Customisation from root file `anubis.config.json` will appear in future updates
|
|
30
132
|
|
|
31
133
|
---
|
|
32
134
|
### Colors (`colors.config.json`)
|
|
@@ -44,6 +146,7 @@ Define your color palette
|
|
|
44
146
|
"warning",
|
|
45
147
|
"danger"
|
|
46
148
|
]
|
|
149
|
+
// no need to includes (lowest, lower, low, high, higher, highest) variants as long as the color name is present in the class
|
|
47
150
|
```
|
|
48
151
|
</details>
|
|
49
152
|
|
|
@@ -104,7 +207,8 @@ Configure common style presets
|
|
|
104
207
|
</details>
|
|
105
208
|
|
|
106
209
|
|
|
107
|
-
|
|
210
|
+
---
|
|
211
|
+
### Selectors (`selectors.config.json`)
|
|
108
212
|
Define available states and style prefixes
|
|
109
213
|
|
|
110
214
|
<details>
|
|
@@ -133,7 +237,8 @@ Define available states and style prefixes
|
|
|
133
237
|
- `bg-{color}` - Background color
|
|
134
238
|
- `text-{color}` - Text color
|
|
135
239
|
- `border-{color}` - Border color
|
|
136
|
-
- `
|
|
240
|
+
- `inner-border-{color}` - Inner border color (inset box shadow, not compatible with `shadow-`)
|
|
241
|
+
- `shadow-{color}` - Box shadow color (not compatible with `inner-border-`)
|
|
137
242
|
|
|
138
243
|
#### States
|
|
139
244
|
- `hover:{utility}` - Apply style on hover
|
|
@@ -145,25 +250,34 @@ Define available states and style prefixes
|
|
|
145
250
|
- `shadow-{color}-{preset}` - Box shadow spread
|
|
146
251
|
- `inner-border-{color}-{preset}` - Box shadow inset width
|
|
147
252
|
|
|
253
|
+
## Prefix/Declaration relations
|
|
254
|
+
| prefix | declaration |
|
|
255
|
+
|--------------|-----------------------------------------------------------------------------|
|
|
256
|
+
| bg | `background: {color} important;` |
|
|
257
|
+
| text | `color: {color} important;` |
|
|
258
|
+
| border | `border-width: {variation \|\| default} !important; border-color: {color} !important; border-style: solid;` |
|
|
259
|
+
| inner-border | `box-shadow: inset {variation \|\| default} {color} !important;` |
|
|
260
|
+
| shadow | `box-shadow: {variation \|\| default} {color} !important;` |
|
|
261
|
+
|
|
148
262
|
## Architecture
|
|
149
263
|
### Core Components
|
|
150
264
|
- **Vite Plugin**: Handles file watching and build process
|
|
151
265
|
- **Class Extractor**: Scans files for utility classes
|
|
152
266
|
- **Rule Generator**: Converts utility classes to CSS rules
|
|
153
|
-
- **Configuration System**: Manages user preferences and presets
|
|
267
|
+
- **Configuration System**: WIP - Manages user preferences and presets
|
|
154
268
|
|
|
155
269
|
### File Structure
|
|
156
270
|
```
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
├── config/ # Configuration files
|
|
160
|
-
├── interfaces/ # TypeScript interfaces
|
|
161
|
-
├── manual/ # Manually trigger anubis actions
|
|
162
|
-
|
|
163
|
-
│
|
|
164
|
-
│
|
|
165
|
-
│
|
|
166
|
-
└── index.
|
|
271
|
+
├── dist/ # Compiled and generated output
|
|
272
|
+
├── src/
|
|
273
|
+
│ ├── config/ # Configuration files
|
|
274
|
+
│ ├── interfaces/ # TypeScript interfaces
|
|
275
|
+
│ ├── manual/ # Manually trigger anubis actions
|
|
276
|
+
│ └── tools/
|
|
277
|
+
│ ├── extract/ # Class extraction logic
|
|
278
|
+
│ ├── declaration/ # WIP - Style declaration handlers
|
|
279
|
+
│ └── mapping/ # Class to CSS rule mapping
|
|
280
|
+
└── index.js # Plugin entry point
|
|
167
281
|
```
|
|
168
282
|
|
|
169
283
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anubis-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Class-based css generator",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"anubis",
|
|
8
|
+
"anubisUI",
|
|
9
|
+
"css",
|
|
10
|
+
"scss",
|
|
11
|
+
"style",
|
|
12
|
+
"plugin",
|
|
13
|
+
"vite",
|
|
14
|
+
"quasar",
|
|
15
|
+
"vue"
|
|
16
|
+
],
|
|
6
17
|
"scripts": {
|
|
7
18
|
"build": "tsc",
|
|
8
|
-
"
|
|
19
|
+
"preinstall": "npm run build"
|
|
9
20
|
},
|
|
10
21
|
"style": "dist/_anubis.scss",
|
|
11
22
|
"repository": {
|
|
12
23
|
"type": "git",
|
|
13
24
|
"url": "git+https://github.com/HugoLMTY/anubis-ui.git"
|
|
14
25
|
},
|
|
15
|
-
"author": "
|
|
26
|
+
"author": "Improba",
|
|
16
27
|
"license": "ISC",
|
|
17
28
|
"bugs": {
|
|
18
29
|
"url": "https://github.com/HugoLMTY/anubis-ui/issues"
|
package/src/tools/cssFile.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const fs = require('fs')
|
|
4
4
|
const path = require('path')
|
|
5
5
|
|
|
6
|
-
import { log } from './logger'
|
|
6
|
+
import { cssHeader, log } from './logger'
|
|
7
7
|
|
|
8
8
|
const distDir = path.join(__dirname, '..', '..', 'dist')
|
|
9
9
|
const outputPath = path.join(distDir, '_anubis.scss')
|
|
@@ -25,7 +25,7 @@ const buildCssRuleFile = (classes: string = '') => {
|
|
|
25
25
|
try {
|
|
26
26
|
checkCssRuleFilePresence()
|
|
27
27
|
|
|
28
|
-
fs.writeFileSync(outputPath, classes)
|
|
28
|
+
fs.writeFileSync(outputPath, cssHeader + '\n' + classes)
|
|
29
29
|
|
|
30
30
|
return outputPath
|
|
31
31
|
} catch (err: any) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { config } from "../../../config/config.tool"
|
|
2
2
|
import { buildCssRuleFile } from "../../cssFile"
|
|
3
|
-
import {
|
|
4
|
-
import { mapClassIntoRule } from "../../mapping/mapClassIntoRule"
|
|
3
|
+
import { mapClassesIntoRules } from "../../mapping/mapClassIntoRule"
|
|
5
4
|
import { getFiles } from "../extract.tools"
|
|
6
5
|
|
|
7
6
|
// import fs from 'fs'
|
|
@@ -52,17 +51,6 @@ const extractClasses = async (filePath: string): Promise<string[]> => {
|
|
|
52
51
|
return matches
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
const mapClassesIntoRules = (classes: string[]) => {
|
|
56
|
-
const mappedRules = classes
|
|
57
|
-
?.map(cssClass => mapClassIntoRule(cssClass))
|
|
58
|
-
?.filter(rule => rule)
|
|
59
|
-
|
|
60
|
-
log(`${mappedRules?.length} rules generated`)
|
|
61
|
-
|
|
62
|
-
const rules = mappedRules?.join('\n')
|
|
63
|
-
return rules
|
|
64
|
-
}
|
|
65
|
-
|
|
66
54
|
export {
|
|
67
55
|
init
|
|
68
56
|
}
|
package/src/tools/logger.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { config } from "../../config/config.tool"
|
|
2
|
+
import { log } from "../logger"
|
|
3
|
+
|
|
4
|
+
const mapClassesIntoRules = (classes: string[]) => {
|
|
5
|
+
const mappedRules = classes
|
|
6
|
+
?.map(cssClass => mapClassIntoRule(cssClass))
|
|
7
|
+
?.filter(rule => rule)
|
|
8
|
+
|
|
9
|
+
log(`${mappedRules?.length} rules generated`)
|
|
10
|
+
|
|
11
|
+
const rules = mappedRules?.join('\n')
|
|
12
|
+
return rules
|
|
13
|
+
}
|
|
2
14
|
|
|
3
15
|
const mapClassIntoRule = (stringClass: string) => {
|
|
4
16
|
const colorExists = config.colors?.some(color => stringClass.includes(color))
|
|
@@ -59,11 +71,12 @@ const getVariantInfos = ({ cleanedColor, prefix }: { cleanedColor: string, prefi
|
|
|
59
71
|
const isOpacity = opacityDetectionRegex.test(cleanedColor)
|
|
60
72
|
if (isOpacity) {
|
|
61
73
|
return {
|
|
62
|
-
color: cleanedColor
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
color: cleanedColor // Opacity is included in the color name, whoops on me for this one (and every other one tho)
|
|
75
|
+
// color: cleanedColor?.slice(0, -3),
|
|
76
|
+
// variation: {
|
|
77
|
+
// key: 'opacity',
|
|
78
|
+
// value: cleanedColor?.slice(-2),
|
|
79
|
+
// }
|
|
67
80
|
}
|
|
68
81
|
}
|
|
69
82
|
|
|
@@ -151,5 +164,6 @@ function mapIntoRule({ state, prefix, color, variation }: { state?: string, pref
|
|
|
151
164
|
}
|
|
152
165
|
|
|
153
166
|
export {
|
|
167
|
+
mapClassesIntoRules,
|
|
154
168
|
mapClassIntoRule
|
|
155
169
|
}
|
|
File without changes
|
|
File without changes
|