@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,167 @@
|
|
|
1
|
+
import { auditPalette, contrastRatio, TEXT_CONTRAST_MINIMUM } from "./contrast.js";
|
|
2
|
+
import { paletteSchema } from "./theme.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a palette that clears the bar, from three hues and a mode.
|
|
5
|
+
*
|
|
6
|
+
* `auditPalette` is the half of this pair that **reports**: it tells a host
|
|
7
|
+
* whether the colours they chose can be read. This is the half that
|
|
8
|
+
* **constructs**, and it exists because reporting is not much help on its own —
|
|
9
|
+
* a host told that four of their twelve pairings fail still has to solve twelve
|
|
10
|
+
* simultaneous contrast constraints by hand, and the usual outcome is that they
|
|
11
|
+
* lighten a background until the warning goes away and ship a page nobody
|
|
12
|
+
* looked at.
|
|
13
|
+
*
|
|
14
|
+
* The seventeen slots of a palette are not seventeen decisions. Three of them
|
|
15
|
+
* are — *what colour is the page, what colour is the ink that carries meaning,
|
|
16
|
+
* and what is the second colour* — and the rest follow by rule. So this takes
|
|
17
|
+
* the three and derives the rest, searching for a lightness that clears
|
|
18
|
+
* `TEXT_CONTRAST_MINIMUM` with a margin rather than picking one and hoping.
|
|
19
|
+
*
|
|
20
|
+
* **It is a build-time tool, not a runtime one.** The palettes this library
|
|
21
|
+
* ships are literals in `palettes.ts` — derived once, looked at, committed —
|
|
22
|
+
* because a palette is reviewed by seeing it and diffed by reading it, and a
|
|
23
|
+
* page whose colours are computed at import time is a page whose colours nobody
|
|
24
|
+
* approved. Derive, look, paste. Never call this in a render.
|
|
25
|
+
*
|
|
26
|
+
* ## The one thing it cannot do for you
|
|
27
|
+
*
|
|
28
|
+
* **It will not put a brand colour where a brand colour does not go.** `accent`
|
|
29
|
+
* is ink — eyebrows, kickers, the disclosure marker, the current nav item — so
|
|
30
|
+
* a hue given here is darkened until it can carry text, and a pale mint or a
|
|
31
|
+
* bright yellow comes back much darker than the brand book says. That is the
|
|
32
|
+
* correct answer and it is the one `minimal` reached by hand: its green lives in
|
|
33
|
+
* `border-accent` and `brand-secondary`, where it is an area rather than a
|
|
34
|
+
* letterform, and `accent` is near-black.
|
|
35
|
+
*
|
|
36
|
+
* `deriveBrandPalette` is the shape of that answer: give it the brand colour and
|
|
37
|
+
* it decides, by measuring, whether it can be ink or has to be an area.
|
|
38
|
+
*/
|
|
39
|
+
/** How far above the AA bar a derived colour lands. */
|
|
40
|
+
const MARGIN = 0.25;
|
|
41
|
+
const TARGET = TEXT_CONTRAST_MINIMUM + MARGIN;
|
|
42
|
+
/** HSL to a six-digit hex, which is the only form `contrastRatio` measures. */
|
|
43
|
+
export const hslHex = (hue, saturation, lightness) => {
|
|
44
|
+
const a = (saturation / 100) * Math.min(lightness / 100, 1 - lightness / 100);
|
|
45
|
+
const channel = (n) => {
|
|
46
|
+
const k = (n + hue / 30) % 12;
|
|
47
|
+
const value = lightness / 100 - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
|
|
48
|
+
return Math.round(255 * value)
|
|
49
|
+
.toString(16)
|
|
50
|
+
.padStart(2, "0");
|
|
51
|
+
};
|
|
52
|
+
return `#${channel(0)}${channel(8)}${channel(4)}`;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The lightest ink (or darkest, on a dark palette) at this hue that still clears
|
|
56
|
+
* `target` against `on`.
|
|
57
|
+
*
|
|
58
|
+
* Lightest rather than merely sufficient, because a colour dragged further than
|
|
59
|
+
* it needs to go loses its hue: an accent solved to 8% lightness is black
|
|
60
|
+
* whatever its hue said, and a palette of five of those is five identical
|
|
61
|
+
* palettes. Twenty-four bisection steps put it within about 0.000006 of the
|
|
62
|
+
* boundary, which is far finer than the 1/255 the hex can express.
|
|
63
|
+
*/
|
|
64
|
+
export const solveLightness = (hue, saturation, on, target, darkening) => {
|
|
65
|
+
let low = darkening ? 0 : 50;
|
|
66
|
+
let high = darkening ? 50 : 100;
|
|
67
|
+
let best = hslHex(hue, saturation, darkening ? 0 : 100);
|
|
68
|
+
for (let step = 0; step < 24; step += 1) {
|
|
69
|
+
const middle = (low + high) / 2;
|
|
70
|
+
const candidate = hslHex(hue, saturation, middle);
|
|
71
|
+
if ((contrastRatio(candidate, on) ?? 0) >= target) {
|
|
72
|
+
best = candidate;
|
|
73
|
+
if (darkening)
|
|
74
|
+
low = middle;
|
|
75
|
+
else
|
|
76
|
+
high = middle;
|
|
77
|
+
}
|
|
78
|
+
else if (darkening)
|
|
79
|
+
high = middle;
|
|
80
|
+
else
|
|
81
|
+
low = middle;
|
|
82
|
+
}
|
|
83
|
+
return best;
|
|
84
|
+
};
|
|
85
|
+
const DEFAULT_LEVELS = {
|
|
86
|
+
light: [98, 100, 94],
|
|
87
|
+
dark: [10, 14, 8],
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Derives a palette. Total: it always returns one, and `auditPalette` on the
|
|
91
|
+
* result is the check that it worked — see `derivePaletteChecked` for the pair.
|
|
92
|
+
*/
|
|
93
|
+
export const derivePalette = (spec) => {
|
|
94
|
+
const ink = spec.mode === "light";
|
|
95
|
+
const [canvasL, surfaceL, mutedL] = spec.levels ?? DEFAULT_LEVELS[spec.mode];
|
|
96
|
+
const { hue: ch, saturation: cs } = spec.canvas;
|
|
97
|
+
const { hue: ah, saturation: as } = spec.accent;
|
|
98
|
+
const { hue: sh, saturation: ss } = spec.secondary;
|
|
99
|
+
const bgCanvas = hslHex(ch, cs, canvasL);
|
|
100
|
+
const bgSurface = hslHex(ch, cs, surfaceL);
|
|
101
|
+
const bgSurfaceMuted = hslHex(ch, cs + 2, mutedL);
|
|
102
|
+
/**
|
|
103
|
+
* Every ink slot is solved against the *worst* of the three grounds it is
|
|
104
|
+
* rendered on rather than against the canvas, because `loom.card` puts body
|
|
105
|
+
* copy on the surface and `loom.perk` puts the subtle slot on the muted well.
|
|
106
|
+
* Solving against the canvas alone is how a palette passes the eye and fails
|
|
107
|
+
* the audit on two pairings nobody was looking at.
|
|
108
|
+
*/
|
|
109
|
+
const tightest = [bgCanvas, bgSurface, bgSurfaceMuted].sort((a, b) => (contrastRatio(a, ink ? "#000000" : "#ffffff") ?? 0) -
|
|
110
|
+
(contrastRatio(b, ink ? "#000000" : "#ffffff") ?? 0))[0];
|
|
111
|
+
const accentSubtle = ink ? hslHex(ah, Math.min(as, 55), 94) : hslHex(ah, Math.min(as, 30), 16);
|
|
112
|
+
const accent = spec.extremeAccent === true
|
|
113
|
+
? hslHex(ah, as, ink ? 7 : 97)
|
|
114
|
+
: solveLightness(ah, as, tightest, TARGET, ink);
|
|
115
|
+
return paletteSchema.parse({
|
|
116
|
+
id: spec.id,
|
|
117
|
+
name: spec.name,
|
|
118
|
+
description: spec.description,
|
|
119
|
+
slots: {
|
|
120
|
+
"bg-canvas": bgCanvas,
|
|
121
|
+
"bg-surface": bgSurface,
|
|
122
|
+
"bg-surface-muted": bgSurfaceMuted,
|
|
123
|
+
"bg-overlay": bgSurface,
|
|
124
|
+
"fg-default": hslHex(ch, Math.min(cs + 6, 20), ink ? 7 : 96),
|
|
125
|
+
/** A step past the bar, so the muted slot is visibly quieter than the default one. */
|
|
126
|
+
"fg-muted": solveLightness(ch, Math.min(cs + 8, 22), tightest, TARGET + 1.6, ink),
|
|
127
|
+
"fg-subtle": solveLightness(ch, Math.min(cs + 6, 18), tightest, TARGET, ink),
|
|
128
|
+
"fg-on-accent": solveLightness(ah, 12, accent, TARGET + 0.5, !ink),
|
|
129
|
+
accent,
|
|
130
|
+
"accent-strong": solveLightness(ah, Math.min(as + 8, 100), accentSubtle, TARGET, ink),
|
|
131
|
+
"accent-subtle": accentSubtle,
|
|
132
|
+
/** Areas, never text, so they keep their chroma and are not solved for. */
|
|
133
|
+
"brand-secondary": hslHex(sh, ss, ink ? 52 : 62),
|
|
134
|
+
"brand-secondary-strong": hslHex(sh, Math.min(ss + 6, 100), ink ? 38 : 48),
|
|
135
|
+
"border-default": hslHex(ch, cs + 4, ink ? 86 : 22),
|
|
136
|
+
"border-strong": hslHex(ch, cs + 4, ink ? 12 : 90),
|
|
137
|
+
"border-subtle": hslHex(ch, cs + 3, ink ? 92 : 17),
|
|
138
|
+
"border-accent": hslHex(ah, Math.min(as, 70), ink ? 58 : 62),
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* The palette and its audit together, which is how a host should call this: the
|
|
144
|
+
* derivation is a rule and the audit is the check on it, and a rule that has
|
|
145
|
+
* never been checked is a rule that will eventually be wrong at one hue.
|
|
146
|
+
*
|
|
147
|
+
* **`clean` means legible, not distinguishable.** It is `auditPalette` and
|
|
148
|
+
* nothing else: every ink clears the contrast bar on every ground it is
|
|
149
|
+
* rendered on. Whether two slots a reader is meant to tell apart are far enough
|
|
150
|
+
* apart to be told apart is `auditSeparation`, and a host that wants both runs
|
|
151
|
+
* both — five of the palettes this function derived collapse a pair that one
|
|
152
|
+
* measures and the other does not.
|
|
153
|
+
*/
|
|
154
|
+
export const derivePaletteChecked = (spec) => {
|
|
155
|
+
const palette = derivePalette(spec);
|
|
156
|
+
return { palette, clean: auditPalette(palette).failures.length === 0 };
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Whether a brand colour can carry text on a given ground.
|
|
160
|
+
*
|
|
161
|
+
* The question a host actually has, and the one they are usually answering
|
|
162
|
+
* wrongly: *can we put our orange in `accent`?* If this says no, the honest
|
|
163
|
+
* places for it are `border-accent` and `brand-secondary` — a rule, a ring, a
|
|
164
|
+
* tinted field — and `accent` takes a near-neutral ink instead.
|
|
165
|
+
*/
|
|
166
|
+
export const canCarryText = (colour, on) => (contrastRatio(colour, on) ?? 0) >= TEXT_CONTRAST_MINIMUM;
|
|
167
|
+
//# sourceMappingURL=derive.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { FontFace, FontPack } from "./theme.js";
|
|
2
|
+
/**
|
|
3
|
+
* Where a face actually is, for anything that cannot look one up.
|
|
4
|
+
*
|
|
5
|
+
* A font pack names CSS family stacks, which is the right thing to hand a
|
|
6
|
+
* browser: it already has the face, or the host's own stylesheet gives it one.
|
|
7
|
+
* Anything that draws text itself has no such luxury. An image renderer cannot
|
|
8
|
+
* resolve `Fraunces` to an outline, so it draws in whatever it ships with and
|
|
9
|
+
* says nothing — a card renders in a grotesque and looks entirely deliberate
|
|
10
|
+
* while doing it.
|
|
11
|
+
*
|
|
12
|
+
* A pack may therefore declare, beside the stack, where each face is. The
|
|
13
|
+
* declaration is an address and nothing more: **the runtime never fetches
|
|
14
|
+
* one**, so a render stays pure and a deployment keeps its own say over what it
|
|
15
|
+
* talks to. A browser reads the stack exactly as before.
|
|
16
|
+
*/
|
|
17
|
+
/** The three roles a pack names a family for. */
|
|
18
|
+
export type FaceRole = "heading" | "body" | "mono";
|
|
19
|
+
export declare const FACE_ROLES: readonly FaceRole[];
|
|
20
|
+
/**
|
|
21
|
+
* The CSS generic families, which name a face without addressing one.
|
|
22
|
+
*
|
|
23
|
+
* A stack ending in `serif` has a last resort everywhere, and there is nothing
|
|
24
|
+
* for a pack to say about where that face is: the renderer either has a default
|
|
25
|
+
* for the generic or it does not. They are excluded from every question below
|
|
26
|
+
* about what is missing, because a source for one would be meaningless.
|
|
27
|
+
*/
|
|
28
|
+
export declare const GENERIC_FAMILIES: readonly string[];
|
|
29
|
+
export declare const isGenericFamily: (family: string) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The first family a stack asks for, unquoted.
|
|
32
|
+
*
|
|
33
|
+
* The leading family is the one the pack is actually about — everything after
|
|
34
|
+
* it is the fallback chain, and a renderer that has the first needs none of the
|
|
35
|
+
* rest. Quotes are stripped because a stack writes `'Space Grotesk'` and a
|
|
36
|
+
* `@font-face` rule and a renderer's font table both want `Space Grotesk`.
|
|
37
|
+
*/
|
|
38
|
+
export declare const leadingFamily: (stack: string) => string;
|
|
39
|
+
export declare const familyStackForRole: (pack: FontPack, role: FaceRole) => string | undefined;
|
|
40
|
+
/** Every face the pack says where to find, in declaration order. */
|
|
41
|
+
export declare const declaredFaces: (pack: FontPack) => readonly FontFace[];
|
|
42
|
+
/**
|
|
43
|
+
* The declared faces whose family is the one this role's stack leads with.
|
|
44
|
+
*
|
|
45
|
+
* Matched on family rather than on role, because one face serves every role
|
|
46
|
+
* that asks for it: a pack setting body and mono to the same family declares
|
|
47
|
+
* that face once.
|
|
48
|
+
*/
|
|
49
|
+
export declare const facesForRole: (pack: FontPack, role: FaceRole) => readonly FontFace[];
|
|
50
|
+
/**
|
|
51
|
+
* The families this pack asks for first and does not say where to find.
|
|
52
|
+
*
|
|
53
|
+
* For a browser this is usually nothing to worry about: a stack leading with
|
|
54
|
+
* `'Helvetica Neue'` finds it on the reader's own machine. For anything drawing
|
|
55
|
+
* text itself every entry here is a face it will not have, and therefore a
|
|
56
|
+
* silent fallback — which is the whole reason a pack may carry sources at all.
|
|
57
|
+
*
|
|
58
|
+
* In `FACE_ROLES` order, deduplicated, generics excluded.
|
|
59
|
+
*/
|
|
60
|
+
export declare const familiesWithoutSource: (pack: FontPack) => readonly string[];
|
|
61
|
+
/**
|
|
62
|
+
* The pack's declared faces as `@font-face` rules, for a host that wants them.
|
|
63
|
+
*
|
|
64
|
+
* Emitted on request and never mounted with the theme, because loading a face
|
|
65
|
+
* is a deployment's decision rather than a pack's: the same pack is correct on
|
|
66
|
+
* a host that serves the faces itself, one that links somebody else's stylesheet,
|
|
67
|
+
* and one that accepts the fallback. A host that wants them puts this in a
|
|
68
|
+
* `<style>`; a host that does not is unaffected.
|
|
69
|
+
*
|
|
70
|
+
* Empty when the pack declares no faces, so the caller has nothing to special-case.
|
|
71
|
+
*/
|
|
72
|
+
export declare const fontFaceRules: (pack: FontPack) => string;
|
|
73
|
+
//# sourceMappingURL=faces.d.ts.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { everyMemberOf } from "../closed-set.js";
|
|
2
|
+
export const FACE_ROLES = everyMemberOf()([
|
|
3
|
+
"heading",
|
|
4
|
+
"body",
|
|
5
|
+
"mono",
|
|
6
|
+
]);
|
|
7
|
+
/**
|
|
8
|
+
* The CSS generic families, which name a face without addressing one.
|
|
9
|
+
*
|
|
10
|
+
* A stack ending in `serif` has a last resort everywhere, and there is nothing
|
|
11
|
+
* for a pack to say about where that face is: the renderer either has a default
|
|
12
|
+
* for the generic or it does not. They are excluded from every question below
|
|
13
|
+
* about what is missing, because a source for one would be meaningless.
|
|
14
|
+
*/
|
|
15
|
+
export const GENERIC_FAMILIES = [
|
|
16
|
+
"serif",
|
|
17
|
+
"sans-serif",
|
|
18
|
+
"monospace",
|
|
19
|
+
"cursive",
|
|
20
|
+
"fantasy",
|
|
21
|
+
"system-ui",
|
|
22
|
+
"ui-serif",
|
|
23
|
+
"ui-sans-serif",
|
|
24
|
+
"ui-monospace",
|
|
25
|
+
"ui-rounded",
|
|
26
|
+
"math",
|
|
27
|
+
"emoji",
|
|
28
|
+
"fangsong",
|
|
29
|
+
];
|
|
30
|
+
const GENERIC_LOOKUP = new Set(GENERIC_FAMILIES);
|
|
31
|
+
export const isGenericFamily = (family) => GENERIC_LOOKUP.has(family.trim().toLowerCase());
|
|
32
|
+
/**
|
|
33
|
+
* The first family a stack asks for, unquoted.
|
|
34
|
+
*
|
|
35
|
+
* The leading family is the one the pack is actually about — everything after
|
|
36
|
+
* it is the fallback chain, and a renderer that has the first needs none of the
|
|
37
|
+
* rest. Quotes are stripped because a stack writes `'Space Grotesk'` and a
|
|
38
|
+
* `@font-face` rule and a renderer's font table both want `Space Grotesk`.
|
|
39
|
+
*/
|
|
40
|
+
export const leadingFamily = (stack) => (stack.split(",")[0] ?? "").trim().replace(/^["']|["']$/g, "");
|
|
41
|
+
export const familyStackForRole = (pack, role) => {
|
|
42
|
+
switch (role) {
|
|
43
|
+
case "heading":
|
|
44
|
+
return pack.headingFamily;
|
|
45
|
+
case "body":
|
|
46
|
+
return pack.bodyFamily;
|
|
47
|
+
case "mono":
|
|
48
|
+
return pack.monoFamily;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/** Every face the pack says where to find, in declaration order. */
|
|
52
|
+
export const declaredFaces = (pack) => pack.faces ?? [];
|
|
53
|
+
/**
|
|
54
|
+
* The declared faces whose family is the one this role's stack leads with.
|
|
55
|
+
*
|
|
56
|
+
* Matched on family rather than on role, because one face serves every role
|
|
57
|
+
* that asks for it: a pack setting body and mono to the same family declares
|
|
58
|
+
* that face once.
|
|
59
|
+
*/
|
|
60
|
+
export const facesForRole = (pack, role) => {
|
|
61
|
+
const stack = familyStackForRole(pack, role);
|
|
62
|
+
if (stack === undefined)
|
|
63
|
+
return [];
|
|
64
|
+
const wanted = leadingFamily(stack).toLowerCase();
|
|
65
|
+
return declaredFaces(pack).filter((face) => face.family.toLowerCase() === wanted);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* The families this pack asks for first and does not say where to find.
|
|
69
|
+
*
|
|
70
|
+
* For a browser this is usually nothing to worry about: a stack leading with
|
|
71
|
+
* `'Helvetica Neue'` finds it on the reader's own machine. For anything drawing
|
|
72
|
+
* text itself every entry here is a face it will not have, and therefore a
|
|
73
|
+
* silent fallback — which is the whole reason a pack may carry sources at all.
|
|
74
|
+
*
|
|
75
|
+
* In `FACE_ROLES` order, deduplicated, generics excluded.
|
|
76
|
+
*/
|
|
77
|
+
export const familiesWithoutSource = (pack) => {
|
|
78
|
+
const sourced = new Set(declaredFaces(pack).map((face) => face.family.toLowerCase()));
|
|
79
|
+
const missing = [];
|
|
80
|
+
for (const role of FACE_ROLES) {
|
|
81
|
+
const stack = familyStackForRole(pack, role);
|
|
82
|
+
if (stack === undefined)
|
|
83
|
+
continue;
|
|
84
|
+
const family = leadingFamily(stack);
|
|
85
|
+
if (family === "" || isGenericFamily(family))
|
|
86
|
+
continue;
|
|
87
|
+
if (sourced.has(family.toLowerCase()))
|
|
88
|
+
continue;
|
|
89
|
+
if (missing.some((seen) => seen.toLowerCase() === family.toLowerCase()))
|
|
90
|
+
continue;
|
|
91
|
+
missing.push(family);
|
|
92
|
+
}
|
|
93
|
+
return missing;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The pack's declared faces as `@font-face` rules, for a host that wants them.
|
|
97
|
+
*
|
|
98
|
+
* Emitted on request and never mounted with the theme, because loading a face
|
|
99
|
+
* is a deployment's decision rather than a pack's: the same pack is correct on
|
|
100
|
+
* a host that serves the faces itself, one that links somebody else's stylesheet,
|
|
101
|
+
* and one that accepts the fallback. A host that wants them puts this in a
|
|
102
|
+
* `<style>`; a host that does not is unaffected.
|
|
103
|
+
*
|
|
104
|
+
* Empty when the pack declares no faces, so the caller has nothing to special-case.
|
|
105
|
+
*/
|
|
106
|
+
export const fontFaceRules = (pack) => declaredFaces(pack)
|
|
107
|
+
.map((face) => {
|
|
108
|
+
const format = face.format === undefined ? "" : ` format("${face.format}")`;
|
|
109
|
+
return [
|
|
110
|
+
"@font-face {",
|
|
111
|
+
` font-family: "${face.family}";`,
|
|
112
|
+
` font-style: ${face.style};`,
|
|
113
|
+
` font-weight: ${face.weight};`,
|
|
114
|
+
` src: url("${face.source}")${format};`,
|
|
115
|
+
"}",
|
|
116
|
+
].join("\n");
|
|
117
|
+
})
|
|
118
|
+
.join("\n\n");
|
|
119
|
+
//# sourceMappingURL=faces.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type FontPack } from "./theme.js";
|
|
2
|
+
export declare const grotesqueFontPack: FontPack;
|
|
3
|
+
export declare const transitionalFontPack: FontPack;
|
|
4
|
+
export declare const didoneFontPack: FontPack;
|
|
5
|
+
export declare const humanistFontPack: FontPack;
|
|
6
|
+
export declare const slabFontPack: FontPack;
|
|
7
|
+
export declare const monoFontPack: FontPack;
|
|
8
|
+
export declare const monoDisplayFontPack: FontPack;
|
|
9
|
+
export declare const geometricFontPack: FontPack;
|
|
10
|
+
export declare const classicalFontPack: FontPack;
|
|
11
|
+
export declare const condensedFontPack: FontPack;
|
|
12
|
+
export declare const roundedFontPack: FontPack;
|
|
13
|
+
export declare const nativeFontPack: FontPack;
|
|
14
|
+
export declare const typewriterFontPack: FontPack;
|
|
15
|
+
export declare const interUiFontPack: FontPack;
|
|
16
|
+
export declare const displaySerifFontPack: FontPack;
|
|
17
|
+
export declare const spaceFontPack: FontPack;
|
|
18
|
+
export declare const workhorseFontPack: FontPack;
|
|
19
|
+
/**
|
|
20
|
+
* In catalogue order: the stack packs first, then the four that need a host to
|
|
21
|
+
* serve a face. A model reading down the list meets something that always works
|
|
22
|
+
* before something that depends on a deployment it cannot see.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ADDITIONAL_FONT_PACKS: readonly FontPack[];
|
|
25
|
+
//# sourceMappingURL=font-packs.d.ts.map
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { fontPackSchema } from "./theme.js";
|
|
2
|
+
/**
|
|
3
|
+
* The seventeen font packs the starter library ships beyond the first three.
|
|
4
|
+
*
|
|
5
|
+
* **Loom does not fetch fonts, and that is the fact to hold while reading these.**
|
|
6
|
+
* A pack names a literal family stack and nothing loads it; a host that wants a
|
|
7
|
+
* webface links it, and until it arrives — or forever, if it never does — the
|
|
8
|
+
* page renders the next family in the stack. Nothing warns. That failure is
|
|
9
|
+
* silent and looks entirely deliberate, which is why the packs below are
|
|
10
|
+
* divided into two kinds and each says which it is:
|
|
11
|
+
*
|
|
12
|
+
* - **Stack packs** name only faces a mainstream operating system already has,
|
|
13
|
+
* so they render as designed with nothing to install and no network at all.
|
|
14
|
+
* Thirteen of the seventeen are these, deliberately: a starter library whose
|
|
15
|
+
* typography depends on a third party is fine until the day it is not, and
|
|
16
|
+
* this repository has already met a blocked CDN twice.
|
|
17
|
+
* - **Served packs** name a webface *first* and a real stack behind it. They
|
|
18
|
+
* are marked in their description, because the host has to serve the face for
|
|
19
|
+
* them to mean anything. `minimal-sans` set the precedent by naming Geist,
|
|
20
|
+
* and the four surfaces link it.
|
|
21
|
+
*
|
|
22
|
+
* Every stack ends in a generic family — `serif`, `sans-serif`, `monospace`,
|
|
23
|
+
* `system-ui` — so there is always a last resort that exists everywhere.
|
|
24
|
+
*
|
|
25
|
+
* ## What actually distinguishes a pack
|
|
26
|
+
*
|
|
27
|
+
* Two families, two weights, a ramp of eight sizes, and — where the pack has an
|
|
28
|
+
* opinion about code — a third family for it. The **ramp is where the
|
|
29
|
+
* feel lives**, and it is the half people skip: a pack whose top step is 96px
|
|
30
|
+
* makes a hero that shouts, and one whose top step is 40px makes a page that
|
|
31
|
+
* reads as an application. Three shapes recur below and are named in each
|
|
32
|
+
* description:
|
|
33
|
+
*
|
|
34
|
+
* | shape | ramp | reads as |
|
|
35
|
+
* | --- | --- | --- |
|
|
36
|
+
* | **dramatic** | wide, 12 → 88 or more | a landing page, a poster |
|
|
37
|
+
* | **editorial** | even, 12 → 64 | a magazine, a long read |
|
|
38
|
+
* | **functional** | tight, 12 → 40 | a product, a dashboard |
|
|
39
|
+
*
|
|
40
|
+
* The steps are px and the primitives read them through `--loom-scale-1…8`;
|
|
41
|
+
* step 3 is body copy in every pack here, so a ramp that starts elsewhere would
|
|
42
|
+
* re-size every paragraph in the library.
|
|
43
|
+
*
|
|
44
|
+
* ## The mono family, and why most packs decline it
|
|
45
|
+
*
|
|
46
|
+
* `monoFamily` is optional (0085), and five of the seventeen below set it: the
|
|
47
|
+
* two built out of a monospace, `typewriter`, and the two whose named face has
|
|
48
|
+
* a mono sibling a host serving one is almost certainly serving too. The rest
|
|
49
|
+
* say nothing on purpose. A pack that paired, say, Garamond with an arbitrary mono
|
|
50
|
+
* would be asserting a relationship its designer never chose — and the reader,
|
|
51
|
+
* `tokens.ts`'s `monospace()`, already falls back to the system stack, which is
|
|
52
|
+
* the same face the operating system uses for code everywhere else.
|
|
53
|
+
*/
|
|
54
|
+
/** The generic tails every stack in this file ends with. */
|
|
55
|
+
const SANS = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif";
|
|
56
|
+
const SERIF = "'Times New Roman', Times, serif";
|
|
57
|
+
const MONO = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
|
|
58
|
+
export const grotesqueFontPack = fontPackSchema.parse({
|
|
59
|
+
id: "grotesque",
|
|
60
|
+
name: "Grotesque",
|
|
61
|
+
description: "One neutral sans at two weights, on a functional ramp. The typography of a product rather than a document.",
|
|
62
|
+
headingFamily: `'Helvetica Neue', Helvetica, Arial, ${SANS}`,
|
|
63
|
+
bodyFamily: `'Helvetica Neue', Helvetica, Arial, ${SANS}`,
|
|
64
|
+
headingWeight: 700,
|
|
65
|
+
bodyWeight: 400,
|
|
66
|
+
scaleRamp: [12, 14, 16, 18, 22, 28, 34, 44],
|
|
67
|
+
});
|
|
68
|
+
export const transitionalFontPack = fontPackSchema.parse({
|
|
69
|
+
id: "transitional",
|
|
70
|
+
name: "Transitional",
|
|
71
|
+
description: "A book serif over a humanist sans, on an editorial ramp. The pairing a long read wants.",
|
|
72
|
+
headingFamily: `Charter, 'Bitstream Charter', 'Sitka Text', Cambria, ${SERIF}`,
|
|
73
|
+
bodyFamily: `'Segoe UI', Roboto, ${SANS}`,
|
|
74
|
+
headingWeight: 600,
|
|
75
|
+
bodyWeight: 400,
|
|
76
|
+
scaleRamp: [12, 14, 17, 19, 24, 32, 44, 64],
|
|
77
|
+
});
|
|
78
|
+
export const didoneFontPack = fontPackSchema.parse({
|
|
79
|
+
id: "didone",
|
|
80
|
+
name: "Didone",
|
|
81
|
+
description: "High-contrast display serif over a quiet sans, on a dramatic ramp. A fashion masthead.",
|
|
82
|
+
headingFamily: `'Playfair Display', 'Bodoni MT', Didot, 'Didot LT STD', 'Hoefler Text', Garamond, ${SERIF}`,
|
|
83
|
+
bodyFamily: `Avenir, 'Avenir Next', ${SANS}`,
|
|
84
|
+
headingWeight: 700,
|
|
85
|
+
bodyWeight: 400,
|
|
86
|
+
scaleRamp: [12, 14, 16, 19, 26, 38, 60, 96],
|
|
87
|
+
});
|
|
88
|
+
export const humanistFontPack = fontPackSchema.parse({
|
|
89
|
+
id: "humanist",
|
|
90
|
+
name: "Humanist",
|
|
91
|
+
description: "A warm sans at two weights, on an editorial ramp. Approachable without being soft.",
|
|
92
|
+
headingFamily: `'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', ${SANS}`,
|
|
93
|
+
bodyFamily: `'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', ${SANS}`,
|
|
94
|
+
headingWeight: 600,
|
|
95
|
+
bodyWeight: 400,
|
|
96
|
+
scaleRamp: [12, 14, 16, 18, 24, 32, 46, 66],
|
|
97
|
+
});
|
|
98
|
+
export const slabFontPack = fontPackSchema.parse({
|
|
99
|
+
id: "slab",
|
|
100
|
+
name: "Slab",
|
|
101
|
+
description: "A slab serif over a plain sans, on a dramatic ramp. Sturdy, and a little loud.",
|
|
102
|
+
headingFamily: `Rockwell, 'Rockwell Nova', 'Roboto Slab', 'DejaVu Serif', 'Sitka Small', ${SERIF}`,
|
|
103
|
+
bodyFamily: `Verdana, Geneva, ${SANS}`,
|
|
104
|
+
headingWeight: 700,
|
|
105
|
+
bodyWeight: 400,
|
|
106
|
+
scaleRamp: [12, 14, 16, 19, 25, 34, 52, 80],
|
|
107
|
+
});
|
|
108
|
+
export const monoFontPack = fontPackSchema.parse({
|
|
109
|
+
id: "mono",
|
|
110
|
+
name: "Mono",
|
|
111
|
+
description: "Monospace throughout, on a functional ramp. Everything on the page sits on the same grid.",
|
|
112
|
+
headingFamily: MONO,
|
|
113
|
+
bodyFamily: MONO,
|
|
114
|
+
monoFamily: MONO,
|
|
115
|
+
headingWeight: 600,
|
|
116
|
+
bodyWeight: 400,
|
|
117
|
+
scaleRamp: [12, 13, 15, 17, 21, 26, 33, 42],
|
|
118
|
+
});
|
|
119
|
+
export const monoDisplayFontPack = fontPackSchema.parse({
|
|
120
|
+
id: "mono-display",
|
|
121
|
+
name: "Mono Display",
|
|
122
|
+
description: "Monospace headlines over a readable sans, on a dramatic ramp. Technical, and still a long read.",
|
|
123
|
+
headingFamily: MONO,
|
|
124
|
+
bodyFamily: `'Segoe UI', Roboto, ${SANS}`,
|
|
125
|
+
monoFamily: MONO,
|
|
126
|
+
headingWeight: 700,
|
|
127
|
+
bodyWeight: 400,
|
|
128
|
+
scaleRamp: [12, 14, 16, 18, 24, 34, 52, 76],
|
|
129
|
+
});
|
|
130
|
+
export const geometricFontPack = fontPackSchema.parse({
|
|
131
|
+
id: "geometric",
|
|
132
|
+
name: "Geometric",
|
|
133
|
+
description: "Circular geometric sans at two weights, on a dramatic ramp. Confident and modern.",
|
|
134
|
+
headingFamily: `'Century Gothic', 'Futura', 'Avenir Next', 'Trebuchet MS', ${SANS}`,
|
|
135
|
+
bodyFamily: `Avenir, 'Avenir Next', 'Segoe UI', ${SANS}`,
|
|
136
|
+
headingWeight: 700,
|
|
137
|
+
bodyWeight: 400,
|
|
138
|
+
scaleRamp: [12, 14, 16, 19, 25, 36, 56, 88],
|
|
139
|
+
});
|
|
140
|
+
export const classicalFontPack = fontPackSchema.parse({
|
|
141
|
+
id: "classical",
|
|
142
|
+
name: "Classical",
|
|
143
|
+
description: "Old-style serif throughout, on an editorial ramp. A page that looks printed.",
|
|
144
|
+
headingFamily: `Garamond, 'EB Garamond', 'Apple Garamond', 'Palatino Linotype', Palatino, ${SERIF}`,
|
|
145
|
+
bodyFamily: `Georgia, 'Iowan Old Style', Palatino, ${SERIF}`,
|
|
146
|
+
headingWeight: 600,
|
|
147
|
+
bodyWeight: 400,
|
|
148
|
+
scaleRamp: [13, 15, 18, 20, 26, 34, 48, 68],
|
|
149
|
+
});
|
|
150
|
+
export const condensedFontPack = fontPackSchema.parse({
|
|
151
|
+
id: "condensed",
|
|
152
|
+
name: "Condensed",
|
|
153
|
+
description: "A narrow sans for headlines over a normal one for text, on a dramatic ramp. Fits more, shouts louder.",
|
|
154
|
+
headingFamily: `'Haettenschweiler', 'Arial Narrow', 'Roboto Condensed', Impact, ${SANS}`,
|
|
155
|
+
bodyFamily: `Roboto, 'Segoe UI', ${SANS}`,
|
|
156
|
+
headingWeight: 700,
|
|
157
|
+
bodyWeight: 400,
|
|
158
|
+
scaleRamp: [12, 14, 16, 18, 26, 40, 64, 104],
|
|
159
|
+
});
|
|
160
|
+
export const roundedFontPack = fontPackSchema.parse({
|
|
161
|
+
id: "rounded",
|
|
162
|
+
name: "Rounded",
|
|
163
|
+
description: "A soft-cornered sans at two weights, on a functional ramp. Friendly, for a product.",
|
|
164
|
+
headingFamily: `'SF Pro Rounded', 'Varela Round', 'Nunito', 'Trebuchet MS', ${SANS}`,
|
|
165
|
+
bodyFamily: `'SF Pro Rounded', 'Varela Round', 'Nunito', 'Trebuchet MS', ${SANS}`,
|
|
166
|
+
headingWeight: 700,
|
|
167
|
+
bodyWeight: 400,
|
|
168
|
+
scaleRamp: [12, 14, 16, 18, 22, 28, 38, 52],
|
|
169
|
+
});
|
|
170
|
+
export const nativeFontPack = fontPackSchema.parse({
|
|
171
|
+
id: "native",
|
|
172
|
+
name: "Native",
|
|
173
|
+
description: "The reader's own system face at two weights, on a functional ramp. Nothing to load, and it looks native everywhere.",
|
|
174
|
+
headingFamily: `system-ui, ${SANS}`,
|
|
175
|
+
bodyFamily: `system-ui, ${SANS}`,
|
|
176
|
+
headingWeight: 600,
|
|
177
|
+
bodyWeight: 400,
|
|
178
|
+
scaleRamp: [12, 14, 16, 18, 22, 28, 36, 48],
|
|
179
|
+
});
|
|
180
|
+
export const typewriterFontPack = fontPackSchema.parse({
|
|
181
|
+
id: "typewriter",
|
|
182
|
+
name: "Typewriter",
|
|
183
|
+
description: "Monospace headlines over an old-style serif, on an editorial ramp. A manuscript rather than a terminal.",
|
|
184
|
+
headingFamily: `'Courier New', Courier, ${MONO}`,
|
|
185
|
+
bodyFamily: `Georgia, 'Iowan Old Style', ${SERIF}`,
|
|
186
|
+
monoFamily: `'Courier New', Courier, ${MONO}`,
|
|
187
|
+
headingWeight: 700,
|
|
188
|
+
bodyWeight: 400,
|
|
189
|
+
scaleRamp: [13, 15, 17, 19, 24, 31, 44, 62],
|
|
190
|
+
});
|
|
191
|
+
export const interUiFontPack = fontPackSchema.parse({
|
|
192
|
+
id: "inter-ui",
|
|
193
|
+
name: "Inter UI",
|
|
194
|
+
description: "Inter at two weights, on a functional ramp. **The host must serve Inter**; without it this is the system sans.",
|
|
195
|
+
headingFamily: `Inter, system-ui, ${SANS}`,
|
|
196
|
+
bodyFamily: `Inter, system-ui, ${SANS}`,
|
|
197
|
+
headingWeight: 650,
|
|
198
|
+
bodyWeight: 400,
|
|
199
|
+
scaleRamp: [12, 14, 16, 18, 22, 28, 38, 52],
|
|
200
|
+
});
|
|
201
|
+
export const displaySerifFontPack = fontPackSchema.parse({
|
|
202
|
+
id: "display-serif",
|
|
203
|
+
name: "Display Serif",
|
|
204
|
+
description: "Fraunces headlines over a system sans, on a dramatic ramp. **The host must serve Fraunces**; without it this is Georgia.",
|
|
205
|
+
headingFamily: `Fraunces, 'Playfair Display', Georgia, ${SERIF}`,
|
|
206
|
+
bodyFamily: `system-ui, ${SANS}`,
|
|
207
|
+
headingWeight: 700,
|
|
208
|
+
bodyWeight: 400,
|
|
209
|
+
scaleRamp: [12, 14, 17, 19, 26, 38, 58, 92],
|
|
210
|
+
});
|
|
211
|
+
export const spaceFontPack = fontPackSchema.parse({
|
|
212
|
+
id: "space",
|
|
213
|
+
name: "Space",
|
|
214
|
+
description: "Space Grotesk headlines over its mono, on a dramatic ramp. **The host must serve both**; without them, system sans over system mono.",
|
|
215
|
+
headingFamily: `'Space Grotesk', system-ui, ${SANS}`,
|
|
216
|
+
bodyFamily: `'Space Mono', ${MONO}`,
|
|
217
|
+
monoFamily: `'Space Mono', ${MONO}`,
|
|
218
|
+
headingWeight: 700,
|
|
219
|
+
bodyWeight: 400,
|
|
220
|
+
scaleRamp: [12, 14, 16, 18, 24, 34, 54, 84],
|
|
221
|
+
});
|
|
222
|
+
export const workhorseFontPack = fontPackSchema.parse({
|
|
223
|
+
id: "workhorse",
|
|
224
|
+
name: "Workhorse",
|
|
225
|
+
description: "Source Sans over Source Serif, on an editorial ramp. **The host must serve both**; without them, system sans over Georgia.",
|
|
226
|
+
headingFamily: `'Source Sans 3', 'Source Sans Pro', system-ui, ${SANS}`,
|
|
227
|
+
bodyFamily: `'Source Serif 4', 'Source Serif Pro', Georgia, ${SERIF}`,
|
|
228
|
+
monoFamily: `'Source Code Pro', ${MONO}`,
|
|
229
|
+
headingWeight: 600,
|
|
230
|
+
bodyWeight: 400,
|
|
231
|
+
scaleRamp: [12, 14, 17, 19, 24, 32, 44, 62],
|
|
232
|
+
});
|
|
233
|
+
/**
|
|
234
|
+
* In catalogue order: the stack packs first, then the four that need a host to
|
|
235
|
+
* serve a face. A model reading down the list meets something that always works
|
|
236
|
+
* before something that depends on a deployment it cannot see.
|
|
237
|
+
*/
|
|
238
|
+
export const ADDITIONAL_FONT_PACKS = [
|
|
239
|
+
nativeFontPack,
|
|
240
|
+
grotesqueFontPack,
|
|
241
|
+
humanistFontPack,
|
|
242
|
+
geometricFontPack,
|
|
243
|
+
roundedFontPack,
|
|
244
|
+
condensedFontPack,
|
|
245
|
+
transitionalFontPack,
|
|
246
|
+
classicalFontPack,
|
|
247
|
+
didoneFontPack,
|
|
248
|
+
slabFontPack,
|
|
249
|
+
monoFontPack,
|
|
250
|
+
monoDisplayFontPack,
|
|
251
|
+
typewriterFontPack,
|
|
252
|
+
interUiFontPack,
|
|
253
|
+
displaySerifFontPack,
|
|
254
|
+
spaceFontPack,
|
|
255
|
+
workhorseFontPack,
|
|
256
|
+
];
|
|
257
|
+
//# sourceMappingURL=font-packs.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a page looks like, as something a tree can name.
|
|
3
|
+
*
|
|
4
|
+
* A palette, a font pack and a style preset, registered by a deployment and
|
|
5
|
+
* selected by id on the root node, resolved into the variables a stylesheet reads.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./apply.js";
|
|
8
|
+
export * from "./contrast.js";
|
|
9
|
+
export * from "./derive.js";
|
|
10
|
+
export * from "./faces.js";
|
|
11
|
+
export * from "./font-packs.js";
|
|
12
|
+
export * from "./lab.js";
|
|
13
|
+
export * from "./library.js";
|
|
14
|
+
export * from "./measure.js";
|
|
15
|
+
export * from "./palettes.js";
|
|
16
|
+
export * from "./separation.js";
|
|
17
|
+
export * from "./style-presets.js";
|
|
18
|
+
export * from "./registry.js";
|
|
19
|
+
export * from "./theme.js";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|