aliascss 1.4.7 → 1.5.1
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 +51 -0
- package/bin/aliascss.js +118 -1
- package/dist/aliascss.js +1 -1
- package/jestconfig.json +1 -3
- package/lib/build/index.js +136 -19
- package/lib/classPrinter.d.ts +1 -1
- package/lib/classPrinter.js +351 -23
- package/lib/compilers/border.js +106 -27
- package/lib/compilers/clipPath.js +79 -6
- package/lib/compilers/color.js +150 -21
- package/lib/compilers/filter.js +90 -3
- package/lib/compilers/font.js +39 -11
- package/lib/compilers/gradient.js +43 -27
- package/lib/compilers/length.js +34 -9
- package/lib/compilers/shadow.js +60 -26
- package/lib/compilers/stringAndContent.js +39 -2
- package/lib/compilers/timingFunction.js +57 -6
- package/lib/compilers/transform.js +118 -48
- package/lib/compilers/transition.js +79 -11
- package/lib/compilers/url.js +53 -3
- package/lib/config.d.ts +1 -0
- package/lib/config.js +1 -0
- package/lib/custom-css-compilers.js +1 -68
- package/lib/index.d.ts +9 -9
- package/lib/node/compileFile-BK-291026.d.ts +27 -0
- package/lib/node/compileFile-BK-291026.js +309 -0
- package/lib/node/compileFile-bk.d.ts +14 -12
- package/lib/node/compileFile-bk.js +263 -252
- package/lib/node/compileFile.js +1 -1
- package/lib/node/extractClassNamesFromFile.js +208 -86
- package/lib/prebuild.d.ts +26 -0
- package/lib/prebuild.js +0 -6
- package/lib/prefix/element-selector.js +93 -20
- package/lib/prefix/extractPrefix.d.ts +1 -1
- package/lib/prefix/extractPrefix.js +113 -70
- package/lib/returnPropertyAndValue-bk-301026.d.ts +30 -0
- package/lib/returnPropertyAndValue-bk-301026.js +219 -0
- package/lib/returnPropertyAndValue.js +26 -25
- package/lib/returnStatement-bk-291026.d.ts +5 -0
- package/lib/returnStatement-bk-291026.js +470 -0
- package/lib/returnStatement.d.ts +1 -0
- package/lib/returnStatement.js +120 -29
- package/lib/utils/helper.js +16 -2
- package/lib/x-classes/x-bundle.d.ts +26 -0
- package/lib/x-classes/x-bundle.js +2 -1
- package/lib/x-classes/x-extras.js +1 -1
- package/lib/x-classes/x-form-components.js +2 -1
- package/lib/x-classes/x-row-col.d.ts +29 -0
- package/lib/x-classes/x-row-col.js +52 -0
- package/llms.txt +326 -0
- package/package.json +3 -1
- package/tsconfig.json +1 -0
- package/tsconfig.test.json +10 -0
package/llms.txt
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# AliasCSS
|
|
2
|
+
|
|
3
|
+
> AliasCSS is a deterministic compiler that turns class names into native CSS. A class name *is* a CSS declaration, written as `[@scope-][selector-]property-value`. There is no design-token vocabulary to learn: if you know CSS, you can write AliasCSS. It works as a browser script (compiles classes on the page at runtime) or as a CLI/build step (writes a .css file). It ships optional theme-aware color tokens and an `x-` component library as examples of building your own design system.
|
|
4
|
+
|
|
5
|
+
Website: https://aliascss.com
|
|
6
|
+
Package: `aliascss` on npm
|
|
7
|
+
This file describes version 1.5.0. Every example below was compiled with that release.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Browser (no build step):
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script defer src="https://cdn.jsdelivr.net/npm/aliascss@latest/dist/aliascss.js"></script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Keep `defer` (or put the script at the end of `<body>`): the runtime watches the page for new elements and needs `<body>` to exist. Classes added later by JavaScript are compiled automatically.
|
|
18
|
+
|
|
19
|
+
CLI / build:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm i -D aliascss
|
|
23
|
+
npx aliascss "src/**/*.html" public/css/acss.css # input glob, output file
|
|
24
|
+
npx aliascss --config --watch # uses aliascss.config.js (or .mjs)
|
|
25
|
+
npx aliascss --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
// aliascss.config.js
|
|
30
|
+
export default {
|
|
31
|
+
input: ['src/**/*.{html,jsx,tsx,vue}'],
|
|
32
|
+
output: { location: 'public/css/acss.css' },
|
|
33
|
+
minify: false,
|
|
34
|
+
// prefix, layers, media, custom, extend, statement, group, ignore … are optional
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Core rule: a class is one CSS declaration
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
property-value display-flex → display: flex
|
|
42
|
+
alias-value d-flex → display: flex
|
|
43
|
+
@scope-property-value @md-d-flex → @media (min-width: 768px) { … }
|
|
44
|
+
--state-property-value --hover-c-red → :hover { color: red }
|
|
45
|
+
@scope--state-property-value @md--hover-c-red
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- The property-value pair is always last; everything before it is scope and selector.
|
|
49
|
+
- Full CSS property names always work (`background-color-red`, `justify-content-space-between`). Short aliases exist for common ones. When unsure, use the full name.
|
|
50
|
+
- Values are written as in CSS with `-` between tokens: `b-1px-solid-red` → `border: 1px solid red`, `p-8px-16px` → `padding: 8px 16px`.
|
|
51
|
+
|
|
52
|
+
### Common aliases
|
|
53
|
+
|
|
54
|
+
| Alias | Property | Example |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `d` | display | `d-flex`, `d-grid`, `d-none`, `d-inline-flex` |
|
|
57
|
+
| `p`, `m` | padding, margin | `p-16px`, `m-0`, `p-8px-16px` |
|
|
58
|
+
| `w`, `h` | width, height | `w-100%`, `h-40px` |
|
|
59
|
+
| `mw`, `xw` | min-width, max-width | `mw-0px`, `xw-680px` |
|
|
60
|
+
| `xh` | max-height | `xh-240px` |
|
|
61
|
+
| `g` | gap | `g-12px` |
|
|
62
|
+
| `aic`, `jcc`, `jcsb` | align-items:center, justify-content:center / space-between | |
|
|
63
|
+
| `c`, `bgc` | color, background-color | `c-red`, `bgc-slateTheme1` |
|
|
64
|
+
| `fs`, `fw`, `lh`, `ff` | font-size, font-weight, line-height, font-family | `fs-14px`, `fw-600`, `lh-1.5` |
|
|
65
|
+
| `les` | letter-spacing | `les--0.02em` |
|
|
66
|
+
| `b`, `br` | border, border-radius | `b-1px-solid-red`, `b-0`, `br-8px` |
|
|
67
|
+
| `t`, `r`, `btm`, `l` | top, right, bottom, left | `t-0` |
|
|
68
|
+
| `o`, `zi` | opacity, z-index | `o-0.5`, `zi-10` |
|
|
69
|
+
| `tf` | transform | `tf-scale-0.98`, `tf-translateY--2px` |
|
|
70
|
+
| `td` | text-decoration | `td-none` |
|
|
71
|
+
| `cont` | `content: ""` (for ::before/::after) | `--before-cont` |
|
|
72
|
+
|
|
73
|
+
Less common properties: use the full name (`overflow-wrap-break-word`, `scroll-margin-top-24px`).
|
|
74
|
+
|
|
75
|
+
## Values
|
|
76
|
+
|
|
77
|
+
| Need | Write | Output |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| Negative number | `--` before it | `m--8px` → `margin: -8px`, `tf-translateY--2px` |
|
|
80
|
+
| Decimal | `.` | `o-0.5`, `lh-1.5` |
|
|
81
|
+
| Percent | `%` | `w-100%` |
|
|
82
|
+
| Color with alpha | `/` + decimal 0–1 | `c-red/0.5`, `bgc-ccc/0.7` → `oklch(from … / 0.7)` |
|
|
83
|
+
| Hex color | with or without `#` | `c-e3e3e3` and `c-#e3e3e3` are the same |
|
|
84
|
+
| `!important` | `--important` or `-i` at the end | `c-red--important` |
|
|
85
|
+
| Complex value | property function `prop(value)` | see below |
|
|
86
|
+
|
|
87
|
+
### Property functions: `property(raw value)`
|
|
88
|
+
|
|
89
|
+
Use when the value has spaces, commas or functions:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
padding(8px_16px) → padding: 8px 16px
|
|
93
|
+
grid-template-columns(repeat(3,1fr)) → grid-template-columns: repeat(3,1fr)
|
|
94
|
+
box-shadow(0_1px_3px_rgb(0_0_0_/_0.1)) → box-shadow: 0 1px 3px rgb(0 0 0 / 0.1)
|
|
95
|
+
w(calc(100%_-_32px)) → width: calc(100% - 32px)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- `_` means a space. `\_` is a literal underscore. Commas stay commas.
|
|
99
|
+
- Inside `calc()`, `+` and `-` need spaces: write `calc(100%_-_32px)`, never `calc(100%-32px)` (invalid CSS). `*` and `/` don't need them: `calc(var(--x)*-1)`.
|
|
100
|
+
- Hex inside a function keeps its `#`: `c(#e3e3e3)`.
|
|
101
|
+
|
|
102
|
+
## CSS variables
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
--x-gap:16px defines --x-gap: 16px
|
|
106
|
+
--x-pad:(8px_16px) defines --x-pad: 8px 16px (raw value in parentheses)
|
|
107
|
+
--x-border-color:--x-accent:blue defines --x-border-color: var(--x-accent, blue)
|
|
108
|
+
g--x-gap uses gap: var(--x-gap)
|
|
109
|
+
g--x-gap:16px uses gap: var(--x-gap, 16px) (with fallback)
|
|
110
|
+
m--x-shift:--8px uses margin: var(--x-shift, -8px) (negative fallback: always write --8px)
|
|
111
|
+
bgc--x-bg:slateTheme1 uses background-color: var(--x-bg, <compiled color token>)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Variable names must not start with a digit. The end of a variable name decides how its value is compiled: names ending in `color` or `bg` compile colors (`slateTheme1` → `light-dark(…)`), names ending in `ring` compile a focus ring. Pick neutral names (`--x-gap`, `--x-border-color`) when you want the value as written.
|
|
115
|
+
|
|
116
|
+
## Selectors and states
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
--hover-c-red :hover --focus-visible-… --active-… --disabled-…
|
|
120
|
+
--before-cont ::before --after-… --placeholder-… --marker-…
|
|
121
|
+
--first-child-… --last-child-… --checked-… --open-… --popover-open-…
|
|
122
|
+
--nth-child(2n+1)-… :nth-child(2n+1) short: --nc(3)-… , --nth-child-3-…
|
|
123
|
+
--not(--first-child)-… :not(:first-child) (parentheses for anything longer than one word)
|
|
124
|
+
--not--hover-… :not(:hover) (one-word form)
|
|
125
|
+
--has(--checked)-… :has(:checked)
|
|
126
|
+
--is(…) --where(…) :is(…) :where(…) Capitalised (--Has, --Is, --Where) adds a space: " :has(…)"
|
|
127
|
+
--hover--before-c-red :hover::before (state first, then pseudo-element)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Never put a state after `::before`/`::after` (`--before--hover` → `::before:hover`, which never matches).
|
|
131
|
+
|
|
132
|
+
Vendor parts (each browser only applies its own prefix): `--webkit-slider-thumb`, `--webkit-slider-runnable-track`, `--moz-range-thumb`, `--moz-range-track`, `--moz-range-progress`, `--webkit-progress-bar`, `--webkit-progress-value`, `--moz-progress-bar`, `--scrollbar`, `--scrollbar-thumb`, `--file-selector-button`, `--details-content`.
|
|
133
|
+
|
|
134
|
+
### Attribute selectors
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
[aria-expanded=true]-c-red .x[aria-expanded="true"] { color: red }
|
|
138
|
+
[aria-current=page][c-red,fw-600] attribute first, then a group
|
|
139
|
+
[class~=active]-bgc-blue
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Combinators (target other elements)
|
|
143
|
+
|
|
144
|
+
| Write | Selector |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `_li-c-red` | descendant `li` |
|
|
147
|
+
| `__li-c-red` | child `> li` |
|
|
148
|
+
| `___p-c-red` | next sibling `+ p` |
|
|
149
|
+
| `____p-c-red` | later siblings `~ p` |
|
|
150
|
+
| `_all-m-0` | descendants `*` |
|
|
151
|
+
| `__all-m-0` | children `> *` |
|
|
152
|
+
| `_.card-c-red` | descendant `.card` |
|
|
153
|
+
| `_.(card-title)-c-red` | descendant `.card-title`: **class names containing `-` go in parentheses** |
|
|
154
|
+
| `_.(card.is-active)-o-1` | `.card.is-active` |
|
|
155
|
+
| `_ul__li--hover-c-red` | `ul > li:hover` |
|
|
156
|
+
|
|
157
|
+
### Selector before the element: `&`
|
|
158
|
+
|
|
159
|
+
Everything before `&` becomes an ancestor selector:
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
_.dark&c-white .dark .<class> { color: white }
|
|
163
|
+
[data-theme=dark]&c-white [data-theme="dark"] .<class> { … }
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Scopes (`@…-`)
|
|
167
|
+
|
|
168
|
+
| Scope | Meaning |
|
|
169
|
+
|---|---|
|
|
170
|
+
| `@xs-` | max-width: 575.99px |
|
|
171
|
+
| `@sm-` | min-width: 576px |
|
|
172
|
+
| `@md-` | min-width: 768px |
|
|
173
|
+
| `@lg-` | min-width: 992px |
|
|
174
|
+
| `@xl-` | min-width: 1200px |
|
|
175
|
+
| `@xxl-` | min-width: 1408px (`xxl`, not `2xl`) |
|
|
176
|
+
| `@hover-capable-` | `(hover: hover)` |
|
|
177
|
+
| `@motion-reduce-` | `prefers-reduced-motion: reduce` |
|
|
178
|
+
| `@container-xs-` … `@container-xxl-` | container queries |
|
|
179
|
+
| `@reset- @base- @theme- @components- @utils-` | CSS cascade layers (`@rs`, `@comps`, `@utilities` also work) |
|
|
180
|
+
| `@starting-style-` / `@ss-` | `@starting-style` (entry animations) |
|
|
181
|
+
| `@[components,starting-style]-…` | several scopes at once |
|
|
182
|
+
|
|
183
|
+
Layer order: `@layer reset, base, theme, components, utilities;` then the breakpoint layers.
|
|
184
|
+
|
|
185
|
+
### Responsive rules (important)
|
|
186
|
+
|
|
187
|
+
1. **Breakpoint classes live in layers, so a plain class always beats them.** Never mix `p-32px @xs-p-16px`; the plain one wins everywhere. Write every size with a prefix: `@xs-p-16px @sm-p-24px @md-p-32px`.
|
|
188
|
+
2. **`@xs` is max-width, the others are min-width.** If you start with `@xs`, also set `@sm`, or 576–767px gets nothing: `@xs-x-col-12 @sm-x-col-12 @lg-x-col-8`.
|
|
189
|
+
3. Larger breakpoints win over smaller ones (`@md` over `@sm`).
|
|
190
|
+
|
|
191
|
+
## Groups `[…]`
|
|
192
|
+
|
|
193
|
+
Apply one prefix to several declarations:
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
@md[d-flex,g-16px,p-24px]
|
|
197
|
+
--hover[c-red,bgc-blue]
|
|
198
|
+
@components--before[cont,position-absolute,inset-0]
|
|
199
|
+
[d-block,--hover-bgc-gray100,[aria-current=true]-fw-600] states and attributes are allowed inside
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
A group styles **one element in all its states**. Element nesting (`[_th[…]]`) is not supported: use statements for that.
|
|
203
|
+
|
|
204
|
+
## Export a component class: `--as-name`
|
|
205
|
+
|
|
206
|
+
```html
|
|
207
|
+
<div hidden class="[d-flex,aic,g-8px,p-8px-16px,br-8px,bgc-blue,c-white,--hover-bgc-navy]--as-btn"></div>
|
|
208
|
+
<button class="btn">Save</button>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
- `--as-[btn,button]` exports several names; `/` is allowed (`--as-card/header`).
|
|
212
|
+
- Only property-value classes can be exported; `x-` statements can't be put inside an export.
|
|
213
|
+
|
|
214
|
+
## Other HTML attributes
|
|
215
|
+
|
|
216
|
+
```html
|
|
217
|
+
<div class:card="p-24px br-12px --hover-bgc-gray100"></div> <!-- group named "card" -->
|
|
218
|
+
<div class:[@md]panel="p-32px d-grid"></div> <!-- every item gets @md- -->
|
|
219
|
+
<i keyframes-spin="@0[tf-rotate-0deg] @100[tf-rotate-360deg]"></i> <!-- @keyframes spin -->
|
|
220
|
+
<style data-raw-css="h1{letter-spacing:-0.02em}"></style> <!-- raw CSS passed through -->
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Colors and themes
|
|
224
|
+
|
|
225
|
+
- Theme-aware tokens (switch with light/dark): Radix scales `slateTheme1`…`slateTheme12` (also red, green, amber, blue … `Theme1-12`), fixed dark steps `slateDark1-12`, alpha `blackA1-12`.
|
|
226
|
+
- Accent scale (React Aria style), driven by one variable `--accentColor`: `accentRA100`…`accentRA1600` (fixed), `accentRATheme100`…`accentRATheme1600` (light/dark).
|
|
227
|
+
- Theme tokens compile to `light-dark()`, which needs `color-scheme`. Put `x-theme` on `<html>`.
|
|
228
|
+
- Rebrand everything: `<html class="x-theme --accentColor:0d74ce">`. Force a subtree: `x-theme-dark` / `x-theme-light`.
|
|
229
|
+
|
|
230
|
+
## x- components (optional starter library)
|
|
231
|
+
|
|
232
|
+
All are statements in the `@components` layer, use theme tokens, and can be customised with `--x-*` variables. Utilities override them.
|
|
233
|
+
|
|
234
|
+
- 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-progress`, `x-field`, `x-label`, `x-hint`, `x-error-text`, `x-choice`, `x-input-group`, `x-input-addon`
|
|
235
|
+
- Surfaces: `x-card` (+ `-header -body -footer -title -description -elevated -flat -interactive`), `x-badge`, `x-alert`, `x-table` (+ `-striped -bordered -hover -compact -sticky`), `x-table-card`
|
|
236
|
+
- Overlays: `x-dialog` (native `<dialog>`), `x-dropdown` (native `popover`), `x-accordion` (`<details>`)
|
|
237
|
+
- Navigation: `x-tab-list`, `x-tab`, `x-tab-panel`, `x-breadcrumb`, `x-pagination`, `x-menu` (hamburger → X, uses `aria-expanded`)
|
|
238
|
+
- Feedback: `x-spinner`, `x-skeleton`, `x-avatar`, `x-avatar-group`
|
|
239
|
+
- Layout: `x-stack`, `x-cluster`, `x-center`, `x-grid`, `x-switcher`, `x-sidebar`, `x-cover`, `x-frame`, `x-reel`
|
|
240
|
+
- 12-column grid: `x-row` (gap 16px; `x-row-xs/sm/md/lg/xl` = 4/8/16/24/32px; `x-row-20px` any gap), `x-col-1`…`x-col-12`, `x-col` (fill), `x-col-auto` (fit content), `x-col-240px` (fixed), `x-col-offset-1`…`11`. Uses flex + gap, no negative margins, so a card can be the column itself.
|
|
241
|
+
- Slide-in panels: `x-absolute-top/-bottom/-left/-right` (hide with `data-absolute-hide` or class `x-absolute-hide`), `x-absolute-0` (fill parent)
|
|
242
|
+
- Content: `x-prose`, `x-kbd`, `x-code`, `x-code-block`, `x-divider`, `x-divider-vertical`, `x-divider-text` (+ `-start -end`), `x-arrow` (+ `-up -down -left -right`)
|
|
243
|
+
- Theme: `x-theme`, `x-theme-light`, `x-theme-dark`
|
|
244
|
+
|
|
245
|
+
Example:
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
<html class="x-theme">
|
|
249
|
+
<div class="x-row">
|
|
250
|
+
<article class="x-card @xs-x-col-12 @sm-x-col-6 @lg-x-col-3">
|
|
251
|
+
<div class="x-card-body">…</div>
|
|
252
|
+
</article>
|
|
253
|
+
</div>
|
|
254
|
+
<button class="x-button x-button-secondary x-button-sm">Cancel</button>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Build your own design system
|
|
258
|
+
|
|
259
|
+
The `x-` library is an example, not a fixed API. Define your own in the config:
|
|
260
|
+
|
|
261
|
+
```js
|
|
262
|
+
export default {
|
|
263
|
+
extend: {
|
|
264
|
+
'ui-btn': { type: 'statement', statement: `
|
|
265
|
+
@base-all-unset
|
|
266
|
+
@components[d-inline-flex,aic,g-8px,p-8px-16px,br-8px,bgc--ui-btn-bg:accentRA1000,c-white,cursor-pointer]
|
|
267
|
+
@components--hover-bgc--ui-btn-hover:accentRA1100
|
|
268
|
+
@components--focus-visible[outline-2px-solid-currentColor,outline-offset-2px]
|
|
269
|
+
` },
|
|
270
|
+
'ui-reset': { type: 'raw', statement: `*{box-sizing:border-box}` },
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
- `type: 'statement'`: a class made of AliasCSS classes (multi-line, scopes allowed).
|
|
276
|
+
- `type: 'raw'`: plain CSS output as is.
|
|
277
|
+
- `type: 'group'`: a function compiler that takes a value (`x-col-6`, `x-row-24px`).
|
|
278
|
+
- Convention: custom function compilers are capitalised (`Theme(…)`), custom classes get a prefix (`x-`, `ui-`).
|
|
279
|
+
|
|
280
|
+
## Console messages
|
|
281
|
+
|
|
282
|
+
The compiler still outputs the CSS but warns about likely mistakes:
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
AliasCSS: "w(calc(100%-32px))": "+" and "-" need spaces in calc(), write _-_ e.g. calc(100%_-_32px)
|
|
286
|
+
AliasCSS: "--before--hover-c-red": "::before:hover" never matches; put the state first, e.g. --hover--before
|
|
287
|
+
AliasCSS: in "[d-flex,bad-thing,c-red]", could not compile: -bad-thing
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Values are not validated against CSS: `bgc-notacolor` outputs `background-color:notacolor` and the browser ignores it.
|
|
291
|
+
|
|
292
|
+
## Common mistakes
|
|
293
|
+
|
|
294
|
+
| Wrong | Right | Why |
|
|
295
|
+
|---|---|---|
|
|
296
|
+
| `p-32px @xs-p-16px` | `@xs-p-16px @sm-p-32px` | plain classes beat breakpoint classes |
|
|
297
|
+
| `@xs-x-col-12 @lg-x-col-6` | `@xs-x-col-12 @sm-x-col-12 @lg-x-col-6` | 576–991px would get nothing |
|
|
298
|
+
| `@2xl-…` | `@xxl-…` | there is no 2xl |
|
|
299
|
+
| `w(calc(100%-32px))` | `w(calc(100%_-_32px))` | calc needs spaces around + and - |
|
|
300
|
+
| `c-red/50` | `c-red/0.5` | alpha is a decimal 0–1 |
|
|
301
|
+
| `--before--hover-c-red` | `--hover--before-c-red` | state before pseudo-element |
|
|
302
|
+
| `_.card-title-c-red` | `_.(card-title)-c-red` | hyphenated class names need parentheses |
|
|
303
|
+
| `--not--first-child-…` | `--not(--first-child)-…` | multi-word selectors need parentheses |
|
|
304
|
+
| `m--x-gap:-8px` | `m--x-gap:--8px` | negative values (fallbacks too) use `--` |
|
|
305
|
+
| `<script src=…>` in `<head>` without `defer` | `<script defer src=…>` | the runtime needs `<body>` |
|
|
306
|
+
| `m-0_auto` | `margin(0_auto)` or `m-0-auto` | `_` only means space inside a property function |
|
|
307
|
+
| `content-""` | `cont` | `cont` gives `content: ""` |
|
|
308
|
+
| `[_th[fw-600]]` | a statement | groups can't nest elements |
|
|
309
|
+
|
|
310
|
+
## Output example
|
|
311
|
+
|
|
312
|
+
```html
|
|
313
|
+
<button class="d-inline-flex aic g-8px p-8px-16px br-8px bgc-blue c-white --hover-bgc-navy @md-p-12px-20px">
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
```css
|
|
317
|
+
.d-inline-flex{display:inline-flex}
|
|
318
|
+
.aic{align-items:center}
|
|
319
|
+
.g-8px{gap:8px}
|
|
320
|
+
.p-8px-16px{padding:8px 16px}
|
|
321
|
+
.br-8px{border-radius:8px}
|
|
322
|
+
.bgc-blue{background-color:blue}
|
|
323
|
+
.c-white{color:white}
|
|
324
|
+
.--hover-bgc-navy:hover{background-color:navy}
|
|
325
|
+
@layer md{@media (min-width:768px){.\@md-p-12px-20px{padding:12px 20px}}}
|
|
326
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aliascss",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "AliasCSS is a CSS post processor.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/jest": "^29.5.14",
|
|
29
|
+
"@types/node": "^26.6.6",
|
|
29
30
|
"@types/postcss-sorting": "^8.0.2",
|
|
30
31
|
"browser-sync": "^1.9.2",
|
|
31
32
|
"jest": "^29.6.2",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"ts-node": "^10.9.2",
|
|
35
36
|
"tslint": "^6.1.3",
|
|
36
37
|
"tslint-config-prettier": "^1.18.0",
|
|
38
|
+
"typescript": "^6.0.3",
|
|
37
39
|
"vite": "^6.3.5",
|
|
38
40
|
"webpack": "^5.88.2",
|
|
39
41
|
"webpack-cli": "^5.1.4"
|
package/tsconfig.json
CHANGED