@thi.ng/hiccup-css 2.6.13 → 2.7.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 +20 -1
- package/README.md +63 -1
- package/animation.js +3 -3
- package/attribs.js +1 -1
- package/impl.js +4 -2
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-03-
|
|
3
|
+
- **Last updated**: 2024-03-27T09:53:45Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,25 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [2.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-css@2.7.0) (2024-03-21)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add support for `&` parent selector ([2332cdc](https://github.com/thi-ng/umbrella/commit/2332cdc))
|
|
17
|
+
- update xfSel transducer to support SASS-style `&`
|
|
18
|
+
parent selector
|
|
19
|
+
- add tests
|
|
20
|
+
|
|
21
|
+
#### 🩹 Bug fixes
|
|
22
|
+
|
|
23
|
+
- correct case-sensitivity in attrib selectors ([23d556f](https://github.com/thi-ng/umbrella/commit/23d556f))
|
|
24
|
+
- add tests
|
|
25
|
+
|
|
26
|
+
#### ♻️ Refactoring
|
|
27
|
+
|
|
28
|
+
- minor updates ([ac9032d](https://github.com/thi-ng/umbrella/commit/ac9032d))
|
|
29
|
+
- internal updates animation() & withScope()
|
|
30
|
+
|
|
12
31
|
## [2.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-css@2.6.0) (2024-02-12)
|
|
13
32
|
|
|
14
33
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
- [Property object merging & re-use](#property-object-merging--re-use)
|
|
30
30
|
- [Iterators & CSS class scoping](#iterators--css-class-scoping)
|
|
31
31
|
- [Nested selectors](#nested-selectors)
|
|
32
|
+
- [Parent selector](#parent-selector)
|
|
32
33
|
- [Pseudo-classes](#pseudo-classes)
|
|
33
34
|
- [Attribute selectors](#attribute-selectors)
|
|
34
35
|
- [Auto-prefixed properties](#auto-prefixed-properties)
|
|
@@ -121,7 +122,7 @@ For Node.js REPL:
|
|
|
121
122
|
const hiccupCss = await import("@thi.ng/hiccup-css");
|
|
122
123
|
```
|
|
123
124
|
|
|
124
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 2.
|
|
125
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 2.23 KB
|
|
125
126
|
|
|
126
127
|
## Dependencies
|
|
127
128
|
|
|
@@ -348,6 +349,67 @@ header, footer {
|
|
|
348
349
|
font-size: 1.25rem;
|
|
349
350
|
}
|
|
350
351
|
```
|
|
352
|
+
#### Parent selector
|
|
353
|
+
|
|
354
|
+
Child selectors can use the special `&` prefix to refer to their direct parent
|
|
355
|
+
to form derived selectors, for example:
|
|
356
|
+
|
|
357
|
+
```js
|
|
358
|
+
import { css, PRETTY } from "@thi.ng/hiccup-css";
|
|
359
|
+
|
|
360
|
+
css(
|
|
361
|
+
["#test", { color: "white" },
|
|
362
|
+
["&.alt", { color: "black" }],
|
|
363
|
+
["&-alt-bg", { background: "black" }]],
|
|
364
|
+
{ format: css.PRETTY }
|
|
365
|
+
);
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
```css
|
|
369
|
+
#test.alt {
|
|
370
|
+
color: black;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
#test-alt-bg {
|
|
374
|
+
background: black;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
#test {
|
|
378
|
+
color: white;
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
The `&`-prefixed selectors only refer to their immediate parent, but otherwise
|
|
383
|
+
behave like all other nested selectors:
|
|
384
|
+
|
|
385
|
+
```js
|
|
386
|
+
import { css, PRETTY } from "@thi.ng/hiccup-css";
|
|
387
|
+
|
|
388
|
+
css(
|
|
389
|
+
["outer1", "outer2",
|
|
390
|
+
[".inner1", ".inner2", { color: "red" },
|
|
391
|
+
["&--green", { color: "green" }],
|
|
392
|
+
["&--blue", { color: "blue" }]]],
|
|
393
|
+
{ format: css.PRETTY }
|
|
394
|
+
);
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
```css
|
|
398
|
+
outer1 .inner1--green, outer1 .inner2--green,
|
|
399
|
+
outer2 .inner1--green, outer2 .inner2--green {
|
|
400
|
+
color: green;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
outer1 .inner1--blue, outer1 .inner2--blue,
|
|
404
|
+
outer2 .inner1--blue, outer2 .inner2--blue {
|
|
405
|
+
color: blue;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
outer1 .inner1, outer1 .inner2,
|
|
409
|
+
outer2 .inner1, outer2 .inner2 {
|
|
410
|
+
color: red;
|
|
411
|
+
}
|
|
412
|
+
```
|
|
351
413
|
|
|
352
414
|
### Pseudo-classes
|
|
353
415
|
|
package/animation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { at_keyframes } from "./keyframes.js";
|
|
2
2
|
const animation = (id, opts, ...keyframes) => {
|
|
3
|
-
opts = {
|
|
3
|
+
const $opts = {
|
|
4
4
|
duration: "250ms",
|
|
5
5
|
name: id,
|
|
6
6
|
...opts
|
|
@@ -9,8 +9,8 @@ const animation = (id, opts, ...keyframes) => {
|
|
|
9
9
|
at_keyframes.apply(null, [id, ...keyframes]),
|
|
10
10
|
[
|
|
11
11
|
`.${id}`,
|
|
12
|
-
Object.
|
|
13
|
-
(acc, k) => (acc[`animation-${k}`] =
|
|
12
|
+
Object.entries($opts).reduce(
|
|
13
|
+
(acc, [k, v]) => (acc[`animation-${k}`] = v, acc),
|
|
14
14
|
{}
|
|
15
15
|
)
|
|
16
16
|
]
|
package/attribs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const $ = (op) => (id, x, caseSensitve =
|
|
1
|
+
const $ = (op) => (id, x, caseSensitve = true) => `[${id}${op}="${x}"${caseSensitve ? "" : " i"}]`;
|
|
2
2
|
const withAttrib = (id) => `[${id}]`;
|
|
3
3
|
const attribEq = $("");
|
|
4
4
|
const attribContains = $("~");
|
package/impl.js
CHANGED
|
@@ -15,11 +15,13 @@ const EMPTY = /* @__PURE__ */ new Set();
|
|
|
15
15
|
const NO_SPACES = ":[";
|
|
16
16
|
const xfSel = comp(
|
|
17
17
|
flatten(),
|
|
18
|
-
map(
|
|
18
|
+
map(
|
|
19
|
+
(x) => x[0] === "&" ? x.substring(1) : NO_SPACES.includes(x[0]) ? x : " " + x
|
|
20
|
+
)
|
|
19
21
|
);
|
|
20
22
|
const withScope = (xf, scope) => comp(
|
|
21
23
|
xf,
|
|
22
|
-
map((x) => isString(x) && x.
|
|
24
|
+
map((x) => isString(x) && x.startsWith(" .") ? x + scope : x)
|
|
23
25
|
);
|
|
24
26
|
const expand = (acc, parent, rules, opts) => {
|
|
25
27
|
const n = rules.length;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hiccup-css",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "CSS from nested JS data structures",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.9.
|
|
40
|
-
"@thi.ng/checks": "^3.5.
|
|
41
|
-
"@thi.ng/errors": "^2.5.
|
|
42
|
-
"@thi.ng/transducers": "^8.9.
|
|
39
|
+
"@thi.ng/api": "^8.9.31",
|
|
40
|
+
"@thi.ng/checks": "^3.5.5",
|
|
41
|
+
"@thi.ng/errors": "^2.5.2",
|
|
42
|
+
"@thi.ng/transducers": "^8.9.16"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.
|
|
46
|
-
"esbuild": "^0.20.
|
|
45
|
+
"@microsoft/api-extractor": "^7.43.0",
|
|
46
|
+
"esbuild": "^0.20.2",
|
|
47
47
|
"rimraf": "^5.0.5",
|
|
48
48
|
"typedoc": "^0.25.12",
|
|
49
|
-
"typescript": "^5.4.
|
|
49
|
+
"typescript": "^5.4.3"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"array",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
],
|
|
128
128
|
"year": 2016
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "feb3b24654f2c931cd3c3308c1c0c807ee14d0e4\n"
|
|
131
131
|
}
|