css-calipers 0.12.1 → 0.13.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.
Files changed (2) hide show
  1. package/README.md +35 -19
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,18 +1,26 @@
1
1
  # CSS-Calipers
2
2
 
3
- **CSS is code. Treat it that way.**
4
- Compile-time unit safety for numeric, unit-bearing CSS values, no surprises at runtime.
5
-
6
- CSS-Calipers is a tiny layer for typed CSS measurements. Stop parsing CSS
7
- strings and concatenating units. Do your math on real numbers, get
8
- compile-time unit safety, and output CSS only at the edges.
3
+ [![npm](https://img.shields.io/npm/v/css-calipers.svg)](https://www.npmjs.com/package/css-calipers)
4
+ [![types](https://img.shields.io/npm/types/css-calipers.svg)](https://www.npmjs.com/package/css-calipers)
5
+ [![license](https://img.shields.io/npm/l/css-calipers.svg)](./LICENSE.txt)
9
6
 
10
- This README is a general overview. Deeper module guides live in their own files.
7
+ **CSS is code. Treat it that way.**
8
+ Compile-time unit safety for numeric, unit-bearing CSS values, with no surprises at runtime.
11
9
 
12
- Module guides:
10
+ ```ts
11
+ // Before: pull the number AND the unit apart, do the math, glue them back
12
+ const match = base.match(/^(-?\d*\.?\d+)([a-z%]+)$/i);
13
+ if (!match) throw new Error(`Bad measurement: ${base}`);
14
+ const [, numStr, unit] = match;
15
+ const num = parseFloat(numStr);
16
+ const pad = `${num + 4}${unit}`; // and nobody checked that `unit` matches what the caller expects
17
+
18
+ // After: typed math, units enforced by the compiler
19
+ const base = m(8); // or m(8, "rem"), m(1.5, "em"), etc.
20
+ const pad = base.add(4).css(); // type error if units don't match
21
+ ```
13
22
 
14
- - Measurements core: README_MEASUREMENT.md
15
- - Media queries: README_MEDIAQUERIES.md
23
+ A small TypeScript library for **type-safe CSS measurements**. Do arithmetic on real numbers with the unit attached, let the compiler catch `px`-vs-`rem` mistakes, and emit a CSS string only at the edge.
16
24
 
17
25
  At a glance:
18
26
 
@@ -26,15 +34,6 @@ At a glance:
26
34
  npm install css-calipers
27
35
  ```
28
36
 
29
- ### Status & support
30
-
31
- > 🚧 Work in progress.
32
- > API surface and docs may change between `0.x` releases until the first stable version.
33
-
34
- - Status: early `0.x` release. Backwards compatibility is not guaranteed until `1.0.0`.
35
- - Questions or bugs: open an issue on GitHub (see the repository link at the top of this page or in `package.json`).
36
- - Tooling: tested primarily with TypeScript 5.6+ on Node 18+.
37
-
38
37
  ---
39
38
 
40
39
  ## Quick start
@@ -61,6 +60,16 @@ If you prefer, you can also import unit helpers from dedicated subpaths. For exa
61
60
 
62
61
  ---
63
62
 
63
+ ## Status & support
64
+
65
+ > API surface and docs may change between `0.x` releases until the first stable version.
66
+
67
+ - Status: early `0.x` release. Backwards compatibility is not guaranteed until `1.0.0`.
68
+ - Questions or bugs: open an issue on GitHub (see the repository link at the top of this page or in `package.json`).
69
+ - Tooling: tested primarily with TypeScript 5.6+ on Node 18+.
70
+
71
+ ---
72
+
64
73
  ## Media queries
65
74
 
66
75
  ```ts
@@ -464,6 +473,13 @@ by your styling layer. That’s the intended scope: CSS will always be a mix of
464
473
  values, but the library gives you a tight, unit-safe boundary for the numeric
465
474
  parts inside a broader styling solution.
466
475
 
476
+ ### Module guides
477
+
478
+ Deeper guides live alongside this README:
479
+
480
+ - Measurements core: [README_MEASUREMENT.md](README_MEASUREMENT.md)
481
+ - Media queries: [README_MEDIAQUERIES.md](README_MEDIAQUERIES.md)
482
+
467
483
  ### Further examples in this repo
468
484
 
469
485
  The `examples/` folder contains a few non-published usage sketches:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-calipers",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "Compile-time unit safety for numeric, unit-bearing CSS values via typed measurements.",
5
5
  "license": "MIT",
6
6
  "repository": {