@jam-overture/loom 0.1.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 +21 -0
- package/README.md +743 -0
- package/dist/catalogue.d.ts +70 -0
- package/dist/catalogue.js +88 -0
- package/dist/cli/args.d.ts +17 -0
- package/dist/cli/args.js +83 -0
- package/dist/cli/filesystem.d.ts +15 -0
- package/dist/cli/filesystem.js +31 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.js +12 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +30 -0
- package/dist/cli/namespace.d.ts +40 -0
- package/dist/cli/namespace.js +40 -0
- package/dist/cli/plan.d.ts +84 -0
- package/dist/cli/plan.js +113 -0
- package/dist/cli/run.d.ts +17 -0
- package/dist/cli/run.js +75 -0
- package/dist/cli/templates.d.ts +43 -0
- package/dist/cli/templates.js +134 -0
- package/dist/closed-set.d.ts +34 -0
- package/dist/closed-set.js +34 -0
- package/dist/data/adapter.d.ts +123 -0
- package/dist/data/adapter.js +91 -0
- package/dist/data/binding.d.ts +48 -0
- package/dist/data/binding.js +39 -0
- package/dist/data/catalogue.d.ts +26 -0
- package/dist/data/catalogue.js +6 -0
- package/dist/data/index.d.ts +14 -0
- package/dist/data/index.js +14 -0
- package/dist/data/plan.d.ts +58 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +91 -0
- package/dist/data/resolution.js +96 -0
- package/dist/data/resolve.d.ts +46 -0
- package/dist/data/resolve.js +37 -0
- package/dist/data/source.d.ts +40 -0
- package/dist/data/source.js +45 -0
- package/dist/deadline.d.ts +57 -0
- package/dist/deadline.js +78 -0
- package/dist/frame/catalogue.d.ts +24 -0
- package/dist/frame/catalogue.js +5 -0
- package/dist/frame/index.d.ts +12 -0
- package/dist/frame/index.js +12 -0
- package/dist/frame/origin.d.ts +87 -0
- package/dist/frame/origin.js +114 -0
- package/dist/frame/resolution.d.ts +85 -0
- package/dist/frame/resolution.js +79 -0
- package/dist/grammar.d.ts +26 -0
- package/dist/grammar.js +28 -0
- package/dist/ids.d.ts +57 -0
- package/dist/ids.js +104 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/interactivity.d.ts +50 -0
- package/dist/interactivity.js +22 -0
- package/dist/interpretation/anthropic.d.ts +22 -0
- package/dist/interpretation/anthropic.js +76 -0
- package/dist/interpretation/client.d.ts +83 -0
- package/dist/interpretation/client.js +2 -0
- package/dist/interpretation/draft.d.ts +234 -0
- package/dist/interpretation/draft.js +84 -0
- package/dist/interpretation/index.d.ts +15 -0
- package/dist/interpretation/index.js +15 -0
- package/dist/interpretation/interpreter.d.ts +62 -0
- package/dist/interpretation/interpreter.js +151 -0
- package/dist/interpretation/materialize.d.ts +42 -0
- package/dist/interpretation/materialize.js +107 -0
- package/dist/interpretation/prompt.d.ts +229 -0
- package/dist/interpretation/prompt.js +285 -0
- package/dist/interpretation/render.d.ts +76 -0
- package/dist/interpretation/render.js +272 -0
- package/dist/interpretation/schema.d.ts +49 -0
- package/dist/interpretation/schema.js +131 -0
- package/dist/json.d.ts +35 -0
- package/dist/json.js +11 -0
- package/dist/paging.d.ts +60 -0
- package/dist/paging.js +49 -0
- package/dist/primitive-type.d.ts +32 -0
- package/dist/primitive-type.js +39 -0
- package/dist/render/addressing.d.ts +59 -0
- package/dist/render/addressing.js +60 -0
- package/dist/render/anchor.d.ts +105 -0
- package/dist/render/anchor.js +84 -0
- package/dist/render/behaviour-adjust.d.ts +62 -0
- package/dist/render/behaviour-adjust.js +78 -0
- package/dist/render/behaviour-copy.d.ts +53 -0
- package/dist/render/behaviour-copy.js +75 -0
- package/dist/render/behaviour-disclose.d.ts +74 -0
- package/dist/render/behaviour-disclose.js +77 -0
- package/dist/render/behaviour-present.d.ts +123 -0
- package/dist/render/behaviour-present.js +173 -0
- package/dist/render/behaviour.d.ts +243 -0
- package/dist/render/behaviour.js +284 -0
- package/dist/render/control.d.ts +81 -0
- package/dist/render/control.js +80 -0
- package/dist/render/decorative.d.ts +62 -0
- package/dist/render/decorative.js +2 -0
- package/dist/render/diagnostics.d.ts +260 -0
- package/dist/render/diagnostics.js +61 -0
- package/dist/render/disclosed.d.ts +37 -0
- package/dist/render/disclosed.js +37 -0
- package/dist/render/editable.d.ts +34 -0
- package/dist/render/editable.js +35 -0
- package/dist/render/frame.d.ts +42 -0
- package/dist/render/frame.js +31 -0
- package/dist/render/index.d.ts +35 -0
- package/dist/render/index.js +35 -0
- package/dist/render/inline-variables.d.ts +77 -0
- package/dist/render/inline-variables.js +220 -0
- package/dist/render/presented.d.ts +82 -0
- package/dist/render/presented.js +82 -0
- package/dist/render/primitive.d.ts +228 -0
- package/dist/render/primitive.js +36 -0
- package/dist/render/props.d.ts +48 -0
- package/dist/render/props.js +2 -0
- package/dist/render/reads.d.ts +73 -0
- package/dist/render/reads.js +45 -0
- package/dist/render/render.d.ts +164 -0
- package/dist/render/render.js +571 -0
- package/dist/render/request.d.ts +111 -0
- package/dist/render/request.js +60 -0
- package/dist/render/text.d.ts +91 -0
- package/dist/render/text.js +44 -0
- package/dist/render/theme.d.ts +61 -0
- package/dist/render/theme.js +52 -0
- package/dist/reserved-props.d.ts +35 -0
- package/dist/reserved-props.js +45 -0
- package/dist/result.d.ts +27 -0
- package/dist/result.js +30 -0
- package/dist/role.d.ts +71 -0
- package/dist/role.js +22 -0
- package/dist/runtime/analysis.d.ts +149 -0
- package/dist/runtime/analysis.js +187 -0
- package/dist/runtime/assessment.d.ts +35 -0
- package/dist/runtime/assessment.js +13 -0
- package/dist/runtime/disposition.d.ts +102 -0
- package/dist/runtime/disposition.js +59 -0
- package/dist/runtime/events.d.ts +187 -0
- package/dist/runtime/events.js +7 -0
- package/dist/runtime/gate.d.ts +43 -0
- package/dist/runtime/gate.js +169 -0
- package/dist/runtime/index.d.ts +27 -0
- package/dist/runtime/index.js +27 -0
- package/dist/runtime/intent.d.ts +60 -0
- package/dist/runtime/intent.js +36 -0
- package/dist/runtime/interpreter.d.ts +117 -0
- package/dist/runtime/interpreter.js +46 -0
- package/dist/runtime/inverse-interpreter.d.ts +90 -0
- package/dist/runtime/inverse-interpreter.js +56 -0
- package/dist/runtime/inverse.d.ts +87 -0
- package/dist/runtime/inverse.js +48 -0
- package/dist/runtime/narration.d.ts +24 -0
- package/dist/runtime/narration.js +36 -0
- package/dist/runtime/nesting.d.ts +31 -0
- package/dist/runtime/nesting.js +46 -0
- package/dist/runtime/pipeline.d.ts +124 -0
- package/dist/runtime/pipeline.js +178 -0
- package/dist/runtime/policy-fingerprint.d.ts +29 -0
- package/dist/runtime/policy-fingerprint.js +119 -0
- package/dist/runtime/policy-source.d.ts +42 -0
- package/dist/runtime/policy-source.js +8 -0
- package/dist/runtime/policy.d.ts +156 -0
- package/dist/runtime/policy.js +107 -0
- package/dist/runtime/proposal.d.ts +423 -0
- package/dist/runtime/proposal.js +109 -0
- package/dist/runtime/redirection.d.ts +53 -0
- package/dist/runtime/redirection.js +38 -0
- package/dist/runtime/repointing.d.ts +71 -0
- package/dist/runtime/repointing.js +0 -0
- package/dist/runtime/reversibility.d.ts +36 -0
- package/dist/runtime/reversibility.js +39 -0
- package/dist/runtime/stake-level.d.ts +33 -0
- package/dist/runtime/stake-level.js +58 -0
- package/dist/runtime/stakes.d.ts +47 -0
- package/dist/runtime/stakes.js +305 -0
- package/dist/runtime/vocabulary.d.ts +122 -0
- package/dist/runtime/vocabulary.js +87 -0
- package/dist/sdk/audit.d.ts +195 -0
- package/dist/sdk/audit.js +128 -0
- package/dist/sdk/catalogue.d.ts +37 -0
- package/dist/sdk/catalogue.js +16 -0
- package/dist/sdk/conformance.d.ts +342 -0
- package/dist/sdk/conformance.js +494 -0
- package/dist/sdk/copy.d.ts +105 -0
- package/dist/sdk/copy.js +90 -0
- package/dist/sdk/definition.d.ts +242 -0
- package/dist/sdk/definition.js +64 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.js +19 -0
- package/dist/sdk/interactivity.d.ts +29 -0
- package/dist/sdk/interactivity.js +34 -0
- package/dist/sdk/pairings.d.ts +124 -0
- package/dist/sdk/pairings.js +81 -0
- package/dist/sdk/registry.d.ts +162 -0
- package/dist/sdk/registry.js +329 -0
- package/dist/sdk/selection.d.ts +46 -0
- package/dist/sdk/selection.js +24 -0
- package/dist/sdk/text.d.ts +100 -0
- package/dist/sdk/text.js +105 -0
- package/dist/sdk/vocabulary.d.ts +39 -0
- package/dist/sdk/vocabulary.js +36 -0
- package/dist/signals/broadcast.d.ts +134 -0
- package/dist/signals/broadcast.js +451 -0
- package/dist/signals/collect.d.ts +184 -0
- package/dist/signals/collect.js +196 -0
- package/dist/signals/deliver.d.ts +64 -0
- package/dist/signals/deliver.js +85 -0
- package/dist/signals/fold.d.ts +112 -0
- package/dist/signals/fold.js +76 -0
- package/dist/signals/index.d.ts +31 -0
- package/dist/signals/index.js +31 -0
- package/dist/signals/ingest.d.ts +51 -0
- package/dist/signals/ingest.js +70 -0
- package/dist/signals/intake.d.ts +149 -0
- package/dist/signals/intake.js +154 -0
- package/dist/signals/journal.d.ts +94 -0
- package/dist/signals/journal.js +11 -0
- package/dist/signals/kinds.d.ts +22 -0
- package/dist/signals/kinds.js +22 -0
- package/dist/signals/ledger.d.ts +46 -0
- package/dist/signals/ledger.js +81 -0
- package/dist/signals/memory.d.ts +17 -0
- package/dist/signals/memory.js +99 -0
- package/dist/signals/migrate.d.ts +27 -0
- package/dist/signals/migrate.js +78 -0
- package/dist/signals/postgres.d.ts +7 -0
- package/dist/signals/postgres.js +295 -0
- package/dist/signals/rollup.d.ts +142 -0
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +534 -0
- package/dist/signals/schema.js +92 -0
- package/dist/signals/signal.d.ts +381 -0
- package/dist/signals/signal.js +150 -0
- package/dist/signals/tally.d.ts +70 -0
- package/dist/signals/tally.js +2 -0
- package/dist/signals/view.d.ts +51 -0
- package/dist/signals/view.js +54 -0
- package/dist/store/attribution.d.ts +125 -0
- package/dist/store/attribution.js +116 -0
- package/dist/store/database.d.ts +14 -0
- package/dist/store/database.js +2 -0
- package/dist/store/driver.d.ts +29 -0
- package/dist/store/driver.js +39 -0
- package/dist/store/errors.d.ts +56 -0
- package/dist/store/errors.js +37 -0
- package/dist/store/index.d.ts +16 -0
- package/dist/store/index.js +16 -0
- package/dist/store/memory.d.ts +3 -0
- package/dist/store/memory.js +115 -0
- package/dist/store/migrate.d.ts +54 -0
- package/dist/store/migrate.js +122 -0
- package/dist/store/postgres-holds.d.ts +4 -0
- package/dist/store/postgres-holds.js +192 -0
- package/dist/store/postgres.d.ts +8 -0
- package/dist/store/postgres.js +262 -0
- package/dist/store/replay.d.ts +94 -0
- package/dist/store/replay.js +82 -0
- package/dist/store/revert.d.ts +116 -0
- package/dist/store/revert.js +243 -0
- package/dist/store/schema.d.ts +371 -0
- package/dist/store/schema.js +78 -0
- package/dist/store/source.d.ts +23 -0
- package/dist/store/source.js +37 -0
- package/dist/store/store.d.ts +231 -0
- package/dist/store/store.js +52 -0
- package/dist/store/undone.d.ts +18 -0
- package/dist/store/undone.js +89 -0
- package/dist/submit/catalogue.d.ts +20 -0
- package/dist/submit/catalogue.js +5 -0
- package/dist/submit/declaration.d.ts +39 -0
- package/dist/submit/declaration.js +30 -0
- package/dist/submit/endpoint.d.ts +131 -0
- package/dist/submit/endpoint.js +160 -0
- package/dist/submit/index.d.ts +13 -0
- package/dist/submit/index.js +13 -0
- package/dist/submit/plan.d.ts +49 -0
- package/dist/submit/plan.js +47 -0
- package/dist/submit/resolution.d.ts +61 -0
- package/dist/submit/resolution.js +64 -0
- package/dist/submit/resolve.d.ts +45 -0
- package/dist/submit/resolve.js +36 -0
- package/dist/telemetry/calibration.d.ts +132 -0
- package/dist/telemetry/calibration.js +151 -0
- package/dist/telemetry/episode.d.ts +140 -0
- package/dist/telemetry/episode.js +272 -0
- package/dist/telemetry/event.d.ts +2310 -0
- package/dist/telemetry/event.js +405 -0
- package/dist/telemetry/index.d.ts +15 -0
- package/dist/telemetry/index.js +15 -0
- package/dist/telemetry/journal.d.ts +116 -0
- package/dist/telemetry/journal.js +11 -0
- package/dist/telemetry/memory.d.ts +24 -0
- package/dist/telemetry/memory.js +75 -0
- package/dist/telemetry/migrate.d.ts +26 -0
- package/dist/telemetry/migrate.js +40 -0
- package/dist/telemetry/postgres.d.ts +6 -0
- package/dist/telemetry/postgres.js +139 -0
- package/dist/telemetry/retention.d.ts +131 -0
- package/dist/telemetry/retention.js +217 -0
- package/dist/telemetry/schema.d.ts +113 -0
- package/dist/telemetry/schema.js +33 -0
- package/dist/telemetry/sink.d.ts +42 -0
- package/dist/telemetry/sink.js +61 -0
- package/dist/testing/contracts.d.ts +34 -0
- package/dist/testing/contracts.js +34 -0
- package/dist/testing/definitions.d.ts +15 -0
- package/dist/testing/definitions.js +48 -0
- package/dist/testing/doubles.d.ts +94 -0
- package/dist/testing/doubles.js +141 -0
- package/dist/testing/episode-harness.d.ts +49 -0
- package/dist/testing/episode-harness.js +65 -0
- package/dist/testing/filesystem.d.ts +17 -0
- package/dist/testing/filesystem.js +17 -0
- package/dist/testing/fixtures.d.ts +57 -0
- package/dist/testing/fixtures.js +84 -0
- package/dist/testing/hold-contract.d.ts +19 -0
- package/dist/testing/hold-contract.js +374 -0
- package/dist/testing/index.d.ts +41 -0
- package/dist/testing/index.js +41 -0
- package/dist/testing/journal-contract.d.ts +17 -0
- package/dist/testing/journal-contract.js +353 -0
- package/dist/testing/model-replies.d.ts +34 -0
- package/dist/testing/model-replies.js +101 -0
- package/dist/testing/primitives.d.ts +7 -0
- package/dist/testing/primitives.js +29 -0
- package/dist/testing/reader-signal-contract.d.ts +38 -0
- package/dist/testing/reader-signal-contract.js +318 -0
- package/dist/testing/row-security.d.ts +17 -0
- package/dist/testing/row-security.js +21 -0
- package/dist/testing/store-contract.d.ts +25 -0
- package/dist/testing/store-contract.js +500 -0
- package/dist/theme/apply.d.ts +17 -0
- package/dist/theme/apply.js +60 -0
- package/dist/theme/contrast.d.ts +197 -0
- package/dist/theme/contrast.js +259 -0
- package/dist/theme/derive.d.ts +77 -0
- package/dist/theme/derive.js +167 -0
- package/dist/theme/faces.d.ts +73 -0
- package/dist/theme/faces.js +119 -0
- package/dist/theme/font-packs.d.ts +25 -0
- package/dist/theme/font-packs.js +257 -0
- package/dist/theme/index.d.ts +20 -0
- package/dist/theme/index.js +20 -0
- package/dist/theme/lab.d.ts +30 -0
- package/dist/theme/lab.js +46 -0
- package/dist/theme/library.d.ts +114 -0
- package/dist/theme/library.js +300 -0
- package/dist/theme/measure.d.ts +144 -0
- package/dist/theme/measure.js +145 -0
- package/dist/theme/palettes.d.ts +64 -0
- package/dist/theme/palettes.js +497 -0
- package/dist/theme/registry.d.ts +59 -0
- package/dist/theme/registry.js +60 -0
- package/dist/theme/separation.d.ts +177 -0
- package/dist/theme/separation.js +203 -0
- package/dist/theme/style-presets.d.ts +60 -0
- package/dist/theme/style-presets.js +124 -0
- package/dist/theme/theme.d.ts +253 -0
- package/dist/theme/theme.js +171 -0
- package/dist/tree/apply.d.ts +16 -0
- package/dist/tree/apply.js +104 -0
- package/dist/tree/builders.d.ts +19 -0
- package/dist/tree/builders.js +20 -0
- package/dist/tree/compare.d.ts +68 -0
- package/dist/tree/compare.js +75 -0
- package/dist/tree/configuration.d.ts +25 -0
- package/dist/tree/configuration.js +108 -0
- package/dist/tree/delta.d.ts +288 -0
- package/dist/tree/delta.js +88 -0
- package/dist/tree/errors.d.ts +69 -0
- package/dist/tree/errors.js +34 -0
- package/dist/tree/identity.d.ts +117 -0
- package/dist/tree/identity.js +145 -0
- package/dist/tree/index.d.ts +21 -0
- package/dist/tree/index.js +21 -0
- package/dist/tree/inverse.d.ts +24 -0
- package/dist/tree/inverse.js +112 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +49 -0
- package/dist/tree/naming.d.ts +4 -0
- package/dist/tree/naming.js +35 -0
- package/dist/tree/navigation.d.ts +38 -0
- package/dist/tree/navigation.js +83 -0
- package/dist/tree/node.d.ts +103 -0
- package/dist/tree/node.js +46 -0
- package/dist/tree/outline.d.ts +28 -0
- package/dist/tree/outline.js +10 -0
- package/dist/tree/tree.d.ts +83 -0
- package/dist/tree/tree.js +62 -0
- package/dist/write/commit.d.ts +124 -0
- package/dist/write/commit.js +234 -0
- package/dist/write/held.d.ts +674 -0
- package/dist/write/held.js +185 -0
- package/dist/write/index.d.ts +11 -0
- package/dist/write/index.js +11 -0
- package/dist/write/liveness.d.ts +132 -0
- package/dist/write/liveness.js +91 -0
- package/dist/write/revert.d.ts +79 -0
- package/dist/write/revert.js +134 -0
- package/package.json +160 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { Palette, PaletteSlot, ThemeId } from "./theme.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether two slots a reader is meant to tell apart are far enough apart to be
|
|
4
|
+
* told apart. The other half of what a palette owes a page.
|
|
5
|
+
*
|
|
6
|
+
* `contrast.ts` measures an ink against the ground behind it, which is
|
|
7
|
+
* legibility: can this be read at all. Nothing measured **difference between
|
|
8
|
+
* two slots a reader is meant to distinguish from each other** — a stressed
|
|
9
|
+
* word beside the words either side of it, a link inside the paragraph it sits
|
|
10
|
+
* in, a quiet note under a less quiet one. Both are the palette's promise and
|
|
11
|
+
* only one of them was checked.
|
|
12
|
+
*
|
|
13
|
+
* The gap was found the expensive way, on 23 August: `loom.emphasis` asked for
|
|
14
|
+
* `weight("heading")`, got a font pack that declares the same weight for
|
|
15
|
+
* headings and body, and rendered a stressed word identical to its neighbours.
|
|
16
|
+
* Every test passed, because every test asked whether the token was real. The
|
|
17
|
+
* lesson generalises past that instance and is the reason this module exists:
|
|
18
|
+
* **a token is a promise about provenance, not about difference.**
|
|
19
|
+
*
|
|
20
|
+
* ## Why this is not a second contrast bar
|
|
21
|
+
*
|
|
22
|
+
* A contrast ratio compares luminance, and two slots can differ in hue while
|
|
23
|
+
* matching in luminance — 1.00:1 and plainly different colours. Asking WCAG's
|
|
24
|
+
* question here would report a pair as identical that a reader distinguishes at
|
|
25
|
+
* a glance, and would miss a pair that differs in luminance alone by less than
|
|
26
|
+
* an eye can resolve.
|
|
27
|
+
*
|
|
28
|
+
* So this measures CIELAB ΔE, and the threshold is **borrowed rather than
|
|
29
|
+
* invented**, which is what 0089 said the missing check would have to manage:
|
|
30
|
+
* the just-noticeable difference is a published property of human vision, not a
|
|
31
|
+
* number chosen to fit these palettes.
|
|
32
|
+
*
|
|
33
|
+
* It reports; it does not decide — the bargain `auditPalette` and
|
|
34
|
+
* `auditRegistry` both make, for the same reason (0076).
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* ΔE below which two colours are the same colour to a reader.
|
|
38
|
+
*
|
|
39
|
+
* The conventional just-noticeable difference for CIE76 under controlled
|
|
40
|
+
* viewing. It is a floor and not a target: a pair at 2.4 is technically
|
|
41
|
+
* distinguishable and is not *distinct*, which is why what this module asserts
|
|
42
|
+
* is that nothing falls under it rather than that everything comfortably clears
|
|
43
|
+
* it.
|
|
44
|
+
*
|
|
45
|
+
* CIE76 is used rather than CIEDE2000 deliberately. It is known to overstate
|
|
46
|
+
* differences among saturated blues, and it is twelve lines that a reader can
|
|
47
|
+
* check against the formula — where CIEDE2000 is a page of rotation terms
|
|
48
|
+
* nobody reviewing a palette would verify. The error runs in the safe
|
|
49
|
+
* direction for the one thing asserted here: a pair CIE76 calls collapsed is
|
|
50
|
+
* collapsed under any metric.
|
|
51
|
+
*/
|
|
52
|
+
export declare const JUST_NOTICEABLE_DIFFERENCE = 2.3;
|
|
53
|
+
/**
|
|
54
|
+
* The CIE76 colour difference between two colours, or `undefined` when either
|
|
55
|
+
* is a form `channelsOf` declines to guess at.
|
|
56
|
+
*
|
|
57
|
+
* The conversion is `lab.ts`'s, shared with the module that measures how much
|
|
58
|
+
* colour a single slot has: both are distances in the same space, and two
|
|
59
|
+
* copies of it would be two answers to where a colour sits.
|
|
60
|
+
*/
|
|
61
|
+
export declare const colourDifference: (a: string, b: string) => number | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* How the reader is told the two apart, which decides what a collapse means.
|
|
64
|
+
*
|
|
65
|
+
* **`colour-only`** — nothing but the colour separates them where they meet. A
|
|
66
|
+
* palette that collapses one has a page in it where two different things look
|
|
67
|
+
* like one thing, and no tree can avoid it.
|
|
68
|
+
*
|
|
69
|
+
* **`also-marked`** — a rule, a border or an outline separates them as well, so
|
|
70
|
+
* the two colours are free to be equal. `minimal` is the argument for this
|
|
71
|
+
* basis existing: its `bg-surface` *is* its `bg-canvas`, deliberately, because
|
|
72
|
+
* every card in that palette is defined by its border. What is asserted for
|
|
73
|
+
* these is the weaker and still real claim — the mark itself has to be visible
|
|
74
|
+
* against both.
|
|
75
|
+
*/
|
|
76
|
+
export type PeerBasis = "colour-only" | "also-marked";
|
|
77
|
+
type PeerBase = {
|
|
78
|
+
readonly first: PaletteSlot;
|
|
79
|
+
readonly second: PaletteSlot;
|
|
80
|
+
/** Where a reader meets them together, so a collapse names a page. */
|
|
81
|
+
readonly where: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Two slots a reader is meant to tell apart, and what tells them apart.
|
|
85
|
+
*
|
|
86
|
+
* A discriminated union rather than an optional field, so an `also-marked`
|
|
87
|
+
* peer cannot be declared without naming the mark that does the marking. A
|
|
88
|
+
* claim that something else carries the pair is only worth making if the
|
|
89
|
+
* something else can be measured too.
|
|
90
|
+
*/
|
|
91
|
+
export type PeerPairing = (PeerBase & {
|
|
92
|
+
readonly basis: "colour-only";
|
|
93
|
+
}) | (PeerBase & {
|
|
94
|
+
readonly basis: "also-marked";
|
|
95
|
+
readonly mark: PaletteSlot;
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* The pairs the library actually asks a reader to distinguish.
|
|
99
|
+
*
|
|
100
|
+
* Declared rather than derived, and that is not the compromise it looks like.
|
|
101
|
+
* A probe can see that `loom.link` sets `accent` inside a `loom.prose` that set
|
|
102
|
+
* `fg-default`; nothing in either component says the reader is *meant* to tell
|
|
103
|
+
* them apart, because that is what the two mean rather than what they render —
|
|
104
|
+
* the same thing `PALETTE_TEXT_GROUNDS` has to declare, for the same reason
|
|
105
|
+
* (0089).
|
|
106
|
+
*
|
|
107
|
+
* Two rules keep the list honest, both borrowed from `PALETTE_TEXT_PAIRINGS`:
|
|
108
|
+
* every row names somewhere the library really puts the two together, and
|
|
109
|
+
* **nothing may be demoted.** A pair that is `colour-only` in any place where
|
|
110
|
+
* the boundary is what the reader reads is `colour-only` here, whatever else
|
|
111
|
+
* marks it elsewhere: `loom.card` outlines its surface, and `loom.section
|
|
112
|
+
* tone="surface"` paints the same fill on the same canvas with no border at
|
|
113
|
+
* all, so the pair answers for the section. Where two primitives mark a pair
|
|
114
|
+
* with different rules, the row names the fainter of them.
|
|
115
|
+
*
|
|
116
|
+
* *Where the boundary is what the reader reads* is doing real work in that
|
|
117
|
+
* sentence and is a judgement rather than a derivation. `loom.avatar` and
|
|
118
|
+
* `loom.media` paint the muted well on an unbordered ground too, and they are
|
|
119
|
+
* not why those rows exist: what a reader is meant to see in an avatar is the
|
|
120
|
+
* monogram and in a media frame is the picture, and the ink and the picture are
|
|
121
|
+
* held to their own bars elsewhere. A well whose edge nobody looks for is not a
|
|
122
|
+
* pair anybody is being asked to tell apart.
|
|
123
|
+
*/
|
|
124
|
+
export declare const PALETTE_PEER_PAIRINGS: readonly PeerPairing[];
|
|
125
|
+
/** A peer that was measured, whether or not it came apart. */
|
|
126
|
+
export type MeasuredPeer = {
|
|
127
|
+
readonly pairing: PeerPairing;
|
|
128
|
+
readonly difference: number;
|
|
129
|
+
/**
|
|
130
|
+
* How far the mark is from whichever of the two it is nearer to — the mark's
|
|
131
|
+
* worst case, since it has to be visible against both.
|
|
132
|
+
*
|
|
133
|
+
* `undefined` for a `colour-only` peer, which has no mark, and for a mark
|
|
134
|
+
* written in a form this cannot measure. The second case judges the pair on
|
|
135
|
+
* its colours alone, which is the safe direction: a defence that cannot be
|
|
136
|
+
* measured is not counted as one.
|
|
137
|
+
*/
|
|
138
|
+
readonly markDifference: number | undefined;
|
|
139
|
+
readonly separated: boolean;
|
|
140
|
+
};
|
|
141
|
+
/** A peer whose colours could not be measured, and which colour stopped it. */
|
|
142
|
+
export type UnmeasuredPeer = {
|
|
143
|
+
readonly pairing: PeerPairing;
|
|
144
|
+
readonly first: string;
|
|
145
|
+
readonly second: string;
|
|
146
|
+
};
|
|
147
|
+
/** What one palette does with the pairs its reader has to tell apart. */
|
|
148
|
+
export type PaletteSeparation = {
|
|
149
|
+
readonly palette: ThemeId;
|
|
150
|
+
readonly measured: readonly MeasuredPeer[];
|
|
151
|
+
/**
|
|
152
|
+
* Colour-only peers under the threshold: two things that look like one thing,
|
|
153
|
+
* with nothing else to go on. The list a host asserts empty.
|
|
154
|
+
*/
|
|
155
|
+
readonly collapsed: readonly MeasuredPeer[];
|
|
156
|
+
/**
|
|
157
|
+
* Marked peers whose colours have collapsed **and** whose mark has too — a
|
|
158
|
+
* card that is neither filled nor outlined. Separate from `collapsed` because
|
|
159
|
+
* it is a different defect with a different fix, and because a marked pair
|
|
160
|
+
* whose mark is doing its job is not a defect at all.
|
|
161
|
+
*/
|
|
162
|
+
readonly unmarked: readonly MeasuredPeer[];
|
|
163
|
+
/** Neither separated nor collapsed: a colour this cannot measure. */
|
|
164
|
+
readonly unmeasured: readonly UnmeasuredPeer[];
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Measures every declared peer in one palette. Refuses nothing.
|
|
168
|
+
*
|
|
169
|
+
* `peers` defaults to the pairs Loom's own library puts in front of a reader. A
|
|
170
|
+
* host with its own primitives declares its own, the way it passes its own
|
|
171
|
+
* pairings to `auditPalette`.
|
|
172
|
+
*/
|
|
173
|
+
export declare const auditSeparation: (palette: Palette, peers?: readonly PeerPairing[]) => PaletteSeparation;
|
|
174
|
+
/** One line per problem, for a CLI or a failing test's message. Empty when clean. */
|
|
175
|
+
export declare const describeSeparationAudit: (audit: PaletteSeparation) => string;
|
|
176
|
+
export {};
|
|
177
|
+
//# sourceMappingURL=separation.d.ts.map
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { labOf } from "./lab.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether two slots a reader is meant to tell apart are far enough apart to be
|
|
4
|
+
* told apart. The other half of what a palette owes a page.
|
|
5
|
+
*
|
|
6
|
+
* `contrast.ts` measures an ink against the ground behind it, which is
|
|
7
|
+
* legibility: can this be read at all. Nothing measured **difference between
|
|
8
|
+
* two slots a reader is meant to distinguish from each other** — a stressed
|
|
9
|
+
* word beside the words either side of it, a link inside the paragraph it sits
|
|
10
|
+
* in, a quiet note under a less quiet one. Both are the palette's promise and
|
|
11
|
+
* only one of them was checked.
|
|
12
|
+
*
|
|
13
|
+
* The gap was found the expensive way, on 23 August: `loom.emphasis` asked for
|
|
14
|
+
* `weight("heading")`, got a font pack that declares the same weight for
|
|
15
|
+
* headings and body, and rendered a stressed word identical to its neighbours.
|
|
16
|
+
* Every test passed, because every test asked whether the token was real. The
|
|
17
|
+
* lesson generalises past that instance and is the reason this module exists:
|
|
18
|
+
* **a token is a promise about provenance, not about difference.**
|
|
19
|
+
*
|
|
20
|
+
* ## Why this is not a second contrast bar
|
|
21
|
+
*
|
|
22
|
+
* A contrast ratio compares luminance, and two slots can differ in hue while
|
|
23
|
+
* matching in luminance — 1.00:1 and plainly different colours. Asking WCAG's
|
|
24
|
+
* question here would report a pair as identical that a reader distinguishes at
|
|
25
|
+
* a glance, and would miss a pair that differs in luminance alone by less than
|
|
26
|
+
* an eye can resolve.
|
|
27
|
+
*
|
|
28
|
+
* So this measures CIELAB ΔE, and the threshold is **borrowed rather than
|
|
29
|
+
* invented**, which is what 0089 said the missing check would have to manage:
|
|
30
|
+
* the just-noticeable difference is a published property of human vision, not a
|
|
31
|
+
* number chosen to fit these palettes.
|
|
32
|
+
*
|
|
33
|
+
* It reports; it does not decide — the bargain `auditPalette` and
|
|
34
|
+
* `auditRegistry` both make, for the same reason (0076).
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* ΔE below which two colours are the same colour to a reader.
|
|
38
|
+
*
|
|
39
|
+
* The conventional just-noticeable difference for CIE76 under controlled
|
|
40
|
+
* viewing. It is a floor and not a target: a pair at 2.4 is technically
|
|
41
|
+
* distinguishable and is not *distinct*, which is why what this module asserts
|
|
42
|
+
* is that nothing falls under it rather than that everything comfortably clears
|
|
43
|
+
* it.
|
|
44
|
+
*
|
|
45
|
+
* CIE76 is used rather than CIEDE2000 deliberately. It is known to overstate
|
|
46
|
+
* differences among saturated blues, and it is twelve lines that a reader can
|
|
47
|
+
* check against the formula — where CIEDE2000 is a page of rotation terms
|
|
48
|
+
* nobody reviewing a palette would verify. The error runs in the safe
|
|
49
|
+
* direction for the one thing asserted here: a pair CIE76 calls collapsed is
|
|
50
|
+
* collapsed under any metric.
|
|
51
|
+
*/
|
|
52
|
+
export const JUST_NOTICEABLE_DIFFERENCE = 2.3;
|
|
53
|
+
/**
|
|
54
|
+
* The CIE76 colour difference between two colours, or `undefined` when either
|
|
55
|
+
* is a form `channelsOf` declines to guess at.
|
|
56
|
+
*
|
|
57
|
+
* The conversion is `lab.ts`'s, shared with the module that measures how much
|
|
58
|
+
* colour a single slot has: both are distances in the same space, and two
|
|
59
|
+
* copies of it would be two answers to where a colour sits.
|
|
60
|
+
*/
|
|
61
|
+
export const colourDifference = (a, b) => {
|
|
62
|
+
const [first, second] = [a, b].map(labOf);
|
|
63
|
+
if (!first || !second)
|
|
64
|
+
return undefined;
|
|
65
|
+
const [lightness, green, blue] = first;
|
|
66
|
+
const [otherLightness, otherGreen, otherBlue] = second;
|
|
67
|
+
return Math.sqrt((lightness - otherLightness) ** 2 + (green - otherGreen) ** 2 + (blue - otherBlue) ** 2);
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The pairs the library actually asks a reader to distinguish.
|
|
71
|
+
*
|
|
72
|
+
* Declared rather than derived, and that is not the compromise it looks like.
|
|
73
|
+
* A probe can see that `loom.link` sets `accent` inside a `loom.prose` that set
|
|
74
|
+
* `fg-default`; nothing in either component says the reader is *meant* to tell
|
|
75
|
+
* them apart, because that is what the two mean rather than what they render —
|
|
76
|
+
* the same thing `PALETTE_TEXT_GROUNDS` has to declare, for the same reason
|
|
77
|
+
* (0089).
|
|
78
|
+
*
|
|
79
|
+
* Two rules keep the list honest, both borrowed from `PALETTE_TEXT_PAIRINGS`:
|
|
80
|
+
* every row names somewhere the library really puts the two together, and
|
|
81
|
+
* **nothing may be demoted.** A pair that is `colour-only` in any place where
|
|
82
|
+
* the boundary is what the reader reads is `colour-only` here, whatever else
|
|
83
|
+
* marks it elsewhere: `loom.card` outlines its surface, and `loom.section
|
|
84
|
+
* tone="surface"` paints the same fill on the same canvas with no border at
|
|
85
|
+
* all, so the pair answers for the section. Where two primitives mark a pair
|
|
86
|
+
* with different rules, the row names the fainter of them.
|
|
87
|
+
*
|
|
88
|
+
* *Where the boundary is what the reader reads* is doing real work in that
|
|
89
|
+
* sentence and is a judgement rather than a derivation. `loom.avatar` and
|
|
90
|
+
* `loom.media` paint the muted well on an unbordered ground too, and they are
|
|
91
|
+
* not why those rows exist: what a reader is meant to see in an avatar is the
|
|
92
|
+
* monogram and in a media frame is the picture, and the ink and the picture are
|
|
93
|
+
* held to their own bars elsewhere. A well whose edge nobody looks for is not a
|
|
94
|
+
* pair anybody is being asked to tell apart.
|
|
95
|
+
*/
|
|
96
|
+
export const PALETTE_PEER_PAIRINGS = [
|
|
97
|
+
{
|
|
98
|
+
first: "fg-default",
|
|
99
|
+
second: "fg-muted",
|
|
100
|
+
basis: "colour-only",
|
|
101
|
+
where: "loom.prose tone muted under a default one",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
first: "fg-muted",
|
|
105
|
+
second: "fg-subtle",
|
|
106
|
+
basis: "colour-only",
|
|
107
|
+
where: "loom.tier note under its body, loom.milestone",
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* The row that fails, and the reason the module is worth its tests. A
|
|
111
|
+
* `loom.link` in a paragraph is `accent` on the `fg-default` around it, at
|
|
112
|
+
* rest with no underline — the wipe-in rule arrives on hover — and no
|
|
113
|
+
* difference in weight. Colour is the whole of the signal.
|
|
114
|
+
*/
|
|
115
|
+
{
|
|
116
|
+
first: "fg-default",
|
|
117
|
+
second: "accent",
|
|
118
|
+
basis: "colour-only",
|
|
119
|
+
where: "loom.link tone accent inside a paragraph",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
first: "bg-canvas",
|
|
123
|
+
second: "bg-surface",
|
|
124
|
+
basis: "colour-only",
|
|
125
|
+
where: "loom.section tone surface, which paints a band and no border",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
first: "bg-canvas",
|
|
129
|
+
second: "accent-subtle",
|
|
130
|
+
basis: "colour-only",
|
|
131
|
+
where: "loom.section tone accent, likewise",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
first: "bg-surface",
|
|
135
|
+
second: "bg-surface-muted",
|
|
136
|
+
basis: "also-marked",
|
|
137
|
+
mark: "border-subtle",
|
|
138
|
+
where: "loom.code panel inside a card",
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
first: "bg-canvas",
|
|
142
|
+
second: "bg-surface-muted",
|
|
143
|
+
basis: "also-marked",
|
|
144
|
+
mark: "border-subtle",
|
|
145
|
+
where: "loom.code panel on a page; loom.callout marks the same pair harder",
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
const markOf = (pairing) => pairing.basis === "also-marked" ? pairing.mark : undefined;
|
|
149
|
+
/**
|
|
150
|
+
* How far a mark is from the *nearer* of the two it separates.
|
|
151
|
+
*
|
|
152
|
+
* The worst of the two rather than the average, because a rule that disappears
|
|
153
|
+
* into one side of the boundary it draws has stopped drawing it.
|
|
154
|
+
*/
|
|
155
|
+
const markSeparation = (mark, first, second) => {
|
|
156
|
+
const toFirst = colourDifference(mark, first);
|
|
157
|
+
const toSecond = colourDifference(mark, second);
|
|
158
|
+
return toFirst === undefined || toSecond === undefined ? undefined : Math.min(toFirst, toSecond);
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Measures every declared peer in one palette. Refuses nothing.
|
|
162
|
+
*
|
|
163
|
+
* `peers` defaults to the pairs Loom's own library puts in front of a reader. A
|
|
164
|
+
* host with its own primitives declares its own, the way it passes its own
|
|
165
|
+
* pairings to `auditPalette`.
|
|
166
|
+
*/
|
|
167
|
+
export const auditSeparation = (palette, peers = PALETTE_PEER_PAIRINGS) => {
|
|
168
|
+
const results = peers.map((pairing) => {
|
|
169
|
+
const first = palette.slots[pairing.first] ?? "";
|
|
170
|
+
const second = palette.slots[pairing.second] ?? "";
|
|
171
|
+
const difference = colourDifference(first, second);
|
|
172
|
+
if (difference === undefined)
|
|
173
|
+
return { unmeasured: { pairing, first, second } };
|
|
174
|
+
const mark = markOf(pairing);
|
|
175
|
+
const markDifference = mark === undefined ? undefined : markSeparation(palette.slots[mark] ?? "", first, second);
|
|
176
|
+
return {
|
|
177
|
+
measured: {
|
|
178
|
+
pairing,
|
|
179
|
+
difference,
|
|
180
|
+
markDifference,
|
|
181
|
+
separated: difference >= JUST_NOTICEABLE_DIFFERENCE ||
|
|
182
|
+
(markDifference !== undefined && markDifference >= JUST_NOTICEABLE_DIFFERENCE),
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
const measured = results.flatMap((result) => (result.measured ? [result.measured] : []));
|
|
187
|
+
const apart = measured.filter((entry) => !entry.separated);
|
|
188
|
+
return {
|
|
189
|
+
palette: palette.id,
|
|
190
|
+
measured,
|
|
191
|
+
collapsed: apart.filter((entry) => entry.pairing.basis === "colour-only"),
|
|
192
|
+
unmarked: apart.filter((entry) => entry.pairing.basis === "also-marked"),
|
|
193
|
+
unmeasured: results.flatMap((result) => (result.unmeasured ? [result.unmeasured] : [])),
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
const describePeer = (pairing) => `${pairing.first} and ${pairing.second} (${pairing.where})`;
|
|
197
|
+
/** One line per problem, for a CLI or a failing test's message. Empty when clean. */
|
|
198
|
+
export const describeSeparationAudit = (audit) => [
|
|
199
|
+
...audit.collapsed.map((entry) => `${audit.palette}: ${describePeer(entry.pairing)} differ by ${entry.difference.toFixed(2)}, under ${JUST_NOTICEABLE_DIFFERENCE} — nothing else tells them apart`),
|
|
200
|
+
...audit.unmarked.map((entry) => `${audit.palette}: ${describePeer(entry.pairing)} differ by ${entry.difference.toFixed(2)} and their mark by ${(entry.markDifference ?? 0).toFixed(2)}, both under ${JUST_NOTICEABLE_DIFFERENCE}`),
|
|
201
|
+
...audit.unmeasured.map((entry) => `${audit.palette}: ${describePeer(entry.pairing)} could not be measured — "${entry.first}" and "${entry.second}" are not both hex`),
|
|
202
|
+
].join("\n");
|
|
203
|
+
//# sourceMappingURL=separation.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type StylePreset } from "./theme.js";
|
|
2
|
+
/**
|
|
3
|
+
* The seven style presets the starter library ships beyond the first three, and
|
|
4
|
+
* the reason there are seven rather than seventeen.
|
|
5
|
+
*
|
|
6
|
+
* A preset is four radii, eight spacing steps, three durations and a density
|
|
7
|
+
* word. That is a small space, and past about ten entries the differences stop
|
|
8
|
+
* being differences: two presets whose spacing ramps differ by two pixels
|
|
9
|
+
* render pages nobody can tell apart, and a model choosing between them is
|
|
10
|
+
* choosing noise it will be graded on. Ten is where this library stops, and the
|
|
11
|
+
* axes below are what the ten actually vary — each preset moves on at least one
|
|
12
|
+
* of them by an amount a person can see.
|
|
13
|
+
*
|
|
14
|
+
* | axis | range |
|
|
15
|
+
* | --- | --- |
|
|
16
|
+
* | **spacing** | tight (a dense application) → generous (a landing page) |
|
|
17
|
+
* | **radius** | square → soft → pill |
|
|
18
|
+
* | **motion** | brisk (~120ms) → calm (~500ms) |
|
|
19
|
+
*
|
|
20
|
+
* ## What the numbers actually do
|
|
21
|
+
*
|
|
22
|
+
* **The spacing ramp is not linear, and should not be.** Steps 1–4 are the
|
|
23
|
+
* distances inside a component — a gap between a label and its input, the
|
|
24
|
+
* padding in a button — and steps 5–8 are the distances between them: a card's
|
|
25
|
+
* interior, the space under a band, the gap between sections. A ramp that
|
|
26
|
+
* doubles evenly gives a page where a paragraph and a section are separated by
|
|
27
|
+
* the same rhythm, which reads as a wireframe. Every ramp here grows slowly at
|
|
28
|
+
* the bottom and quickly at the top.
|
|
29
|
+
*
|
|
30
|
+
* **`full` is a pill, not a circle.** `loom.action`, `loom.button` and
|
|
31
|
+
* `loom.badge` read `--loom-radius-full` for their own shape, so a preset that
|
|
32
|
+
* set it to `0` would square off every control on the page. The square-cornered
|
|
33
|
+
* presets below do exactly that on purpose — it is the whole of their look —
|
|
34
|
+
* and it is worth knowing that is what the number reaches.
|
|
35
|
+
*
|
|
36
|
+
* **Motion is read by the stylesheet the primitives emit** (0055), and `slow`
|
|
37
|
+
* is multiplied: `loom.hero`'s entrance runs at `slow × 1.6` and its aurora
|
|
38
|
+
* drifts at `slow × 40`. A preset with a 600ms `slow` gives a hero that takes
|
|
39
|
+
* most of a second to arrive, which is stately at the top of a landing page and
|
|
40
|
+
* unbearable on a page a reader is working in. Anything under ~150ms reads as
|
|
41
|
+
* an instant cut rather than as motion — deliberate for the two brisk presets.
|
|
42
|
+
* Reduced motion removes all of it regardless.
|
|
43
|
+
*
|
|
44
|
+
* `density` is emitted as `--loom-density` and nothing in this library reads
|
|
45
|
+
* it: it is there for a host's own components to key off the same choice the
|
|
46
|
+
* tree made. Set honestly anyway, since something downstream will trust it.
|
|
47
|
+
*/
|
|
48
|
+
export declare const editorialPrintStylePreset: StylePreset;
|
|
49
|
+
export declare const brutalistStylePreset: StylePreset;
|
|
50
|
+
export declare const softStylePreset: StylePreset;
|
|
51
|
+
export declare const compactStylePreset: StylePreset;
|
|
52
|
+
export declare const technicalStylePreset: StylePreset;
|
|
53
|
+
export declare const showcaseStylePreset: StylePreset;
|
|
54
|
+
export declare const cardStylePreset: StylePreset;
|
|
55
|
+
/**
|
|
56
|
+
* In catalogue order, from the most neutral to the most committed: a model
|
|
57
|
+
* reading down the list meets `card` and `technical` before `brutalist`.
|
|
58
|
+
*/
|
|
59
|
+
export declare const ADDITIONAL_STYLE_PRESETS: readonly StylePreset[];
|
|
60
|
+
//# sourceMappingURL=style-presets.d.ts.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { stylePresetSchema } from "./theme.js";
|
|
2
|
+
/**
|
|
3
|
+
* The seven style presets the starter library ships beyond the first three, and
|
|
4
|
+
* the reason there are seven rather than seventeen.
|
|
5
|
+
*
|
|
6
|
+
* A preset is four radii, eight spacing steps, three durations and a density
|
|
7
|
+
* word. That is a small space, and past about ten entries the differences stop
|
|
8
|
+
* being differences: two presets whose spacing ramps differ by two pixels
|
|
9
|
+
* render pages nobody can tell apart, and a model choosing between them is
|
|
10
|
+
* choosing noise it will be graded on. Ten is where this library stops, and the
|
|
11
|
+
* axes below are what the ten actually vary — each preset moves on at least one
|
|
12
|
+
* of them by an amount a person can see.
|
|
13
|
+
*
|
|
14
|
+
* | axis | range |
|
|
15
|
+
* | --- | --- |
|
|
16
|
+
* | **spacing** | tight (a dense application) → generous (a landing page) |
|
|
17
|
+
* | **radius** | square → soft → pill |
|
|
18
|
+
* | **motion** | brisk (~120ms) → calm (~500ms) |
|
|
19
|
+
*
|
|
20
|
+
* ## What the numbers actually do
|
|
21
|
+
*
|
|
22
|
+
* **The spacing ramp is not linear, and should not be.** Steps 1–4 are the
|
|
23
|
+
* distances inside a component — a gap between a label and its input, the
|
|
24
|
+
* padding in a button — and steps 5–8 are the distances between them: a card's
|
|
25
|
+
* interior, the space under a band, the gap between sections. A ramp that
|
|
26
|
+
* doubles evenly gives a page where a paragraph and a section are separated by
|
|
27
|
+
* the same rhythm, which reads as a wireframe. Every ramp here grows slowly at
|
|
28
|
+
* the bottom and quickly at the top.
|
|
29
|
+
*
|
|
30
|
+
* **`full` is a pill, not a circle.** `loom.action`, `loom.button` and
|
|
31
|
+
* `loom.badge` read `--loom-radius-full` for their own shape, so a preset that
|
|
32
|
+
* set it to `0` would square off every control on the page. The square-cornered
|
|
33
|
+
* presets below do exactly that on purpose — it is the whole of their look —
|
|
34
|
+
* and it is worth knowing that is what the number reaches.
|
|
35
|
+
*
|
|
36
|
+
* **Motion is read by the stylesheet the primitives emit** (0055), and `slow`
|
|
37
|
+
* is multiplied: `loom.hero`'s entrance runs at `slow × 1.6` and its aurora
|
|
38
|
+
* drifts at `slow × 40`. A preset with a 600ms `slow` gives a hero that takes
|
|
39
|
+
* most of a second to arrive, which is stately at the top of a landing page and
|
|
40
|
+
* unbearable on a page a reader is working in. Anything under ~150ms reads as
|
|
41
|
+
* an instant cut rather than as motion — deliberate for the two brisk presets.
|
|
42
|
+
* Reduced motion removes all of it regardless.
|
|
43
|
+
*
|
|
44
|
+
* `density` is emitted as `--loom-density` and nothing in this library reads
|
|
45
|
+
* it: it is there for a host's own components to key off the same choice the
|
|
46
|
+
* tree made. Set honestly anyway, since something downstream will trust it.
|
|
47
|
+
*/
|
|
48
|
+
export const editorialPrintStylePreset = stylePresetSchema.parse({
|
|
49
|
+
id: "editorial-print",
|
|
50
|
+
name: "Editorial Print",
|
|
51
|
+
description: "Square corners, generous spacing, and almost no motion. A page that behaves like paper.",
|
|
52
|
+
radii: { sm: 0, md: 0, lg: 0, full: 0 },
|
|
53
|
+
spacingScale: [4, 8, 14, 22, 36, 56, 80, 120],
|
|
54
|
+
motion: { fast: 120, medium: 200, slow: 320 },
|
|
55
|
+
density: "spacious",
|
|
56
|
+
});
|
|
57
|
+
export const brutalistStylePreset = stylePresetSchema.parse({
|
|
58
|
+
id: "brutalist",
|
|
59
|
+
name: "Brutalist",
|
|
60
|
+
description: "Square corners, tight spacing, and motion fast enough to read as a cut. Nothing is softened.",
|
|
61
|
+
radii: { sm: 0, md: 0, lg: 0, full: 0 },
|
|
62
|
+
spacingScale: [4, 8, 12, 16, 24, 36, 52, 72],
|
|
63
|
+
motion: { fast: 80, medium: 120, slow: 180 },
|
|
64
|
+
density: "compact",
|
|
65
|
+
});
|
|
66
|
+
export const softStylePreset = stylePresetSchema.parse({
|
|
67
|
+
id: "soft",
|
|
68
|
+
name: "Soft",
|
|
69
|
+
description: "Large radii, roomy spacing and calm motion. Everything is rounded and nothing is in a hurry.",
|
|
70
|
+
radii: { sm: 10, md: 18, lg: 32, full: 9999 },
|
|
71
|
+
spacingScale: [4, 10, 16, 24, 38, 58, 84, 124],
|
|
72
|
+
motion: { fast: 200, medium: 320, slow: 500 },
|
|
73
|
+
density: "spacious",
|
|
74
|
+
});
|
|
75
|
+
export const compactStylePreset = stylePresetSchema.parse({
|
|
76
|
+
id: "compact",
|
|
77
|
+
name: "Compact",
|
|
78
|
+
description: "Small radii, tight spacing, brisk motion. The density of a tool someone uses all day.",
|
|
79
|
+
radii: { sm: 4, md: 6, lg: 10, full: 9999 },
|
|
80
|
+
spacingScale: [2, 6, 10, 14, 20, 30, 44, 64],
|
|
81
|
+
motion: { fast: 100, medium: 160, slow: 240 },
|
|
82
|
+
density: "compact",
|
|
83
|
+
});
|
|
84
|
+
export const technicalStylePreset = stylePresetSchema.parse({
|
|
85
|
+
id: "technical",
|
|
86
|
+
name: "Technical",
|
|
87
|
+
description: "Barely-there radii on a strict four-pixel grid, with quick motion. Documentation and dashboards.",
|
|
88
|
+
radii: { sm: 2, md: 4, lg: 8, full: 9999 },
|
|
89
|
+
spacingScale: [4, 8, 12, 16, 24, 32, 48, 72],
|
|
90
|
+
motion: { fast: 110, medium: 180, slow: 260 },
|
|
91
|
+
density: "compact",
|
|
92
|
+
});
|
|
93
|
+
export const showcaseStylePreset = stylePresetSchema.parse({
|
|
94
|
+
id: "showcase",
|
|
95
|
+
name: "Showcase",
|
|
96
|
+
description: "The widest spacing here, medium radii and slow motion. Built for a landing page with room to breathe.",
|
|
97
|
+
radii: { sm: 8, md: 14, lg: 28, full: 9999 },
|
|
98
|
+
spacingScale: [4, 10, 18, 28, 48, 76, 112, 168],
|
|
99
|
+
motion: { fast: 180, medium: 300, slow: 460 },
|
|
100
|
+
density: "spacious",
|
|
101
|
+
});
|
|
102
|
+
export const cardStylePreset = stylePresetSchema.parse({
|
|
103
|
+
id: "card",
|
|
104
|
+
name: "Card",
|
|
105
|
+
description: "Even spacing and one consistent radius everywhere. The neutral middle, when nothing should draw attention.",
|
|
106
|
+
radii: { sm: 8, md: 12, lg: 16, full: 9999 },
|
|
107
|
+
spacingScale: [4, 8, 12, 20, 32, 48, 68, 96],
|
|
108
|
+
motion: { fast: 150, medium: 240, slow: 380 },
|
|
109
|
+
density: "comfortable",
|
|
110
|
+
});
|
|
111
|
+
/**
|
|
112
|
+
* In catalogue order, from the most neutral to the most committed: a model
|
|
113
|
+
* reading down the list meets `card` and `technical` before `brutalist`.
|
|
114
|
+
*/
|
|
115
|
+
export const ADDITIONAL_STYLE_PRESETS = [
|
|
116
|
+
cardStylePreset,
|
|
117
|
+
technicalStylePreset,
|
|
118
|
+
compactStylePreset,
|
|
119
|
+
showcaseStylePreset,
|
|
120
|
+
softStylePreset,
|
|
121
|
+
editorialPrintStylePreset,
|
|
122
|
+
brutalistStylePreset,
|
|
123
|
+
];
|
|
124
|
+
//# sourceMappingURL=style-presets.js.map
|