anubis-ui 1.0.4 → 1.0.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # Anubis UI
1
+ # AnubisUI
2
2
  > powered by [__Improba__](https://improba.fr/)
3
3
 
4
- Anubis UI (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.
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
5
 
6
6
  ## Table of Contents
7
7
  1. [Features](#features)
@@ -23,10 +23,94 @@ Anubis UI (Autonomous Nominative Utility Based Intuitive Styler) is a Vite plugi
23
23
  - 🔍 Smart class detection and parsing
24
24
 
25
25
  # Installation
26
+
27
+ 1. Add the package to your project
28
+ <br />
26
29
  `npm install anubis-ui`
27
30
 
31
+ 2. In the config file, add the package in the plugin section
32
+ ```js
33
+ vitePlugins: [
34
+ [
35
+ anubisUI(),
36
+ ...
37
+ ]
38
+ ]
39
+ ```
40
+ <sup>quasar.config.js</sup>
41
+
42
+ 3. Still in the config file, add the generated file to the css usage
43
+ ```js
44
+ css: [
45
+ 'app.scss',
46
+ '~anubis-ui/dist/_anubis.scss'
47
+ ],
48
+ ```
49
+ <sup>quasar.config.js</sup>
50
+
51
+
52
+ 4. Start adding classes to your *.vue files
53
+ ```html
54
+ <div class="bg-primary border-neutral-low hover:shadow-low" />
55
+ ```
56
+ <sup>any .vue file</sup>
57
+
58
+ 5. Declare your project colors in the DOM ::root in anyway you want
59
+ <br />
60
+ Personnaly, i use the following method based on a mixin declaration
61
+
62
+ ```scss
63
+ $background-opacity: (
64
+ 10: 0.1,
65
+ 20: 0.2,
66
+ 30: 0.3,
67
+ 40: 0.4,
68
+ 50: 0.5,
69
+ 60: 0.6,
70
+ 70: 0.7,
71
+ 80: 0.8,
72
+ 90: 0.9
73
+ );
74
+
75
+ @mixin setGlobalColors($light, $dark, $name) {
76
+ @include setRootColors($name, $light, 'body--light');
77
+ @include setRootColors($name, $dark, 'body--dark');
78
+ }
79
+
80
+ @mixin setRootColors ($name, $color, $theme) {
81
+ :root {
82
+ body.#{$theme} {
83
+ #{"--"+$name}: $color;
84
+
85
+ @if $color != transparent {
86
+ @each $opacity, $multiplier in $background-opacity {
87
+ #{"--"+$name+"-"+$opacity}: #{rgba(red($color), green($color), blue($color), $multiplier)};
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+ <sup>src/css/_mixins.scss</sup>
95
+
96
+ ```scss
97
+ @import './mixins';
98
+
99
+ @include defineColorLightAndDark('primary', $blue-500, $blue-400);
100
+ @include defineColorLightAndDark('secondary', $blue-grey-500, $blue-grey-400);
101
+ @include defineColorLightAndDark('accent', $blue-500, $blue-400);
102
+ @include defineColorLightAndDark('neutral', $slate-500, $slate-500);
103
+ @include defineColorLightAndDark('success', $green-500, $green-400);
104
+ @include defineColorLightAndDark('danger', $red-500, $red-400);
105
+ ```
106
+ <sup>src/css/_colors_.scss</sup>
107
+
108
+ 6. Enjoy
109
+
28
110
  ## Configuration
29
- Anubis UI uses several configuration files located in the `src/config` directory:
111
+ AnubisUI uses several configuration files located in the `src/config` directory:
112
+ <br />
113
+ Customisation from root file `anubis.config.json` will appear in future updates
30
114
 
31
115
  ---
32
116
  ### Colors (`colors.config.json`)
@@ -104,7 +188,8 @@ Configure common style presets
104
188
  </details>
105
189
 
106
190
 
107
- ---### Selectors (`selectors.config.json`)
191
+ ---
192
+ ### Selectors (`selectors.config.json`)
108
193
  Define available states and style prefixes
109
194
 
110
195
  <details>
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "anubis-ui",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Class-based css generator",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
8
- "prepare": "npm run build"
8
+ "preinstall": "npm run build"
9
9
  },
10
10
  "style": "dist/_anubis.scss",
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/HugoLMTY/anubis-ui.git"
14
14
  },
15
- "author": "HugoLMTY - Improba",
15
+ "author": "Improba",
16
16
  "license": "ISC",
17
17
  "bugs": {
18
18
  "url": "https://github.com/HugoLMTY/anubis-ui/issues"
@@ -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 { log } from "../../logger"
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
  }
@@ -13,8 +13,15 @@ const logo = () => {
13
13
  log('---')
14
14
  }
15
15
 
16
+ const cssHeader = `/*!
17
+ * * Anubis v.1.0.5
18
+ * * Improba
19
+ * * Released under the MIT License.
20
+ * */`
21
+
16
22
  export {
17
23
  logo,
24
+ cssHeader,
18
25
 
19
26
  log,
20
27
  logPrefix
@@ -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?.slice(0, -3),
63
- variation: {
64
- key: 'opacity',
65
- value: cleanedColor?.slice(-2),
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