@thi.ng/hiccup-css 2.6.6 → 2.6.8

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +76 -59
  3. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-02-25T14:07:53Z
3
+ - **Last updated**: 2024-03-02T14:05:53Z
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.
package/README.md CHANGED
@@ -1,16 +1,5 @@
1
1
  <!-- This file is generated - DO NOT EDIT! -->
2
2
  <!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
3
- > [!IMPORTANT]
4
- > ‼️ Announcing the thi.ng user survey 2024 📋
5
- >
6
- > [Please participate in the survey here!](https://forms.gle/XacbSDEmQMPZg8197)\
7
- > (open until end of February)
8
- >
9
- > **To achieve a better sample size, I'd highly appreciate if you could
10
- > circulate the link to this survey in your own networks.**
11
- >
12
- > [Discussion](https://github.com/thi-ng/umbrella/discussions/447)
13
-
14
3
  # ![@thi.ng/hiccup-css](https://media.thi.ng/umbrella/banners-20230807/thing-hiccup-css.svg?a302745b)
15
4
 
16
5
  [![npm version](https://img.shields.io/npm/v/@thi.ng/hiccup-css.svg)](https://www.npmjs.com/package/@thi.ng/hiccup-css)
@@ -22,7 +11,7 @@
22
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
23
12
  > and anti-framework.
24
13
  >
25
- > 🚀 Help me to work full-time on these projects by [sponsoring me on
14
+ > 🚀 Please help me to work full-time on these projects by [sponsoring me on
26
15
  > GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
27
16
 
28
17
  - [About](#about)
@@ -181,13 +170,15 @@ format preset, see examples further below.
181
170
  This feature is only intended for setting an element's `.style` attrib:
182
171
 
183
172
  ```ts
184
- css.css({
173
+ import { css, percent, px } from "@thi.ng/hiccup-css";
174
+
175
+ css({
185
176
  position: "absolute",
186
177
  border: 0,
187
178
  // function is evaluated during serialization
188
- top: () => css.percent((Math.random() * 100) | 0),
179
+ top: () => percent((Math.random() * 100) | 0),
189
180
  // the entire properties object is passed to functions
190
- left: (props) => css.px(props.border),
181
+ left: (props) => px(props.border),
191
182
  // arrays are joined with `,`
192
183
  // nested arrays are joined w/ ` `
193
184
  font: [["72px", "ComicSans"], "sans-serif"]
@@ -199,13 +190,15 @@ css.css({
199
190
  ### Basic selectors
200
191
 
201
192
  ```ts
202
- css.css(
193
+ import { css, rem, PRETTY } from "@thi.ng/hiccup-css";
194
+
195
+ css(
203
196
  [
204
197
  ["html", "body", { margin: 0, padding: 0 }],
205
- ["div", { "max-width": css.rem(30)}],
198
+ ["div", { "max-width": rem(30)}],
206
199
  ["div.title", { color: "red" }]
207
200
  ],
208
- { format: css.PRETTY }
201
+ { format: PRETTY }
209
202
  );
210
203
  ```
211
204
 
@@ -227,16 +220,18 @@ div.title {
227
220
  ### Property object merging & re-use
228
221
 
229
222
  ```ts
223
+ import { css, PRETTY } from "@thi.ng/hiccup-css";
224
+
230
225
  // re-usable property snippets
231
226
  const border = { border: "1px solid black" };
232
227
  const red = { color: "red" };
233
228
 
234
- css.css(
229
+ css(
235
230
  [
236
231
  ["#foo", { background: "white" }, border, red],
237
232
  ["#bar", { background: "yellow", color: "black" }, border]
238
233
  ],
239
- { format: css.PRETTY }
234
+ { format: PRETTY }
240
235
  );
241
236
  ```
242
237
 
@@ -319,13 +314,15 @@ selectors are computed using the cartesian product of any selectors in
319
314
  the current scope and their previously defined parents:
320
315
 
321
316
  ```ts
322
- css.css(
323
- ["header", "footer", { "font-size": css.rem(1.25) },
317
+ import { css, rem, withAttrib, PRETTY } from "@thi.ng/hiccup-css";
318
+
319
+ css(
320
+ ["header", "footer", { "font-size": rem(1.25) },
324
321
  ["nav", { background: "#000", color: "#666" },
325
322
  ["ul", { "list-style": "none" }],
326
- ["li", { padding: css.rem(0.5) },
327
- [css.withAttrib("selected"), { color: "#0cf" }]]]],
328
- { format: css.PRETTY }
323
+ ["li", { padding: rem(0.5) },
324
+ [withAttrib("selected"), { color: "#0cf" }]]]],
325
+ { format: PRETTY }
329
326
  )
330
327
  ```
331
328
 
@@ -357,9 +354,11 @@ header, footer {
357
354
  Pseudo-classes follow the same pattern as other nested selectors shown above:
358
355
 
359
356
  ```ts
360
- css.css(
357
+ import { css, PRETTY } from "@thi.ng/hiccup-css";
358
+
359
+ css(
361
360
  ["p", ["a", [":link", {color: "red"}], [":visited", {border: 0}]]],
362
- { format: css.PRETTY }
361
+ { format: PRETTY }
363
362
  );
364
363
  ```
365
364
 
@@ -390,9 +389,11 @@ p a:visited {
390
389
  on property values is planned, but currently low priority.)
391
390
 
392
391
  ```ts
393
- css.css(
392
+ import { css, PRETTY } from "@thi.ng/hiccup-css";
393
+
394
+ css(
394
395
  ["div", {"border-radius": "4px"}],
395
- { autoprefix: ["border-radius"], format: css.PRETTY }
396
+ { autoprefix: ["border-radius"], format: PRETTY }
396
397
  );
397
398
  ```
398
399
 
@@ -426,20 +427,22 @@ Note: In CSS Level 3, the `not` operator can't be used to negate an individual
426
427
  media feature expression, only an entire media query.
427
428
 
428
429
  ```ts
429
- css.css(
430
- css.at_media(
431
- { screen: true, "min-width": css.rem(10) },
430
+ import { css, at_media, percent, rem, PRETTY } from "@thi.ng/hiccup-css";
431
+
432
+ css(
433
+ at_media(
434
+ { screen: true, "min-width": rem(10) },
432
435
  [
433
- [".col", { width: css.percent(50)}],
436
+ [".col", { width: percent(50)}],
434
437
  [
435
- css.at_media(
438
+ at_media(
436
439
  { "min-width": "20rem" },
437
- [".col", { padding: css.rem(1) }]
440
+ [".col", { padding: rem(1) }]
438
441
  )
439
442
  ]
440
443
  ]
441
444
  ),
442
- { format: css.PRETTY }
445
+ { format: PRETTY }
443
446
  );
444
447
  ```
445
448
 
@@ -464,9 +467,11 @@ css.css(
464
467
  ### Keyframes
465
468
 
466
469
  ```ts
467
- css.css(
468
- css.at_keyframes("fadein", { opacity: 0 }, { opacity: 1 }),
469
- { format: css.PRETTY }
470
+ import { css, at_keyframes, PRETTY } from "@thi.ng/hiccup-css";
471
+
472
+ css(
473
+ at_keyframes("fadein", { opacity: 0 }, { opacity: 1 }),
474
+ { format: PRETTY }
470
475
  );
471
476
  ```
472
477
 
@@ -485,8 +490,10 @@ css.css(
485
490
  ```
486
491
 
487
492
  ```ts
488
- css.css(
489
- css.at_keyframes(
493
+ import { css, at_keyframes, PRETTY } from "@thi.ng/hiccup-css";
494
+
495
+ css(
496
+ at_keyframes(
490
497
  "rgbfade",
491
498
  {
492
499
  0: {
@@ -500,7 +507,7 @@ css.css(
500
507
  }
501
508
  }
502
509
  ),
503
- { format: css.PRETTY }
510
+ { format: PRETTY }
504
511
  );
505
512
  ```
506
513
 
@@ -530,13 +537,15 @@ given animation `opts`. Only the `duration`option is given a default
530
537
  value (250ms), all others are optional.
531
538
 
532
539
  ```ts
540
+ import { css, animation } from "@thi.ng/hiccup-css";
541
+
533
542
  css(
534
- animation(
535
- "delayed-fade-in",
536
- { delay: "0.5s" },
537
- { opacity: 0 },
538
- { opacity: 1 }
539
- )
543
+ animation(
544
+ "delayed-fade-in",
545
+ { delay: "0.5s" },
546
+ { opacity: 0 },
547
+ { opacity: 1 }
548
+ )
540
549
  );
541
550
  ```
542
551
 
@@ -564,8 +573,10 @@ Results in:
564
573
  CSS strings can be installed into the DOM `<head>` element via `injectStyleSheet()`:
565
574
 
566
575
  ```ts
567
- css.injectStyleSheet(
568
- css.css([
576
+ import { css, injectStyleSheet } from "@thi.ng/hiccup-css";
577
+
578
+ injectStyleSheet(
579
+ css([
569
580
  "body", { background: "#000", color: "#fff" }
570
581
  ])
571
582
  );
@@ -586,7 +597,9 @@ the `CSSOpts` object passed to `css()`. This form is mainly used by the
586
597
  various `at_*()` functions provided (e.g. `at_media()` example above).
587
598
 
588
599
  ```ts
589
- css.css(at_import("foo.css", "screen"));
600
+ import { css, at_import } from "@thi.ng/hiccup-css";
601
+
602
+ css(at_import("foo.css", "screen"));
590
603
  // "@import url(foo.css) screen;"
591
604
  ```
592
605
 
@@ -594,10 +607,12 @@ The following example illustrates the head position placement, using the
594
607
  `comment()` function to emit CSS comments.
595
608
 
596
609
  ```ts
597
- css.css([
610
+ import { css, comment } from "@thi.ng/hiccup-css";
611
+
612
+ css([
598
613
  // comments are usually omitted with the default format (css.COMPACT)
599
614
  // pass `true` as 2nd arg to force inclusion
600
- css.comment("generated, please don't edit", true),
615
+ comment("generated, please don't edit", true),
601
616
  ["div", { margin: 0 }]
602
617
  ]);
603
618
  // "/*generated, don't edit*/div{margin:0;}"
@@ -628,6 +643,8 @@ called with all remaining elements in the same array. I.e. `["@import",
628
643
  of a scope.
629
644
 
630
645
  ```ts
646
+ import * as css from "@thi.ng/hiccup-css";
647
+
631
648
  const styles = [
632
649
  ["@comment", " CSS from JSON"],
633
650
  ["@import", "print.css", "print"],
@@ -642,12 +659,12 @@ css.css(styles, { format: css.PRETTY, fns: css.QUOTED_FNS });
642
659
 
643
660
  // btw. QUOTED_FNS is simply:
644
661
  const QUOTED_FNS = {
645
- "@comment": comment,
646
- "@import": at_import,
647
- "@keyframes": at_keyframes,
648
- "@media": at_media,
649
- "@namespace": at_namespace,
650
- "@supports": at_supports,
662
+ "@comment": css.comment,
663
+ "@import": css.at_import,
664
+ "@keyframes": css.at_keyframes,
665
+ "@media": css.at_media,
666
+ "@namespace": css.at_namespace,
667
+ "@supports": css.at_supports,
651
668
  }
652
669
  ```
653
670
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/hiccup-css",
3
- "version": "2.6.6",
3
+ "version": "2.6.8",
4
4
  "description": "CSS from nested JS data structures",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -35,10 +35,10 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "dependencies": {
38
- "@thi.ng/api": "^8.9.26",
39
- "@thi.ng/checks": "^3.5.0",
40
- "@thi.ng/errors": "^2.4.18",
41
- "@thi.ng/transducers": "^8.9.7"
38
+ "@thi.ng/api": "^8.9.27",
39
+ "@thi.ng/checks": "^3.5.1",
40
+ "@thi.ng/errors": "^2.4.19",
41
+ "@thi.ng/transducers": "^8.9.9"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@microsoft/api-extractor": "^7.40.1",
@@ -126,5 +126,5 @@
126
126
  ],
127
127
  "year": 2016
128
128
  },
129
- "gitHead": "6e20f80dd9df1c8055ffa3c1e4d6f7598add0c0b\n"
129
+ "gitHead": "df9e312af741d87e6b450afcfea6a6e381662b1e\n"
130
130
  }