@cssints/reset 0.0.0-stage → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alexei Accio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,111 @@
1
- # Temporary Holding Version
1
+ # @cssints/reset
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A small modern CSS reset for [cssints](../../README.md), in a layer below every other style of the sheet, so any style
4
+ beats it whatever its specificity. It is one call member of `cssints/plugin` `scope()` that returns global rules. No
5
+ runtime.
6
+
7
+ ```ts
8
+ import { reset } from "@cssints/reset" with { type: "cssints" };
9
+
10
+ // reset({ media?, prose? })
11
+ reset({ media: true, prose: true });
12
+ ```
13
+
14
+ ```css
15
+ @layer reset;
16
+ @layer _.k, _.a, _.b, _.c, _.d, _.e;
17
+ @layer reset {
18
+ *,
19
+ *::before,
20
+ *::after {
21
+ box-sizing: border-box;
22
+ }
23
+ * {
24
+ margin: 0;
25
+ }
26
+ html {
27
+ -webkit-text-size-adjust: none;
28
+ text-size-adjust: none;
29
+ line-height: 1.5;
30
+ }
31
+ :where(input, button, textarea, select) {
32
+ font: inherit;
33
+ letter-spacing: inherit;
34
+ word-spacing: inherit;
35
+ color: inherit;
36
+ }
37
+ :where(p, h1, h2, h3, h4, h5, h6) {
38
+ overflow-wrap: break-word;
39
+ }
40
+ :where(h1, h2, h3, h4, h5, h6) {
41
+ text-wrap: balance;
42
+ }
43
+ :where(p) {
44
+ text-wrap: pretty;
45
+ }
46
+ :where(ul, ol)[role="list"] {
47
+ list-style: none;
48
+ padding: 0;
49
+ }
50
+ }
51
+ /* prose: true */
52
+ @layer reset {
53
+ :where(h1, …, p, ul, ol, dl, blockquote, pre, figure, table, hr):not([class])
54
+ + :where(h1, …, hr):not([class]) {
55
+ margin-block-start: 1em;
56
+ }
57
+ :where(h1, h2, h3, h4, h5, h6):not([class]) {
58
+ line-height: 1.25;
59
+ }
60
+ }
61
+ /* media: true */
62
+ @layer reset {
63
+ :where(img, picture, video, canvas, svg) {
64
+ display: block;
65
+ max-inline-size: 100%;
66
+ }
67
+ :where(img, video) {
68
+ block-size: auto;
69
+ }
70
+ }
71
+ ```
72
+
73
+ ## The rules
74
+
75
+ - **The base** is what most modern resets agree on ([Josh Comeau](https://www.joshwcomeau.com/css/custom-css-reset/),
76
+ [Jake Lazaroff](https://jakelazaroff.com/words/my-modern-css-reset/), [Vale](https://vale.rocks/posts/css-reset)):
77
+ `border-box`, no margins, a readable line height, no text inflation on mobile, form controls in the page's font and
78
+ colour, long words that wrap, balanced headings and paragraphs without orphans. The paddings stay (a list keeps room
79
+ for its markers), and the markers of a list go only with `role="list"` (Andy Bell's), since Safari stops announcing a
80
+ list that has `list-style: none`.
81
+ - **`media: true`** makes images, videos, canvases and SVGs blocks that never overflow their container, and keeps the
82
+ aspect ratio of an image or video whose `height` attribute is set.
83
+ - **`prose: true`** adds back the space of text: 1em between flow elements that follow each other (Andy Bell's
84
+ [flow](https://piccalil.li/blog/my-favourite-3-lines-of-css/)), and tighter headings, only on elements that have no
85
+ class (Jake Lazaroff's `:not([class])`), as in rendered Markdown. An element with a cssints class is left alone.
86
+ - **Below everything.** The rules are in a top-level layer `reset`, declared before the engine's layers (a `layers`
87
+ entry with `before: true`), so the reset is below the kernels, `global()` and token rules of `_.k`, below the class
88
+ layers and the layers you declare with `layers()`; an unlayered stylesheet beats it as well.
89
+ - **A layer of your own between.** Declare it after `reset`, before the engine's:
90
+ `layers("reset", "base", { before: true })` puts `base` above the reset and below every cssints style.
91
+ - **Once.** Each block is a global rule identified by its text: `reset()` in two modules, or `reset()` and
92
+ `reset({ media: true })`, print the base once.
93
+
94
+ ## Limits
95
+
96
+ - `reset` is a contract name: a `layers("reset")` without `before`, or another plugin that declares `reset` after the
97
+ engine's layers, is a build error.
98
+ - The rule set is fixed: there is no option per rule. A rule you do not want is overridden by any style of yours.
99
+ - Call it at a module's top level, in a module that the pages load (the entry): the reset is in the sheet of the modules
100
+ that call it, and leaves with them.
101
+
102
+ ```bash
103
+ cd packages/reset && bun run test # fixtures through the engine (the order of the sheet, the flags), and the type test via bun run typecheck
104
+ ```
105
+
106
+ ## Credits
107
+
108
+ The base follows what [Josh Comeau](https://www.joshwcomeau.com/css/custom-css-reset/),
109
+ [Jake Lazaroff](https://jakelazaroff.com/words/my-modern-css-reset/) and [Vale](https://vale.rocks/posts/css-reset)
110
+ publish; `role="list"` and the flow rule are [Andy Bell's](https://piccalil.li/blog/my-favourite-3-lines-of-css/). The
111
+ declarations are those that these resets share. They are written here, as globals of `scope()`; no file is copied.
@@ -0,0 +1,19 @@
1
+ //#region src/index.d.ts
2
+ declare const resetScope: import("cssints/plugin").Scope<"reset", {
3
+ readonly reset: {
4
+ readonly args: readonly [{
5
+ readonly "media?": import("cssints/plugin").Typed<boolean>;
6
+ readonly "prose?": import("cssints/plugin").Typed<boolean>;
7
+ }];
8
+ };
9
+ }>;
10
+ /**
11
+ * `reset({ media?, prose? })`: the reset, in a layer below every other style of the sheet. The base sets `border-box`,
12
+ * removes the margins, gives `html` a line height of 1.5 and stops mobile text inflation, makes form controls inherit the
13
+ * font and colour, wraps long words in text and balances headings, and removes the markers of a list with
14
+ * `role="list"`. `media: true` makes images, videos, canvases and SVGs blocks that do not overflow their container;
15
+ * `prose: true` puts 1em between flow elements (headings, paragraphs, lists, ...) that have no class, as in rendered
16
+ * Markdown. Call it at a module's top level; it prints no class.
17
+ */
18
+ export declare const reset: ReturnType<typeof resetScope.export>["reset"];
19
+ //#endregion
package/dist/index.mjs ADDED
@@ -0,0 +1,44 @@
1
+ import { arg, scope } from "cssints/plugin";
2
+ //#region src/index.ts
3
+ const HEADINGS = "h1, h2, h3, h4, h5, h6";
4
+ const FLOW = `${HEADINGS}, p, ul, ol, dl, blockquote, pre, figure, table, hr`;
5
+ const layered = (rules) => ({
6
+ css: rules,
7
+ layer: "reset"
8
+ });
9
+ const BASE = layered([
10
+ "*, *::before, *::after { box-sizing: border-box }",
11
+ "* { margin: 0 }",
12
+ "html { -webkit-text-size-adjust: none; text-size-adjust: none; line-height: 1.5 }",
13
+ ":where(input, button, textarea, select) { font: inherit; letter-spacing: inherit; word-spacing: inherit; color: inherit }",
14
+ `:where(p, ${HEADINGS}) { overflow-wrap: break-word }`,
15
+ `:where(${HEADINGS}) { text-wrap: balance }`,
16
+ ":where(p) { text-wrap: pretty }",
17
+ ":where(ul, ol)[role=\"list\"] { list-style: none; padding: 0 }"
18
+ ].join(" "));
19
+ const MEDIA = layered([":where(img, picture, video, canvas, svg) { display: block; max-inline-size: 100% }", ":where(img, video) { block-size: auto }"].join(" "));
20
+ const PROSE = layered([`:where(${FLOW}):not([class]) + :where(${FLOW}):not([class]) { margin-block-start: 1em }`, `:where(${HEADINGS}):not([class]) { line-height: 1.25 }`].join(" "));
21
+ /**
22
+ * `reset({ media?, prose? })`: the reset, in a layer below every other style of the sheet. The base sets `border-box`,
23
+ * removes the margins, gives `html` a line height of 1.5 and stops mobile text inflation, makes form controls inherit the
24
+ * font and colour, wraps long words in text and balances headings, and removes the markers of a list with
25
+ * `role="list"`. `media: true` makes images, videos, canvases and SVGs blocks that do not overflow their container;
26
+ * `prose: true` puts 1em between flow elements (headings, paragraphs, lists, ...) that have no class, as in rendered
27
+ * Markdown. Call it at a module's top level; it prints no class.
28
+ */
29
+ const reset = scope("reset", { reset: { args: [{
30
+ "media?": arg(),
31
+ "prose?": arg()
32
+ }] } }).build({ reset: (options) => ({
33
+ layers: {
34
+ layers: ["reset"],
35
+ before: true
36
+ },
37
+ globals: [
38
+ BASE,
39
+ ...options.media ? [MEDIA] : [],
40
+ ...options.prose ? [PROSE] : []
41
+ ]
42
+ }) }).export().reset;
43
+ //#endregion
44
+ export { reset };
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@cssints/reset",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "A small modern CSS reset for cssints, in a layer below every style",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/alexeiaccio/css-in-ts-compiler.git",
9
+ "directory": "packages/reset"
10
+ },
11
+ "homepage": "https://cssints.dev",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.mts",
20
+ "default": "./dist/index.mjs"
21
+ }
22
+ },
23
+ "peerDependencies": {
24
+ "cssints": "^0.2.0"
25
+ },
26
+ "engines": {
27
+ "node": ">=22"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }