aliascss 1.5.1 → 1.5.3
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/CHANGELOG.md +27 -0
- package/README.md +408 -553
- package/dist/aliascss.js +1 -1
- package/lib/classPrinter.js +25 -16
- package/lib/css-properties-all.js +43 -10
- package/lib/node/compileFile.js +36 -9
- package/lib/returnPropertyAndValue.js +17 -6
- package/lib/returnStatement.js +18 -4
- package/lib/utils/cssFunc.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,635 +1,490 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AliasCSS
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Write CSS in your class names.** AliasCSS is a compiler that turns class names into native CSS. Each class is one CSS declaration, so if you know CSS, you already know AliasCSS.
|
|
4
4
|
|
|
5
|
-
AliasCSS or in short acss, is a post css processor/compiler means it lets you first define classnames in your html element then get processed to corresponding css declaration.
|
|
6
|
-
|
|
7
|
-
[https:aliascss.com](Offical Documentation site)
|
|
8
|
-
|
|
9
|
-
## What it is?
|
|
10
|
-
With aliascss you can style you webpages using class attribute with post-define classname, for example
|
|
11
5
|
```html
|
|
12
|
-
<
|
|
6
|
+
<button class="d-flex aic g-8px p-8px-16px br-8px bgc-blue c-white --hover-bgc-navy @md-p-12px-20px">
|
|
7
|
+
Save
|
|
8
|
+
</button>
|
|
13
9
|
```
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
|
|
10
|
+
|
|
11
|
+
```css
|
|
12
|
+
.d-flex { display: flex }
|
|
13
|
+
.aic { align-items: center }
|
|
14
|
+
.g-8px { gap: 8px }
|
|
15
|
+
.p-8px-16px { padding: 8px 16px }
|
|
16
|
+
.br-8px { border-radius: 8px }
|
|
17
|
+
.bgc-blue { background-color: blue }
|
|
18
|
+
.c-white { color: white }
|
|
19
|
+
.--hover-bgc-navy:hover { background-color: navy }
|
|
20
|
+
@media (min-width: 768px) { .\@md-p-12px-20px { padding: 12px 20px } }
|
|
17
21
|
```
|
|
18
|
-
Here we have defined the color, font size, display properties of h1 element first, then aliascss will compiles and defines the classname with the corresponding property and value/s in the styles tag or stylesheets. Generally every aliascss classname hold single property and value for it.
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
- **Any CSS property, any value.** There's no fixed list of utilities to learn. Full property names always work (`justify-content-space-between`), and short aliases exist for the common ones (`jcsb`).
|
|
24
|
+
- **States, selectors and media queries live in the class:** `--hover-…`, `[aria-expanded=true]-…`, `[data-open]&…`, `@md-…`, `@motion-reduce-…`.
|
|
25
|
+
- **Light and dark themes built in.** Radix-style colour tokens (`slateTheme1`–`12`) and an accent scale driven by one variable (`--accentColor`).
|
|
26
|
+
- **No config needed to start.** Add a config file when you want custom values, your own components or a build step.
|
|
27
|
+
|
|
28
|
+
📖 Documentation: [aliascss.com](https://aliascss.com)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Contents
|
|
33
|
+
|
|
34
|
+
- [Install](#install)
|
|
35
|
+
- [The rule: one class, one declaration](#the-rule-one-class-one-declaration)
|
|
36
|
+
- [Values](#values)
|
|
37
|
+
- [States and pseudo-elements](#states-and-pseudo-elements)
|
|
38
|
+
- [Attributes and other elements](#attributes-and-other-elements)
|
|
39
|
+
- [Responsive and other scopes](#responsive-and-other-scopes)
|
|
40
|
+
- [Groups and exports](#groups-and-exports)
|
|
41
|
+
- [CSS variables](#css-variables)
|
|
42
|
+
- [Colours and themes](#colours-and-themes)
|
|
43
|
+
- [Keyframes](#keyframes)
|
|
44
|
+
- [x- components](#x--components)
|
|
45
|
+
- [React, Vue and other frameworks](#react-vue-and-other-frameworks)
|
|
46
|
+
- [CLI and aliascss.config.js](#cli-and-aliascssconfigjs)
|
|
47
|
+
- [Using AliasCSS with AI coding agents](#using-aliascss-with-ai-coding-agents)
|
|
48
|
+
- [Upgrading from older versions](#upgrading-from-older-versions)
|
|
49
|
+
- [Changelog](#changelog)
|
|
21
50
|
|
|
22
|
-
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Install
|
|
23
54
|
|
|
24
|
-
###
|
|
25
|
-
|
|
55
|
+
### CLI (production)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
26
58
|
npm install --save-dev aliascss
|
|
59
|
+
npx aliascss "src/**/*.html" public/css/acss.css # input glob → output file
|
|
60
|
+
npx aliascss "src/**/*.html" public/css/acss.css --watch
|
|
27
61
|
```
|
|
28
62
|
|
|
29
|
-
|
|
30
|
-
```html copy
|
|
31
|
-
<script defer src="https://cdn.jsdelivr.net/npm/aliascss@latest/dist/aliascss.js"></script>
|
|
63
|
+
The CLI scans your files and writes one CSS file. Link that file in your app.
|
|
32
64
|
|
|
33
|
-
|
|
65
|
+
### CDN (development and experiments only)
|
|
34
66
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
<h1>Hello World!</h1>
|
|
39
|
-
```
|
|
40
|
-
Normally , we will apply style as shown below
|
|
41
|
-
```
|
|
42
|
-
h1{
|
|
43
|
-
color:gray;
|
|
44
|
-
font-size: 18px;
|
|
45
|
-
}
|
|
67
|
+
```html
|
|
68
|
+
<script defer src="https://cdn.jsdelivr.net/npm/aliascss@latest/dist/aliascss.js"></script>
|
|
46
69
|
```
|
|
47
70
|
|
|
48
|
-
|
|
71
|
+
The browser script compiles classes on the page at runtime, including elements added later by JavaScript. It's large and does its work in the browser, so **don't ship it to production**: use the CLI output instead. Keep `defer`, because the script needs `<body>` to exist.
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
Or by using full semantic classnames
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## The rule: one class, one declaration
|
|
55
76
|
|
|
56
77
|
```
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
> Here if you look carefully the classnames is doing dual responsibility. one is defining classnames and second is also defining css declaration for itself. In AliasCSS ecosystem we first use classnames, then the compiler will define classnames and corresponding property and value in the stylesheet/style tag. you don't have to use aliascss compiler in production.
|
|
61
|
-
|
|
62
|
-
### Here are few other examples of post define classnames:-
|
|
63
|
-
|Aliascss classnames|Short-hand |Corresponding style aplied|
|
|
64
|
-
|------------------|-------------|--------------------------:|
|
|
65
|
-
|`display-flex`|`df`|`display:flex`|
|
|
66
|
-
|`list-style-none`|`lsn`|`list-style:none`|
|
|
67
|
-
|`margin-left-20px`|`ml-20px`|`margin-left:20px`|
|
|
68
|
-
|`margin-top--20px`|`mt--20px`|`margin-top:-20px`|
|
|
69
|
-
|`border-1px-solid-ccc`|`b-1px-s-ccc`|`border:1px solid #ccc`|
|
|
70
|
-
|`backgound-color-10p20p30p`|`bgc-10p20p30p`|`background-color:rgb(10%, 20%, 30%)`|
|
|
71
|
-
|`opacity-1`|`o-1`|`opacity:1`|
|
|
72
|
-
|`opacity-0d5`|`o-0d5`|`opacity:0.5`|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```There are two ways to use class name, either using shorhand e.g c-red m-20px df p-20p-30px l-30px OR full semantic class name color-red display-flex padding-20px-30px left-30px```
|
|
77
|
-
|
|
78
|
-
## Selector and Pseudo [ hover: focus: active: ]
|
|
79
|
-
We can also target pseudo selector / element in your class name by using flags(-- ) e.g --hover or --h. For an example:-
|
|
80
|
-
```
|
|
81
|
-
<div class="bgc-cccccc --hover-bgc-yellow> Hi! i will change background color on hover</div>
|
|
82
|
-
```
|
|
83
|
-
Here by using --hover flag ( *can be used --h shorthand flag*) we are telling to use it in :hover state
|
|
84
|
-
|
|
85
|
-
Flags:-
|
|
86
|
-
|
|
87
|
-
| flags |short-flag | corresponding css selector |
|
|
88
|
-
|-------------|---|---------:|
|
|
89
|
-
|--active|--a or --ac|:active|
|
|
90
|
-
|--after|--af|::after|
|
|
91
|
-
|--after-hover|--afh|::after:hover|
|
|
92
|
-
|--autofill|--atf|:-webkit-autofill|
|
|
93
|
-
|--anylink|--al|:-webkit-anylink|
|
|
94
|
-
|--backdrop|--bd|::backdrop|
|
|
95
|
-
|--before|--bf|::before|
|
|
96
|
-
|--before-hover|--bfh|::before:hover|
|
|
97
|
-
|--blank|--bl|:blank|
|
|
98
|
-
|--checked|--ch|:checked|
|
|
99
|
-
|--cue|--cu|::cue|
|
|
100
|
-
|--current|--cur|:current|
|
|
101
|
-
|--default|--de|:default|
|
|
102
|
-
|--disabled|--di|:disabled|
|
|
103
|
-
|--empty|--em|:empty|
|
|
104
|
-
|--enabled|--en|:enabled|
|
|
105
|
-
|--first-child|--fc|:first-child|
|
|
106
|
-
|--first-letter|--fl|::first-letter|
|
|
107
|
-
|--first-line|--fln|::first-line|
|
|
108
|
-
|--first-of-type |--fot|:first-of-type|
|
|
109
|
-
|--focus| --f or --fo|:focus|
|
|
110
|
-
|--focus-within| --fw|:focus-within|
|
|
111
|
-
|--focus-visible| --fv|:focus-visible|
|
|
112
|
-
|--file-selector-button| --fsb |::file-selector-button|
|
|
113
|
-
|--fullscreen| --fs |::fullscreen|
|
|
114
|
-
|--hover|--h or --ho|:hover|
|
|
115
|
-
|--has|--hs|:has|
|
|
116
|
-
|--hover-after|--haf|:hover::after|
|
|
117
|
-
|--hover-before|--hbf|:hover::before|
|
|
118
|
-
|--hover-target|--htg|:hover:target|
|
|
119
|
-
|--in-range|--ir|:in-range|
|
|
120
|
-
|--indeterminate|--ind|:indeterminate|
|
|
121
|
-
|--invalid|--inv|:invalid|
|
|
122
|
-
|--is|--is|:is|
|
|
123
|
-
|--lang|--lan|:lang|
|
|
124
|
-
|--last-child|--lc|:last-child|
|
|
125
|
-
|--last-of-type|--lot|:last-of-type|
|
|
126
|
-
|--link|--ln or -l|:link|
|
|
127
|
-
|--not-|--n-|:not|
|
|
128
|
-
|--nth-child-|--nc-|:nth-child|
|
|
129
|
-
|--nth-last-child-|--nlc-|:nth-last-child|
|
|
130
|
-
|--nth-last-of-type-|--nlot-|:nth-last-of-type|
|
|
131
|
-
|--nth-of-type-|--nthot-|:nth-of-type|
|
|
132
|
-
|--marker|--m|:marker|
|
|
133
|
-
|--only-of-type |--oot|:only-of-type|
|
|
134
|
-
|--only-child|--oc|:only-child|
|
|
135
|
-
|--optional|--op|:optional|
|
|
136
|
-
|--out-of-range|--oor|:out-of-range|
|
|
137
|
-
|--placeholder|--ph|::placeholder|
|
|
138
|
-
|--placeholder-shadow|--phs|::placeholder-shadow|
|
|
139
|
-
|--popover-open|--po|:popover-open|
|
|
140
|
-
|--read-only |--ro|:read-only|
|
|
141
|
-
|--read-write|--rw|:read-write|
|
|
142
|
-
|--required|--rq|:required|
|
|
143
|
-
|--root|--rt|:root|
|
|
144
|
-
|--selection|--s|::selection|
|
|
145
|
-
|--scrollbar|--sb|::-webkit-scrollbar|
|
|
146
|
-
|--webkit-scrollbar|--sb|::-webkit-scrollbar|
|
|
147
|
-
|--scrollbar-track|--st|::-webkit-scrollbar-track|
|
|
148
|
-
|--webkit-scrollbar-track|--st|::-webkit-scrollbar-track|
|
|
149
|
-
|--scrollbar-thumb|--stm|::-webkit-scrollbar-thumb|
|
|
150
|
-
|--webkit-scrollbar-thumb|--stm|::-webkit-scrollbar-thumb|
|
|
151
|
-
|--spelling-error|--se|::spelling-error|
|
|
152
|
-
|--target |--tg|:target|
|
|
153
|
-
|--user-invalid |--ui|:user-invalid|
|
|
154
|
-
|--valid|--va|:valid|
|
|
155
|
-
|--visited|--vi or- -v|:visited|
|
|
156
|
-
|--where|--w|:where|
|
|
157
|
-
|
|
158
|
-
**Examples**
|
|
159
|
-
|
|
160
|
-
| classname |shorthand | css |Remarks|
|
|
161
|
-
|----------- |----------- |----------------------|------------|
|
|
162
|
-
|`--hover-display-flex`|`--h-df`|`:hover{display: flex ;}`|
|
|
163
|
-
|`--focus-list-style-none`|`--fo-lsn`|`:focus{list-style:none;}`|
|
|
164
|
-
|`--nth-child-2n-margin-left-20px`|`--nc-2n-ml-20px`|`:nth-child(2n){margin-left:20px ;}`|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
#### Similarly , we can also tell aliascss classname to use selector by using '_' at the begin-ing class name . eg:-
|
|
168
|
-
```
|
|
169
|
-
<div class="_h3-c-white _p-fs-14px"" >
|
|
170
|
-
<h3>Hello World</h3>
|
|
171
|
-
<p> Welcome to AliasCSS </p>
|
|
172
|
-
</div>\
|
|
173
|
-
```
|
|
174
|
-
AliasCSS will compile above classnames as below:-
|
|
175
|
-
```
|
|
176
|
-
....
|
|
177
|
-
|
|
178
|
-
._h3-c-white h3{
|
|
179
|
-
color:white ;
|
|
180
|
-
}
|
|
181
|
-
._p-fs14px p{
|
|
182
|
-
font-size:14px ;
|
|
183
|
-
}
|
|
78
|
+
[@scope-][selector-]property-value
|
|
184
79
|
```
|
|
185
80
|
|
|
186
|
-
|
|
81
|
+
Read it right to left: the property and value are always last, and everything before them says *when* and *where* the declaration applies.
|
|
187
82
|
|
|
188
|
-
|
|
|
83
|
+
| Class | CSS |
|
|
189
84
|
|---|---|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
85
|
+
| `display-flex` or `d-flex` | `display: flex` |
|
|
86
|
+
| `margin-left-20px` or `ml-20px` | `margin-left: 20px` |
|
|
87
|
+
| `border-1px-solid-ccc` or `b-1px-solid-ccc` | `border: 1px solid #ccc` |
|
|
88
|
+
| `--hover-c-red` | `:hover { color: red }` |
|
|
89
|
+
| `@md-d-grid` | `@media (min-width: 768px) { display: grid }` |
|
|
90
|
+
| `@md--hover-c-red` | both |
|
|
91
|
+
|
|
92
|
+
### Common aliases
|
|
93
|
+
|
|
94
|
+
| Alias | Property | Example |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `d` | display | `d-flex`, `d-none`, `d-inline-flex` |
|
|
97
|
+
| `p`, `m` | padding, margin | `p-16px`, `m-0`, `p-8px-16px` |
|
|
98
|
+
| `w`, `h` | width, height | `w-100%`, `h-40px` |
|
|
99
|
+
| `mw`, `xw`, `xh` | min-width, max-width, max-height | `xw-680px` |
|
|
100
|
+
| `g` | gap | `g-12px` |
|
|
101
|
+
| `aic`, `jcc`, `jcsb` | align-items: center, justify-content: center / space-between | |
|
|
102
|
+
| `c`, `bgc` | color, background-color | `c-red`, `bgc-slateTheme2` |
|
|
103
|
+
| `fs`, `fw`, `lh`, `ff` | font-size, font-weight, line-height, font-family | `fs-14px`, `fw-600`, `lh-1.5` |
|
|
104
|
+
| `b`, `br` | border, border-radius | `b-1px-solid-ccc`, `br-8px` |
|
|
105
|
+
| `t`, `r`, `btm`, `l` | top, right, bottom, left | `t-0` |
|
|
106
|
+
| `o`, `zi` | opacity, z-index | `o-0.5`, `zi-10` |
|
|
107
|
+
| `tf` | transform | `tf-rotate-45deg`, `tf-translateY--2px` |
|
|
108
|
+
| `cont` | `content: ""` | `--before-cont` |
|
|
109
|
+
|
|
110
|
+
Not sure of an alias? Use the full CSS property name; it always works.
|
|
195
111
|
|
|
112
|
+
---
|
|
196
113
|
|
|
197
|
-
##
|
|
114
|
+
## Values
|
|
198
115
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
116
|
+
| Need | Write | CSS |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| Several values | `-` between them | `p-8px-16px` → `padding: 8px 16px` |
|
|
119
|
+
| Negative | `--` before the number | `m--8px` → `margin: -8px` |
|
|
120
|
+
| Decimal | `0.5` (recommended) | `o-0.5`, `lh-1.5`, `m-0.25rem` |
|
|
121
|
+
| Percent | `%` | `w-100%` |
|
|
122
|
+
| Hex colour | with or without `#` | `c-e3e3e3`, `c-#e3e3e3` |
|
|
123
|
+
| Colour with alpha | `/` + decimal | `c-red/0.5` |
|
|
124
|
+
| `!important` | `--important` at the end | `c-red--important` |
|
|
125
|
+
| Anything complex | `property(raw value)` | see below |
|
|
126
|
+
|
|
127
|
+
`.5` also works and compiles to `0.5`, but write `0.5`. The older `d` and `p` notation (`o-0d5`, `w-50p`) still compiles.
|
|
128
|
+
|
|
129
|
+
### Property functions: `property(raw value)`
|
|
130
|
+
|
|
131
|
+
Use this when the value has spaces, commas or functions. Inside the parentheses, `_` is a space:
|
|
206
132
|
|
|
207
133
|
```
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|md|@media (min-width : 768px) |
|
|
215
|
-
|lg|@media (min-width : 992px) |
|
|
216
|
-
|xl|@media (min-width : 1200px)|
|
|
217
|
-
|xxl|@media (min-width : 1408px) |
|
|
218
|
-
|-xs| @media (min-width : 576px) |
|
|
219
|
-
|-sm|@media (max-width : 576px) |
|
|
220
|
-
|-md|@media (max-width : 768px) |
|
|
221
|
-
|-lg|@media (max-width : 992px) |
|
|
222
|
-
|-xl|@media (max-width : 1200px)|
|
|
223
|
-
|-xxl|@media (max-width : 1408px) |
|
|
224
|
-
|
|
225
|
-
>Any of the above prefix can be used, these prefix must be the at the begin-ing of the classnames.
|
|
226
|
-
Few examples:-
|
|
227
|
-
|
|
228
|
-
**Define**
|
|
229
|
-
```
|
|
230
|
-
<div class="xs-flex-direction-column">...</div>
|
|
231
|
-
//using shorthand <div class="xs-fdc">...</div>
|
|
134
|
+
padding(8px_16px) → padding: 8px 16px
|
|
135
|
+
gtc(repeat(3,1fr)) → grid-template-columns: repeat(3, 1fr)
|
|
136
|
+
box-shadow(0_1px_3px_rgb(0_0_0_/_0.1)) → box-shadow: 0 1px 3px rgb(0 0 0 / 0.1)
|
|
137
|
+
w(calc(100%_-_32px)) → width: calc(100% - 32px)
|
|
138
|
+
ff(Times_New_Roman,Times,serif) → font-family: "Times New Roman", Times, serif
|
|
139
|
+
background(linear-gradient(45deg,red,blue))
|
|
232
140
|
```
|
|
233
141
|
|
|
142
|
+
In `calc()`, `+` and `-` need spaces around them: `calc(100%_-_32px)`.
|
|
143
|
+
|
|
144
|
+
For properties that take several layers (shadows, transforms, transitions, filters), `__` separates the layers: `tf-scale-2__rotate-25deg` → `transform: scale(2) rotate(25deg)`.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## States and pseudo-elements
|
|
149
|
+
|
|
150
|
+
Start the class with `--` and the state or pseudo-element:
|
|
234
151
|
|
|
235
|
-
**Compiled**
|
|
236
152
|
```
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
153
|
+
--hover-c-red :hover
|
|
154
|
+
--focus-visible-… :focus-visible
|
|
155
|
+
--active-… --disabled-… --checked-… --placeholder-…
|
|
156
|
+
--before-cont ::before { content: "" }
|
|
157
|
+
--first-child-… --last-child-… --popover-open-…
|
|
158
|
+
--nth-child(2n+1)-… :nth-child(2n+1)
|
|
159
|
+
--not(--first-child)-… :not(:first-child)
|
|
160
|
+
--has(--checked)-… :has(:checked)
|
|
161
|
+
--hover--before-c-red :hover::before (state first, then pseudo-element)
|
|
242
162
|
```
|
|
163
|
+
|
|
164
|
+
Short forms exist for most of them (`--h-` for `:hover`, `--fv-` for `:focus-visible`, and so on).
|
|
165
|
+
|
|
243
166
|
---
|
|
244
|
-
|
|
167
|
+
|
|
168
|
+
## Attributes and other elements
|
|
169
|
+
|
|
170
|
+
### Attribute states
|
|
171
|
+
|
|
245
172
|
```
|
|
246
|
-
|
|
247
|
-
|
|
173
|
+
[aria-expanded=true]-c-red .x[aria-expanded="true"] { color: red }
|
|
174
|
+
[aria-current=page][c-red,fw-600] attribute + several declarations
|
|
175
|
+
[data-open]-d-block attribute present
|
|
248
176
|
```
|
|
249
177
|
|
|
250
|
-
|
|
178
|
+
Never put quotes in a class name: write `[data-state=open]`, not `[data-state='open']`.
|
|
179
|
+
|
|
180
|
+
### A parent's state: `&`
|
|
181
|
+
|
|
182
|
+
Everything before `&` becomes an ancestor selector. This is the main tool for component state: put one `data-*` or `aria-*` attribute on the root, and let every child react to it.
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<div data-open class="…">
|
|
186
|
+
<div class="o-0 [data-open]&o-1">…</div> <!-- [data-open] .x { opacity: 1 } -->
|
|
187
|
+
</div>
|
|
251
188
|
```
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
189
|
+
|
|
190
|
+
### Other elements
|
|
191
|
+
|
|
192
|
+
| Class | Selector |
|
|
193
|
+
|---|---|
|
|
194
|
+
| `_li-c-red` | descendant `li` |
|
|
195
|
+
| `__li-c-red` | child `> li` |
|
|
196
|
+
| `___p-c-red` | next sibling `+ p` |
|
|
197
|
+
| `____p-c-red` | later siblings `~ p` |
|
|
198
|
+
| `_all-m-0` | all descendants `*` |
|
|
199
|
+
| `_.(card-title)-c-red` | descendant `.card-title` (class names with `-` go in parentheses) |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Responsive and other scopes
|
|
204
|
+
|
|
205
|
+
Scopes start with `@`:
|
|
206
|
+
|
|
207
|
+
| Scope | Media / rule |
|
|
208
|
+
|---|---|
|
|
209
|
+
| `@xs-` | max-width: 575.99px |
|
|
210
|
+
| `@sm-` | min-width: 576px |
|
|
211
|
+
| `@md-` | min-width: 768px |
|
|
212
|
+
| `@lg-` | min-width: 992px |
|
|
213
|
+
| `@xl-` | min-width: 1200px |
|
|
214
|
+
| `@xxl-` | min-width: 1408px |
|
|
215
|
+
| `@hover-capable-` | `(hover: hover)` |
|
|
216
|
+
| `@motion-reduce-` | `prefers-reduced-motion: reduce` |
|
|
217
|
+
| `@container-xs-` … `@container-xxl-` | container queries |
|
|
218
|
+
| `@starting-style-` | `@starting-style` (entry animations) |
|
|
219
|
+
| `@reset-` `@base-` `@theme-` `@components-` `@utils-` | cascade layers |
|
|
220
|
+
|
|
221
|
+
**Two rules to remember:**
|
|
222
|
+
|
|
223
|
+
1. **A class without a scope beats a scoped class**, because breakpoints live in cascade layers. Don't mix `p-32px @md-p-16px`. Give every size a prefix: `@xs-p-16px @sm-p-24px @md-p-32px`.
|
|
224
|
+
2. **`@xs` is max-width; the others are min-width.** If you use `@xs`, also set `@sm`, or screens from 576px to 767px get nothing.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Groups and exports
|
|
229
|
+
|
|
230
|
+
### Groups `[…]`
|
|
231
|
+
|
|
232
|
+
Apply one prefix to several declarations:
|
|
233
|
+
|
|
257
234
|
```
|
|
258
|
-
|
|
235
|
+
@md[d-flex,g-16px,p-24px]
|
|
236
|
+
--hover[c-red,bgc-blue]
|
|
237
|
+
--before[cont,position-absolute,inset-0]
|
|
259
238
|
```
|
|
260
|
-
|
|
261
|
-
|
|
239
|
+
|
|
240
|
+
### Exports `--as-name`
|
|
241
|
+
|
|
242
|
+
Define a class once and reuse it by name. This keeps long class lists out of repeated markup:
|
|
243
|
+
|
|
244
|
+
```html
|
|
245
|
+
<div hidden class="[d-flex,aic,g-8px,p-8px-16px,br-8px,c-slateTheme11,--hover-bgc-slateTheme3,[aria-current=page]-fw-600]--as-nav-item"></div>
|
|
246
|
+
|
|
247
|
+
<a href="/" class="nav-item" aria-current="page">Home</a>
|
|
248
|
+
<a href="/billing" class="nav-item">Billing</a>
|
|
262
249
|
```
|
|
263
250
|
|
|
264
|
-
|
|
251
|
+
Groups and exports take plain property-value classes only. `x-` components and `@scope-` classes go on the element itself.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## CSS variables
|
|
256
|
+
|
|
265
257
|
```
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
258
|
+
--x-gap:16px defines --x-gap: 16px
|
|
259
|
+
g--x-gap uses gap: var(--x-gap)
|
|
260
|
+
g--x-gap:16px uses gap: var(--x-gap, 16px)
|
|
261
|
+
w-var(--x-w) uses width: var(--x-w)
|
|
262
|
+
w(var(--x-w)) uses width: var(--x-w)
|
|
271
263
|
```
|
|
272
264
|
|
|
265
|
+
Start your own variables with `--x-`. Short selector aliases claim other prefixes (`--h-` is `:hover`, `--s-` is `::selection`, `--sb-` is the scrollbar), so `--sb-bg:red` won't do what you expect. Variables whose names end in `-color` or `-bg` compile colour tokens: `--x-ring-color:accentRA1000`.
|
|
273
266
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Colours and themes
|
|
270
|
+
|
|
271
|
+
Put `x-theme` on `<html>`, then use the theme tokens. They switch between light and dark automatically:
|
|
272
|
+
|
|
273
|
+
```html
|
|
274
|
+
<html class="x-theme">
|
|
275
|
+
<div class="bgc-slateTheme2 c-slateTheme12 b-1px-solid-slateTheme6">…</div>
|
|
276
|
+
<button class="bgc-accentRA1000 c-white">Save</button>
|
|
277
|
+
<span class="bgc-accentRATheme100 c-accentRATheme1100">Soft badge</span>
|
|
278
|
+
</html>
|
|
284
279
|
```
|
|
285
|
-
|
|
286
|
-
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|`margin--0d75rem`|`m--0d75rem`|`margin:-0.75rem`|
|
|
292
|
-
|`width-50p`|` w-50p`|`width:50%`|
|
|
293
|
-
|`opacity-0d5`|`o-0d5`|`opacity:0.5`|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
## Length [property whose value are in length ]
|
|
298
|
-
`Syntax:- property[-]?[value]`
|
|
299
|
-
|
|
300
|
-
| classname |shorthand | css |Remarks|
|
|
301
|
-
|----------- |----------- |----------------------|------------|
|
|
302
|
-
|`margin-100px`|`m-100px` | `margin:100px` | |
|
|
303
|
-
|`margin-1em` |`m-1em` |`margin:1em`|
|
|
304
|
-
|`margin-50p` |`m-50p` |`margin:50%` | Use 'p' for %|
|
|
305
|
-
|`margin-0d5rem`|`m-0d5rem` |`margin:0.5rem` | use 'd' for .|
|
|
306
|
-
|`margin-20px-30px-20px-40px`|`m-20px-30px-20px-40px`|` margin:20px 30px 20px 40px`|
|
|
307
|
-
|`margin--20px-30px--20px-40px`|`m--20px-30px--20px-40px`| `margin:-20px 30px -20px 40px`|
|
|
308
|
-
|`margin-left150px`|`ml150px`|`margin-left:150px`|
|
|
309
|
-
|`border-radius-15px`|`br-15px`|`border-radius:15px`|
|
|
310
|
-
|`max-width-500px`|`xw-500px`|`max-width:500px`|
|
|
311
|
-
|`min-width-300px`|`mw-300p`|`min-width:300px`|
|
|
280
|
+
|
|
281
|
+
- **Neutral and colour scales:** `slateTheme1`–`12`, plus `red`, `green`, `amber`, `blue`, `violet`, `mauve`… `Theme1`–`12`, and alpha versions (`violetThemeA4`, `blackA6`). These follow the Radix Colors steps: 1–2 backgrounds, 3–5 component states, 6–8 borders, 9–10 solid fills, 11–12 text.
|
|
282
|
+
- **Accent scale:** `accentRA100`–`1600` (fixed) and `accentRATheme100`–`1600` (light/dark), all derived from one colour.
|
|
283
|
+
- **Rebrand:** `<html class="x-theme --accentColor:0d74ce">`.
|
|
284
|
+
- **Force one part of the page:** `x-theme-dark` / `x-theme-light`.
|
|
285
|
+
|
|
312
286
|
---
|
|
313
|
-
## Color
|
|
314
|
-
### Color by name and Hexadecimal value
|
|
315
|
-
`Syntax:- [color|c] - [name| hexadecimal value without #]`
|
|
316
287
|
|
|
317
|
-
|
|
318
|
-
|---------|---------|---|-------|
|
|
319
|
-
|`color-red`|`c-red`|`color:red`|
|
|
320
|
-
|`color-cccccc`|`c-cccccc`|`color:#cccccc`|
|
|
321
|
-
|`color-fff`|c-fff`|`color:#fff`|
|
|
322
|
-
|`border-color-yellow`|`bc-yellow`|`border-color:yellow`|
|
|
323
|
-
|`background-color-red`|`bgc-red`|`background-color:red`|
|
|
288
|
+
## Keyframes
|
|
324
289
|
|
|
325
|
-
|
|
326
|
-
|
|
290
|
+
Declare keyframes on any element with a `keyframes-name` attribute:
|
|
291
|
+
|
|
292
|
+
```html
|
|
293
|
+
<i class="d-none" keyframes-pop-in="@0-[o-0,tf-scale-0.9] @100-[o-1,tf-none]"></i>
|
|
294
|
+
<i class="d-none" keyframes-shake="@[0,100][tf-none] @[20,60][tf-translateX--6px] @[40,80][tf-translateX-6px]"></i>
|
|
327
295
|
|
|
328
|
-
|
|
296
|
+
<div class="animation(pop-in_.3s_ease-out_both) @motion-reduce-animation-none">Hi</div>
|
|
297
|
+
```
|
|
329
298
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
299
|
+
- One stop: `@0-[…]` or `@0[…]`. Several stops with the same style: `@[0,25,50][…]`.
|
|
300
|
+
- Use lower-case kebab-case names. HTML lower-cases attribute names, so `keyframes-fadeIn` becomes `fadein`.
|
|
301
|
+
- Give the element a class (`class="d-none"`) so the browser script picks it up.
|
|
333
302
|
|
|
303
|
+
---
|
|
334
304
|
|
|
305
|
+
## x- components
|
|
335
306
|
|
|
336
|
-
|
|
337
|
-
|---------|---------|---|-------|
|
|
338
|
-
|`color-000000000`|`c-000000000`|`color:rgb(000,000,000)`|
|
|
339
|
-
|`color-024245100`|`c-024245100`|`color:rgb(024,245,100)`|
|
|
340
|
-
|`color-1110230450d5`|`c-1110230450d5`|`color:rgba(111,023,045,0.4)`|
|
|
341
|
-
|`border-color-11122200050p`|`bc-11122200050p`|`border-color:rgba(111,222,000,50%)`|
|
|
342
|
-
|`background-color-30p40p60p`|`bgc-30p40p60p`|`background-color:rgb(30%,40%,60%)`|
|
|
307
|
+
An optional starter library, built with AliasCSS itself. Every component uses theme tokens, can be customised with `--x-*` variables, and sits in the `@components` layer, so any utility overrides it.
|
|
343
308
|
|
|
344
|
-
|
|
345
|
-
`
|
|
346
|
-
|
|
309
|
+
- **Forms:** `x-button` (+ `-secondary -ghost -danger -sm -lg -icon`), `x-input`, `x-textarea`, `x-select`, `x-checkbox`, `x-radio`, `x-switch`, `x-range`, `x-file`, `x-field`, `x-label`
|
|
310
|
+
- **Surfaces:** `x-card`, `x-badge`, `x-alert`, `x-table`
|
|
311
|
+
- **Overlays:** `x-dialog` (native `<dialog>`), `x-dropdown` (native `popover`), `x-accordion` (`<details>`)
|
|
312
|
+
- **Navigation:** `x-tab-list`, `x-tab`, `x-breadcrumb`, `x-pagination`, `x-menu`
|
|
313
|
+
- **Feedback:** `x-spinner`, `x-skeleton`, `x-avatar`
|
|
314
|
+
- **Layout:** `x-stack`, `x-cluster`, `x-center`, `x-grid`, `x-sidebar`, `x-cover`, `x-row` + `x-col-1`…`12`
|
|
315
|
+
- **Content:** `x-prose`, `x-kbd`, `x-code`, `x-divider`
|
|
347
316
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
317
|
+
```html
|
|
318
|
+
<button class="x-button --x-button-bg:pinkTheme9">Launch</button>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
The `x-` library is an example of a design system built with AliasCSS. You can define your own with `extend` in the config.
|
|
353
322
|
|
|
354
323
|
---
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|`box-shadow--2px--2px-cccccc`|`bxs--2px--2px-cccccc`|`box-shadow:-2px -2px #cccccc`|
|
|
380
|
-
|`box-shadow-0px-2px-0px-000000000__2px-5px-1px-red`|`bxs-0px-2px-0px-000000000__2px-5px-1px-red`|`box-shadow:0px 2px 0px rgb(000,000,000),2px 5px 1px red`|Multiple value for Box-shadow|
|
|
324
|
+
|
|
325
|
+
## React, Vue and other frameworks
|
|
326
|
+
|
|
327
|
+
The CLI reads your source files as text and finds classes in two places:
|
|
328
|
+
|
|
329
|
+
1. `class="…"` and `className="…"` string literals
|
|
330
|
+
2. calls to the extractor function, `String('…')` by default
|
|
331
|
+
|
|
332
|
+
Wrap any class that lives in a variable, object, ternary or template literal, and never build class names at runtime:
|
|
333
|
+
|
|
334
|
+
```tsx
|
|
335
|
+
const TONE = {
|
|
336
|
+
paid: String('bgc-greenTheme3 c-greenTheme11'),
|
|
337
|
+
due: String('bgc-redTheme3 c-redTheme11'),
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
<span className={TONE[status]}>…</span>
|
|
341
|
+
<li className={String('d-flex g-8px ') + (active ? String('bgc-accentRATheme100') : '')} />
|
|
342
|
+
|
|
343
|
+
// never: 'bgc-' + color or `p-${n}px`
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
For component state, set a `data-*` or `aria-*` attribute and style it with `[data-open]&…` or `[aria-pressed=true]-…`, which keeps the class names static.
|
|
347
|
+
|
|
381
348
|
---
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
## Transform
|
|
392
|
-
|classname|shorthand|css|Remarks|
|
|
393
|
-
|---------|---------|---|-------|
|
|
394
|
-
|`transform-rotate-45deg`|`tf-r-45deg`|`transform:rotate(45deg)`|
|
|
395
|
-
|`transform-scale-2__rotate-25deg`|`tf-s2__r-25deg`|`transform:scale(2) rotate(25deg)`| Multiple value|
|
|
396
|
-
|`transform-rotate--45deg`|`tf-r--45deg`|`transform:rotate(-45deg)`|
|
|
397
|
-
|`transform-rotate3d-1--1-1-45deg`|`tf-r3d-1--1-1-45deg`|`transform:rotate3d(1, -1, 1, 45deg)`|
|
|
398
|
-
|`transform-matrix-0d8-0d7--0d8-0.866-0-0`|`tf-m-0d8-0d7--0d8-0.866-0-0`|`transform:matrix(0.8, 0.7, -0.8, 0.866, 0, 0)`||
|
|
399
|
-
|`transform-rotateX-45deg`|`tf-rx-45deg`|`transform:rotateX(45deg)`|
|
|
400
|
-
|`transform-rotate-45deg`|`tf-r-45deg`|`transform:rotate(45deg)`|
|
|
401
|
-
|`transform:-scaleX-2`|`tf-sx-2`|`transform:scaleX(2)`|
|
|
402
|
-
|`transform-skew-45deg--45deg`|`tf-sk-45deg--45deg`|`transform:skew(45deg, -45deg)`|
|
|
403
|
-
|`transform-translate-20px-10px`|`tf-t-20px-10px`|`transform:translate(20px, 10px)`|
|
|
404
|
-
|`transform-rotate-45deg`|`tf-r-45deg`|`transform:rotate(45deg)`|
|
|
405
|
-
|`transform-rotate-45deg`|`tf-r-45deg`|`transform:rotate(45deg)`|
|
|
406
|
-
|
|
407
|
-
## Transition
|
|
408
|
-
|
|
409
|
-
|classname|shorthand|css|Remarks|
|
|
410
|
-
|---------|---------|---|-------|
|
|
411
|
-
|`transition-all-0d5s`|`tn-all-0d5s` |`transition:all 0.5s`|
|
|
412
|
-
|`transition-width-0d35s`|`tn-width-0d35s` |`transition:width 0.5s`|
|
|
413
|
-
|`transition-width-0d35s`|`tn-width-0d35s` |`transition:width 0.5s`|
|
|
414
|
-
|`transition-transform-0d35s`|`tn-transform-0d35s`|`transition:transform 0.35s`|
|
|
415
|
-
|
|
416
|
-
## Filter
|
|
417
|
-
|
|
418
|
-
|classname|shorthand|css|Remarks|
|
|
419
|
-
|---------|---------|---|-------|
|
|
420
|
-
|`filter-blur-4px`|`fl-b-4px`|`filter:blur(4px)`||
|
|
421
|
-
|`filter-unset`|`flu`|`fliter:unset`||
|
|
422
|
-
|`filter-brightness-50p__blur-4px__invert-50p`|`fl-br-50p__b-4px__i-50p`|`filter:brightness( 50% ) blur( 4px ) invert( 50% )` |
|
|
423
|
-
|`filter-drop-shadow8px8px10px-gray`|`fl-ds8px8px10px-gray`|`filter:drop-shadow( 8px 8px 10px gray )`||
|
|
424
|
-
|`filter-hue-rotate-40deg`|`fl-hr-40deg`|`filter:hue-rotate( 40deg )`||
|
|
425
|
-
|
|
426
|
-
## Gradient
|
|
427
|
-
|classname|shorthand|css|Remarks|
|
|
428
|
-
|---------|---------|---|-------|
|
|
429
|
-
|`background-linear-gradient-red-blue`|`bg-lg-red-blue `|`background:linear-gradient( red, blue ) `||
|
|
430
|
-
|`background-linear-gradient-red-10p-blue-90p`|`bg-lg-red-10p-blue-20p `|`background:linear-gradient( red 10%, blue 90% )`||
|
|
431
|
-
|`background-repeating-linear-gradient-red-10p-blue-90p`|`bg-rlg-red-10p-blue-20p `|`background:repeating-linear-gradient( red 10%, blue 90% )`||
|
|
432
|
-
|`background-linear-gradient-to-right-red-10p-blue-90p`|`bg-lg-tr-red-10p-blue-90p `|`background:linear-gradient(to right, red 10%, blue 90% )`||
|
|
433
|
-
|`background-linear-gradient45deg-red-10p-blue-90p`|`bg-lg45deg-red-10p-blue-90p `|`background:linear-gradient(45deg, red 10%, blue 90% )`||
|
|
434
|
-
|`background-radial-gradient-red-10p-blue-90p`|`bg-rg-red-10p-blue-90p `|`background:radial-gradient( red 10%, blue 90% )`||
|
|
435
|
-
|`background-repeating-radial-gradient-circle-blue-5p-skyblue-23p `|`bg-rrg-circle-blue-5p-skyblue-23p `|`background:repeating-radial-gradient( circle, blue 5%, skyblue 23% )`||
|
|
436
|
-
|`background-conic-gradient-red-blue`|`bg-cg-red-blue `|`background:conic-gradient( red, blue ) `||
|
|
437
|
-
|`background-linear-gradient-top-right-red-10p-blue-90p__radial-gradient-center-yellow-blue`|`bg-lg-tr-red-10p-blue-90p__rg-center-yellow-blue `|`background:linear-gradient(top right, red 10%, blue 90% ),radial-gradient( center, yellow, blue )`|multiple|
|
|
438
|
-
|
|
439
|
-
## CSS Variable
|
|
440
|
-
|classname|shorthand|css|Remarks|
|
|
441
|
-
|---------|---------|---|-------|
|
|
442
|
-
|`color--var--name`|`c--var--name`|`color: var(--name)`|
|
|
443
|
-
|`color--name`|`c--name`|`color: var(--name)`|
|
|
444
|
-
|`width--side-bar-width`|`w--side-bar-width`| `width: var(--side-bar-width)`||
|
|
445
|
-
|`--side-bar-width:200px`|`--side-bar-width:200px`| `--side-bar-width:200px`|`Defining css variables`|
|
|
446
|
-
|`width--side-bar-width:400px`|`w--side-bar-width:400px`| `width: var(--side-bar-width,400px)`| `with default value`|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
# NPM Guide
|
|
450
|
-
|
|
451
|
-
With `npm` version there are lots of exrta front-end / workflow feature we can use out of the box.
|
|
452
|
-
|
|
453
|
-
`npm install --save-dev aliascss`
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
To Compiler folder from command line
|
|
457
|
-
|
|
458
|
-
`npx aliascss 'public/*.html' 'public/css/acss.css'`
|
|
459
|
-
|
|
460
|
-
> output css file must be there if not it should be created manully.
|
|
461
|
-
|
|
462
|
-
>Guide-`npx aliascss 'input/glob-pattern/**.*' 'path/to/output/style.css'`
|
|
463
|
-
|
|
464
|
-
### Watch for files
|
|
465
|
-
|
|
466
|
-
`npx aliascss 'public/*.html' 'public/css/acss.ccc' --watch`
|
|
467
|
-
|
|
468
|
-
@package.json
|
|
349
|
+
|
|
350
|
+
## CLI and aliascss.config.js
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
npx aliascss --config # build from aliascss.config.js
|
|
354
|
+
npx aliascss --config --watch # rebuild on change
|
|
355
|
+
npx aliascss --help
|
|
469
356
|
```
|
|
470
|
-
....
|
|
471
|
-
"scripts": {
|
|
472
|
-
...
|
|
473
|
-
"aliascss-build": "aliascss 'public/*.html' 'public/css/aliascss.css'",
|
|
474
|
-
"aliascss-watch": "aliascss-build --watch"
|
|
475
|
-
}
|
|
476
|
-
...
|
|
477
|
-
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
## aliascss.config.js
|
|
481
|
-
`aliascss.config.js` gives you more feature and power to the workflow.
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
Basic structure of aliascss.config.js file
|
|
485
|
-
|
|
486
|
-
```javascript copy showLineNumbers filename="aliascss.config.js"
|
|
487
|
-
const config= {
|
|
488
|
-
// input glob pattern or array of glob pattern
|
|
489
|
-
input:['app/**/*.(tsx|jsx)', 'components/**/*.(tsx|jsx)','public/*.html'],
|
|
490
|
-
|
|
491
|
-
// Output css file , file must exist or should be created manully if file doesnot exist
|
|
492
|
-
output:{
|
|
493
|
-
// path to main/master css file which include every compiled css declaration for given input
|
|
494
|
-
location:'./public/css/acss.css',
|
|
495
|
-
"--file":true// output css file for each file
|
|
496
|
-
},
|
|
497
357
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
358
|
+
`package.json`:
|
|
359
|
+
|
|
360
|
+
```json
|
|
361
|
+
"scripts": {
|
|
362
|
+
"aliascss-build": "aliascss --config",
|
|
363
|
+
"aliascss-watch": "aliascss --config --watch"
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
`aliascss.config.js`: everything except `input` and `output` is optional.
|
|
368
|
+
|
|
369
|
+
```js
|
|
370
|
+
const config = {
|
|
371
|
+
// glob pattern, or an array of them
|
|
372
|
+
input: ['app/**/*.{tsx,jsx}', 'components/**/*.{tsx,jsx}', 'public/*.html'],
|
|
373
|
+
|
|
374
|
+
output: {
|
|
375
|
+
location: './public/css/acss.css', // one CSS file with everything
|
|
376
|
+
'--file': true, // also one CSS file per input file
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
// name of the wrapper the CLI scans in JS/TS (default: String)
|
|
380
|
+
extractorFunction: 'String',
|
|
381
|
+
|
|
382
|
+
// minify the main CSS file with cssnano
|
|
383
|
+
// minify: true,
|
|
384
|
+
|
|
385
|
+
// prefix every class: ac-bgc-red, ac--hover-c-red
|
|
386
|
+
// prefix: 'ac',
|
|
387
|
+
|
|
388
|
+
// CSS module support
|
|
389
|
+
'--module': true,
|
|
390
|
+
importModuleAs: 'x', // import x from 'page.module.css'
|
|
391
|
+
|
|
392
|
+
// rewrite the output file on each build (leave this on unless you know why not)
|
|
393
|
+
truncate: true,
|
|
394
|
+
|
|
395
|
+
// change a media prefix
|
|
396
|
+
media: {
|
|
397
|
+
prefix: { xs: '@media (max-width: 600px)' },
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
// custom colour names (no "-" or "_" in the name): bgc-main, c-brand
|
|
401
|
+
custom: {
|
|
402
|
+
colors: {
|
|
403
|
+
main: 'rgb(12,23,45)',
|
|
404
|
+
brand: '#c6c6c6',
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
// your own properties and components
|
|
409
|
+
extend: {
|
|
410
|
+
'txt-color': { property: 'color', extend: 'color' }, // txt-color-red
|
|
411
|
+
shadow: { // shadow-sm, shadow-lg
|
|
412
|
+
property: 'box-shadow',
|
|
413
|
+
compiler: (value) => ({
|
|
414
|
+
sm: '0 1px 3px var(--x-shadow-color)',
|
|
415
|
+
md: '0 4px 8px -2px var(--x-shadow-color)',
|
|
416
|
+
lg: '0 12px 16px -4px var(--x-shadow-color)',
|
|
417
|
+
})[value.slice(1)],
|
|
504
418
|
},
|
|
505
|
-
//
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
// uncomment minify is true if you want main css file to be minified by cssnano
|
|
512
|
-
|
|
513
|
-
// minify:true,
|
|
514
|
-
|
|
515
|
-
// name of extractorFunction
|
|
516
|
-
extractorFunction:"x",
|
|
517
|
-
|
|
518
|
-
// prefix aliascss ac-bgc-red ac--hover-color-red
|
|
519
|
-
// prefix:'ac',
|
|
520
|
-
|
|
521
|
-
//Truncate the css file , you should let it true unless you know what your are doing
|
|
522
|
-
truncate:true,
|
|
523
|
-
|
|
524
|
-
//ADD Custom color Value
|
|
525
|
-
custom:{
|
|
526
|
-
colors:{
|
|
527
|
-
//custom name for color value must not have "-" or "_" to work perfectly.
|
|
528
|
-
'main':"rgb(12,23,45)",// now you can use bgc-main
|
|
529
|
-
'theme':'#c6c6c6'
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
},
|
|
534
|
-
// Create your own compiler
|
|
535
|
-
extend:{
|
|
536
|
-
'font-size':{
|
|
537
|
-
alias:'fs',
|
|
538
|
-
values:["2rem:xl"],
|
|
539
|
-
compiler:(value)=>{
|
|
540
|
-
return value;
|
|
541
|
-
}
|
|
542
|
-
},
|
|
543
|
-
'txt-color':{
|
|
544
|
-
proerty:'color',
|
|
545
|
-
extend:'color' // now you can use txt-color in place color
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
// Now you can use shadow as className property e.g shadow-xs
|
|
549
|
-
'shadow':{
|
|
550
|
-
property:'box-shadow',
|
|
551
|
-
compiler:(value)=>{
|
|
552
|
-
value=value.slice(1);
|
|
553
|
-
const values={
|
|
554
|
-
'3xl': ' 0px 32px 64px -12px var(--shadow-color)',
|
|
555
|
-
'xxxl': ' 0px 32px 64px -12px var(--shadow-color)',
|
|
556
|
-
'2xl': ' 0px 24px 48px -12px var(--shadow-color)',
|
|
557
|
-
'xxl': ' 0px 24px 48px -12px var(--shadow-color)',
|
|
558
|
-
'xl': ' 0px 20px 24px -4px var(--shadow-color)',
|
|
559
|
-
'lg': ' 0px 12px 16px -4px var(--shadow-color)',
|
|
560
|
-
'md': ' 0px 4px 8px -2px var(--shadow-color)',
|
|
561
|
-
'sm': ' 0px 1px 3px var(--shadow-color)',
|
|
562
|
-
'xs': ' 0px 1px 2px var(--shadow-color)',
|
|
563
|
-
};
|
|
564
|
-
if(values.hasOwnProperty(value)) return values[value];
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
}
|
|
419
|
+
'ui-btn': { // a component made of AliasCSS classes
|
|
420
|
+
type: 'statement',
|
|
421
|
+
statement: `
|
|
422
|
+
@components[d-inline-flex,aic,g-8px,p-8px-16px,br-8px,bgc-accentRA1000,c-white]
|
|
423
|
+
@components--hover-bgc-accentRA1100
|
|
424
|
+
`,
|
|
568
425
|
},
|
|
569
|
-
|
|
570
|
-
prebuild:{
|
|
426
|
+
},
|
|
571
427
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
428
|
+
// fixed class names
|
|
429
|
+
prebuild: {
|
|
430
|
+
'text-sm': 'font-size:14px;line-height:20px',
|
|
431
|
+
'flex-center': 'display:flex;align-items:center;justify-content:center',
|
|
432
|
+
},
|
|
577
433
|
|
|
578
|
-
|
|
434
|
+
// plain CSS added to every compiled file
|
|
435
|
+
statement: `
|
|
436
|
+
body { font-family: system-ui, sans-serif; }
|
|
437
|
+
`,
|
|
438
|
+
|
|
439
|
+
// one class name for a set of AliasCSS classes
|
|
440
|
+
group: {
|
|
441
|
+
container: 'd-flex flex-direction-column aic',
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
// class names to leave alone (for example, ones another framework owns)
|
|
445
|
+
ignore: ['fs12px', 'c-red'],
|
|
446
|
+
};
|
|
579
447
|
|
|
580
|
-
'flex-center':'display:flex;align-items:center;justify-content:center',
|
|
581
|
-
},
|
|
582
|
-
//Add some css statement in every compiled css file
|
|
583
|
-
statement:`
|
|
584
|
-
:root{
|
|
585
|
-
--bg-dark-color:rgba(111,111,111,1) ;
|
|
586
|
-
--bg-light-color:rgba(21,21,21,1) ;
|
|
587
|
-
--outline-color:blue;
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
body{
|
|
592
|
-
font-family:BlinkMacSystemFont , -apple-system , "Segoe UI" ;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
`,
|
|
596
|
-
|
|
597
|
-
// pre group valid Aliascss classNames in single className
|
|
598
|
-
group:{
|
|
599
|
-
'container':' df fdc bsbb aic flex-shrink-1 flex-grow-1 ',
|
|
600
|
-
'section':'flex-shrink0 bsbb'
|
|
601
|
-
},
|
|
602
|
-
// if some of the className collide with other CSS framework like bootstrap and tailwindcss
|
|
603
|
-
// You wanna tell aliascss to ignore it...
|
|
604
|
-
ignore:['fs12px', 'c-red'],// these classnames will be ignored
|
|
605
|
-
}
|
|
606
448
|
export default config;
|
|
607
449
|
```
|
|
608
450
|
|
|
609
|
-
|
|
451
|
+
---
|
|
610
452
|
|
|
611
|
-
|
|
453
|
+
## Using AliasCSS with AI coding agents
|
|
612
454
|
|
|
613
|
-
|
|
455
|
+
- **[aliascss.com/llms.txt](https://aliascss.com/llms.txt):** the whole language on one page, written for language models.
|
|
456
|
+
- **AliasCSS AI kit:** a skill folder plus `AGENTS.md`, `CLAUDE.md`, Cursor and Copilot instructions. Copy it into your project, and Claude Code, Codex, Cursor, Copilot and Gemini CLI will write correct AliasCSS.
|
|
614
457
|
|
|
615
|
-
|
|
458
|
+
---
|
|
616
459
|
|
|
617
|
-
|
|
460
|
+
## Upgrading from older versions
|
|
618
461
|
|
|
619
|
-
|
|
462
|
+
| Old | Now | Why |
|
|
463
|
+
|---|---|---|
|
|
464
|
+
| `xs-dn`, `md-w-500px` | `@xs-d-none`, `@md-w-500px` | Breakpoints need `@`. Without it, the class compiles **with no media query** and applies at every width. |
|
|
465
|
+
| `ff-Times_New_Roman--Times--serif` | `ff(Times_New_Roman,Times,serif)` | Use the function form for font lists. |
|
|
466
|
+
| `o-0d5`, `w-50p` | `o-0.5`, `w-50%` | Both still work; `.` and `%` are easier to read. |
|
|
467
|
+
| `c--var--name` | `c--x-name` | Both work; use `--x-` names for your own variables. |
|
|
620
468
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
"aliascss-watch": "aliascss --config --watch"
|
|
625
|
-
}
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## Changelog
|
|
626
472
|
|
|
627
|
-
|
|
628
|
-
```
|
|
473
|
+
### 1.5.3
|
|
629
474
|
|
|
630
|
-
|
|
475
|
+
- **Fixed:** in the browser script, a page with a `keyframes-…` element threw "Cannot read properties of undefined (reading 'has')" and stopped styling every element after it (regression in 1.5.2).
|
|
476
|
+
- **Fixed:** decimals with a leading dot (`o-.5`, `m-.5rem`, `scale-.98`, `--x-o:.5`) compile to `0.5` instead of a negative value or an empty rule. `0.5` remains the recommended form.
|
|
477
|
+
- **Fixed:** `w-var(--x-w)` and other `-var(…)` values compile, fallbacks included.
|
|
478
|
+
- **Added:** `display-webkit-box` / `d-webkit-box`.
|
|
631
479
|
|
|
480
|
+
### 1.5.2
|
|
632
481
|
|
|
482
|
+
- **Fixed:** `grid-column` and `grid-row` keep a negative number after `/` (`gc-1/-1` → `1 / -1`).
|
|
483
|
+
- **Fixed:** keyframes are written once instead of on every re-render, and single-stop keyframes accept `@0[…]`, `@0-[…]` and `@50%[…]`.
|
|
484
|
+
- **Added:** `cursor-grab` and other cursor keywords.
|
|
633
485
|
|
|
486
|
+
---
|
|
634
487
|
|
|
488
|
+
## License
|
|
635
489
|
|
|
490
|
+
See [LICENSE](LICENSE).
|