@domandigital/craft 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/CHANGELOG.md +39 -0
- package/LICENSE +202 -0
- package/PRINCIPLES.md +93 -0
- package/README.md +105 -0
- package/STANDARD.md +166 -0
- package/css/craft.css +145 -0
- package/css/craft.tailwind.css +97 -0
- package/dist/index.cjs +1201 -0
- package/dist/index.d.cts +676 -0
- package/dist/index.d.ts +676 -0
- package/dist/index.js +1128 -0
- package/package.json +61 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @domandigital/craft
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 000eb90: Initial release: OKLCh colour, contrast, motion tokens and the base stylesheet.
|
|
8
|
+
|
|
9
|
+
Colour ramps snap to anchors byte-identically, so an existing site adopts craft
|
|
10
|
+
without a visual diff. Semantic tokens are derived with measured WCAG 2.x _and_
|
|
11
|
+
APCA-W3 contrast, and `accentFork` returns the step nearest the brand accent that
|
|
12
|
+
clears both bars, emitting the measured ratios as a CSS comment.
|
|
13
|
+
|
|
14
|
+
Motion ships one vocabulary for CSS and JS (`EASE` / `EASE_TUPLE` hold identical
|
|
15
|
+
control points), replacing three ease curves that were wrong in the shared layer:
|
|
16
|
+
two byte-identical curves under different names, and an `ease-in` exit.
|
|
17
|
+
|
|
18
|
+
`craft.css` collapses reduced-motion durations rather than using `animation:
|
|
19
|
+
none`, which strands forwards-filled entrances at `opacity: 0`.
|
|
20
|
+
|
|
21
|
+
- 0b6d77e: Type, space, density, restraint, Tailwind adapters and STANDARD.md.
|
|
22
|
+
|
|
23
|
+
Fluid type and space scales after Utopia, always with a `rem` term so browser
|
|
24
|
+
text-size settings still apply (a bare-`vw` size fails WCAG 1.4.4 at 200% zoom).
|
|
25
|
+
Both accept pinned literals, so a live site adopts the scale without its type or
|
|
26
|
+
spacing moving.
|
|
27
|
+
|
|
28
|
+
Section rhythm ships three sizes rather than the five that shipped previously
|
|
29
|
+
with zero consumers. Density is three steps on a 4px grid, set once on a shell
|
|
30
|
+
via `[data-density]`.
|
|
31
|
+
|
|
32
|
+
`checkRestraint` is pure over strings — no filesystem, no parser, no
|
|
33
|
+
dependencies — so a guard, a CI check and an editor all run it on the same input
|
|
34
|
+
and agree. It catches accumulation, which a differentiation guard structurally
|
|
35
|
+
cannot see: a guard passes anything that differs from its siblings, however ugly.
|
|
36
|
+
|
|
37
|
+
STANDARD.md's canonical numbers are asserted against `HOUSE_BUDGET`, `EASE` and
|
|
38
|
+
`DURATION_MS` on every run, so the document cannot become a second source of
|
|
39
|
+
truth that reads as authoritative while being stale.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Doman Digital Ltd
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/PRINCIPLES.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Why this package exists
|
|
2
|
+
|
|
3
|
+
Not to make things consistent. Consistency was already achievable, and largely
|
|
4
|
+
achieved, by hand. This package exists because the numbers that govern how a
|
|
5
|
+
Doman Digital surface looks were written down in three places that never agreed,
|
|
6
|
+
and because several of them were wrong in ways nobody could see by reading them.
|
|
7
|
+
|
|
8
|
+
## The defect
|
|
9
|
+
|
|
10
|
+
**Three token vocabularies, zero shared numbers.** `packages/ui/tokens/` in the
|
|
11
|
+
monorepo, a `:root` block in a client site with no Tailwind at all, and a
|
|
12
|
+
Tailwind v3 config in another. Each was internally coherent. None of them shared
|
|
13
|
+
a single value with the others, so "the house easing curve" meant three different
|
|
14
|
+
curves depending on which repo you were standing in.
|
|
15
|
+
|
|
16
|
+
**`--ease-emphasized` was byte-identical to `--ease-standard`.** Both
|
|
17
|
+
`cubic-bezier(0.2, 0, 0, 1)`. Every component reaching for emphasis got the
|
|
18
|
+
standard curve and no emphasis. This is invisible on inspection — the names
|
|
19
|
+
differ, the values are 26 characters apart, and nothing fails.
|
|
20
|
+
|
|
21
|
+
**`--ease-exit` was `cubic-bezier(0.4, 0, 1, 1)` — an ease-*in* curve.** It
|
|
22
|
+
starts slow and accelerates out of view. It is the one curve never to use for
|
|
23
|
+
UI: a dismissal on an ease-in reads as the interface dragging the thing away from
|
|
24
|
+
you rather than getting out of your way.
|
|
25
|
+
|
|
26
|
+
**A site was stranded at `opacity: 0`.** A reduced-motion block used
|
|
27
|
+
`animation: none`. That removes the animation *and* its `forwards` fill, so a
|
|
28
|
+
forwards-filled entrance keyframe never applies its end state and the element
|
|
29
|
+
keeps the `opacity: 0` from its own base rule. The content was permanently
|
|
30
|
+
invisible, for exactly the users who had asked for less motion. Collapsing the
|
|
31
|
+
duration to `0.01ms` runs the animation to completion inside a frame instead:
|
|
32
|
+
the end state applies, and nothing moves.
|
|
33
|
+
|
|
34
|
+
**141 classes painting nothing.** `bg-bg3` (48 uses) and `border-border` (93) in
|
|
35
|
+
the portal reference Tailwind theme keys that do not exist under v4. They resolve
|
|
36
|
+
to nothing and fall through to whatever the base rule said. Adding the missing
|
|
37
|
+
keys would not be a fix — it would suddenly paint 48 surfaces nobody designed.
|
|
38
|
+
|
|
39
|
+
**Two guesses at one accessible accent.** Two client repos each hand-picked a
|
|
40
|
+
"legible variant" of the brand accent and wrote the contrast ratio into a
|
|
41
|
+
comment. Both were plausible. Neither was re-checked when the accent moved, and
|
|
42
|
+
a comment is not a measurement.
|
|
43
|
+
|
|
44
|
+
## What follows from that
|
|
45
|
+
|
|
46
|
+
**Anchors are sacred.** Any hex a consuming repo supplies comes back out of a
|
|
47
|
+
ramp as the same string, byte for byte. That is the only reason an existing site
|
|
48
|
+
can adopt this without a visual diff. Values that already shipped stay literal;
|
|
49
|
+
only the steps nobody had picked get computed. The tests assert string identity,
|
|
50
|
+
not colour equality, because re-serialising `#7050f5` through a colour space and
|
|
51
|
+
back is exactly the kind of "no visible change" that turns out to be visible.
|
|
52
|
+
|
|
53
|
+
**Derived values carry their measurement.** `accentFork` does not pick a nice
|
|
54
|
+
lighter violet. It walks the ramp from the brand end and returns the first step
|
|
55
|
+
that actually clears both 4.5:1 and Lc 60 against every background it will sit
|
|
56
|
+
on, with the measured ratios emitted as a CSS comment beside the token. When
|
|
57
|
+
nothing clears the bar it says so loudly rather than returning the least-bad in
|
|
58
|
+
silence.
|
|
59
|
+
|
|
60
|
+
**Both contrast models, because they disagree and the disagreement matters.**
|
|
61
|
+
The portal's shipped `--violet-400` (`#a78bfa`) scores 7.21:1 against the
|
|
62
|
+
marketing canvas — comfortably AA — and Lc −49.1, which is under the house bar
|
|
63
|
+
for body text. WCAG 2.x is what an audit asks for; APCA is what tracks
|
|
64
|
+
readability on dark backgrounds. The house bar is the pair.
|
|
65
|
+
|
|
66
|
+
**Search from the brand end, not the legible end.** On a dark background every
|
|
67
|
+
step lighter than the accent eventually passes a contrast check, so a naive
|
|
68
|
+
search returns near-white. The answer that is useful is the *darkest* step that
|
|
69
|
+
passes: maximum brand, minimum sufficient contrast.
|
|
70
|
+
|
|
71
|
+
**Motion is a decision before it is a curve.** The commonest motion defect is
|
|
72
|
+
not a wrong easing, it is animating something that should have been instant.
|
|
73
|
+
`shouldAnimate` refuses keyboard-triggered motion outright, refuses anything a
|
|
74
|
+
user hits a hundred times a day, and always gives a reason — so a "no" is
|
|
75
|
+
arguable rather than mysterious.
|
|
76
|
+
|
|
77
|
+
**Plain custom properties, nothing else.** The consumers do not agree on a
|
|
78
|
+
styling engine and are not going to. Custom properties are the only output all
|
|
79
|
+
of them can read without a build step. What this package deliberately does not
|
|
80
|
+
decide: the styling engine, the motion library, or where the tokens live.
|
|
81
|
+
|
|
82
|
+
## The tension the ramp has to resolve
|
|
83
|
+
|
|
84
|
+
An anchor's real lightness and the ramp's lightness curve contradict each other.
|
|
85
|
+
`#7050f5` sits at OKLCh L=0.564; `LIGHTNESS_CURVE[500]` is 0.658. Pin the anchor
|
|
86
|
+
at 500, generate 600 from the raw curve at 0.586, and step 600 comes out
|
|
87
|
+
*lighter* than step 500 — a ramp that reverses direction halfway down.
|
|
88
|
+
|
|
89
|
+
Both properties are required, so neither can be dropped. The curve is warped
|
|
90
|
+
instead: a piecewise-linear map pinned at 0 and 1 that passes through
|
|
91
|
+
(curve value, actual value) for the anchor. Monotonic by construction, and every
|
|
92
|
+
other step keeps its relative position. The anchors define the ramp; the curve
|
|
93
|
+
only sets the spacing between them.
|
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @domandigital/craft
|
|
2
|
+
|
|
3
|
+
The Doman Digital house craft standard, as numbers.
|
|
4
|
+
|
|
5
|
+
OKLCh colour ramps that snap to colours you already ship, semantic tokens derived
|
|
6
|
+
with measured WCAG **and** APCA contrast, one motion vocabulary shared by CSS and
|
|
7
|
+
JS, and a base stylesheet. Zero runtime dependencies.
|
|
8
|
+
|
|
9
|
+
Read [PRINCIPLES.md](./PRINCIPLES.md) for why each rule is a rule.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add @domandigital/craft
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Use
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { craftTokens } from "@domandigital/craft";
|
|
21
|
+
|
|
22
|
+
const { css, report, ramps } = craftTokens({
|
|
23
|
+
// Steps you already ship come back byte-identical.
|
|
24
|
+
accent: { 400: "#a78bfa", 500: "#7050f5", 600: "#6e4ce8" },
|
|
25
|
+
bgCanvas: "#04060e",
|
|
26
|
+
bgSurface: "#0b1120",
|
|
27
|
+
bgElevated: "#151c2e",
|
|
28
|
+
textPrimary: "#ecf2ff",
|
|
29
|
+
textSecondary: "#b7c3d9",
|
|
30
|
+
textMuted: "#8e9cb5",
|
|
31
|
+
borderSubtle: "rgba(184, 198, 219, 0.16)",
|
|
32
|
+
borderStrong: "rgba(184, 198, 219, 0.28)",
|
|
33
|
+
success: "#3fb98a",
|
|
34
|
+
warning: "#d6a14a",
|
|
35
|
+
danger: "#e26d6d",
|
|
36
|
+
info: "#5aa7e8",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (report.failures.length > 0) {
|
|
40
|
+
// Fails the house bar (4.5:1 AND |Lc| 60). Surface it; do not ship past it.
|
|
41
|
+
console.warn(report.failures.map((f) => f.note).join("\n"));
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Write `css` to a committed file and import it. Then, once, in your global
|
|
46
|
+
stylesheet:
|
|
47
|
+
|
|
48
|
+
```css
|
|
49
|
+
@import "@domandigital/craft/craft.css";
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`craft.css` needs no build step and works with or without Tailwind.
|
|
53
|
+
|
|
54
|
+
On Tailwind v4, also import the theme bridge:
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
@import "@domandigital/craft/craft.tailwind.css";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
On Tailwind v3, add the preset:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
const { tailwindV3Preset } = require("@domandigital/craft");
|
|
64
|
+
module.exports = { presets: [tailwindV3Preset()] };
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## The standard itself
|
|
68
|
+
|
|
69
|
+
[STANDARD.md](./STANDARD.md) is the eleven-section house standard, every numeric
|
|
70
|
+
rule cited, including a section on what is deliberately *not* a rule. Its
|
|
71
|
+
canonical numbers are compared against the code on every test run, so the
|
|
72
|
+
document cannot drift from what ships.
|
|
73
|
+
|
|
74
|
+
## The anchor guarantee
|
|
75
|
+
|
|
76
|
+
Every hex you pass in comes back out unchanged — the same string, byte for byte.
|
|
77
|
+
That is what lets a live site adopt this without a single pixel moving. Only the
|
|
78
|
+
steps you never picked by hand are generated.
|
|
79
|
+
|
|
80
|
+
## What it will tell you that you did not ask
|
|
81
|
+
|
|
82
|
+
`report.failures` lists every text-on-surface pair that clears WCAG AA but misses
|
|
83
|
+
the house APCA bar, which is the failure mode a WCAG-only check cannot see. The
|
|
84
|
+
accent fork emits its measured ratios as a CSS comment, so the choice is
|
|
85
|
+
checkable rather than asserted.
|
|
86
|
+
|
|
87
|
+
## API
|
|
88
|
+
|
|
89
|
+
| Area | Exports |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| Colour space | `hexToOklch`, `oklchToHex`, `toGamut`, `inSrgbGamut`, `inP3Gamut`, `deltaEOk`, `deltaEOkHex` |
|
|
92
|
+
| Ramps | `ramp`, `rampFromAnchors`, `RAMP_STEPS`, `LIGHTNESS_CURVE` |
|
|
93
|
+
| Contrast | `wcagContrast`, `apcaContrast`, `checkPair` |
|
|
94
|
+
| Semantic | `semantic`, `accentFork` |
|
|
95
|
+
| Motion | `EASE`, `EASE_TUPLE`, `DURATION_MS`, `DURATION_S`, `SPRING`, `SCALE`, `exitDuration`, `shouldAnimate` |
|
|
96
|
+
| Type | `fluidType`, `fluidClamp`, `typeFeatureTokens`, `HOUSE_TYPE`, `TYPE_STEPS` |
|
|
97
|
+
| Space | `fluidSpace`, `sectionRhythm`, `SPACE_STEPS` |
|
|
98
|
+
| Density | `densityCss`, `densityTokens`, `DENSITIES` |
|
|
99
|
+
| Restraint | `checkRestraint`, `HOUSE_BUDGET` |
|
|
100
|
+
| Tailwind | `tailwindV3Preset` (v3), `tailwindV4Theme` / `craft.tailwind.css` (v4) |
|
|
101
|
+
| Emit | `craftTokens`, `emitCss`, `motionTokens` |
|
|
102
|
+
|
|
103
|
+
## Licence
|
|
104
|
+
|
|
105
|
+
Apache-2.0
|
package/STANDARD.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# The Doman Digital craft standard
|
|
2
|
+
|
|
3
|
+
Eleven sections. Every numeric rule is cited, and section 10 says what is
|
|
4
|
+
deliberately *not* a rule.
|
|
5
|
+
|
|
6
|
+
This document and the package are bound together by a test: the machine-readable
|
|
7
|
+
block in section 11 is compared against `HOUSE_BUDGET`, `EASE` and
|
|
8
|
+
`DURATION_MS` on every run, so the standard cannot drift from what ships.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. Colour is derived, not picked
|
|
13
|
+
|
|
14
|
+
Anchors — colours a surface already ships — are sacred and come back byte-identical.
|
|
15
|
+
Everything else is generated in OKLCh from those anchors.
|
|
16
|
+
|
|
17
|
+
- Ramps have **11 steps** (50–950).
|
|
18
|
+
- Gamut mapping reduces **chroma only**, preserving hue and lightness
|
|
19
|
+
(CSS Color 4 §13.2). RGB clipping is rejected: it walks a saturated violet
|
|
20
|
+
toward magenta.
|
|
21
|
+
- Derived values standing in for a hand-picked one must be within
|
|
22
|
+
**ΔE_OK ≤ 0.02** — the just-noticeable difference — or be declared an
|
|
23
|
+
intentional change.
|
|
24
|
+
|
|
25
|
+
*Source: Ottosson, "A perceptual color space for image processing" (2020); CSS Color 4 §13.2.*
|
|
26
|
+
|
|
27
|
+
## 2. Contrast is measured against both models
|
|
28
|
+
|
|
29
|
+
- Body text clears **4.5:1** (WCAG 2.x AA) **and** **|Lc| 60** (APCA-W3 0.1.9).
|
|
30
|
+
- Large text and non-text UI clear **3:1**.
|
|
31
|
+
- The two disagree, and the disagreement is the point: `#a78bfa` on `#060b19`
|
|
32
|
+
scores 7.21:1 and Lc −49.1. WCAG is what an audit asks for; APCA is what tracks
|
|
33
|
+
readability on dark backgrounds.
|
|
34
|
+
- An accent fork searches **from the brand end**, returning the darkest passing
|
|
35
|
+
step, and emits its measured ratio as a comment. Searching from the light end
|
|
36
|
+
returns near-white, which passes everything and is no longer the brand colour.
|
|
37
|
+
|
|
38
|
+
*Source: WCAG 2.2 SC 1.4.3; APCA-W3 0.1.9.*
|
|
39
|
+
|
|
40
|
+
## 3. Type is fluid, and always has a rem term
|
|
41
|
+
|
|
42
|
+
- Steps **−2 to 5**, `clamp()` interpolated between a small and a large viewport.
|
|
43
|
+
- The interpolation term is **`rem + vw`, never bare `vw`** — a bare-`vw` size
|
|
44
|
+
ignores the browser text-size setting and fails WCAG 1.4.4 at 200% zoom.
|
|
45
|
+
- Existing sizes are **pinned**, not regenerated, so adopting the scale moves
|
|
46
|
+
nothing.
|
|
47
|
+
|
|
48
|
+
*Source: Utopia (utopia.fyi); WCAG 2.2 SC 1.4.4.*
|
|
49
|
+
|
|
50
|
+
## 4. Typographic detail is not optional
|
|
51
|
+
|
|
52
|
+
- Display tracking **−0.01em**; button **0.12em**; eyebrow **0.24em**.
|
|
53
|
+
- Leading: display **1.05**, heading **1.1**, body **1.6**.
|
|
54
|
+
- Measure **45–75ch**; body **65ch**.
|
|
55
|
+
- Headings `text-wrap: balance`; body copy `text-wrap: pretty`.
|
|
56
|
+
- Numeric columns get `tabular-nums` and align to the end. Proportional figures
|
|
57
|
+
in a column do not line up.
|
|
58
|
+
- Clipped display text gets a **descender mask** (`padding-bottom: .16em;
|
|
59
|
+
margin-bottom: -.16em`), or it loses the tails of g, j, p, q, y.
|
|
60
|
+
|
|
61
|
+
*Source: house habit — the −0.01em display tracking and the ch measure were arrived at independently in two client repos.*
|
|
62
|
+
|
|
63
|
+
## 5. Space is fluid and proportional to type
|
|
64
|
+
|
|
65
|
+
- Steps **3xs–3xl** as multiples of a base (0.25× to 6×), plus **one-up pairs**.
|
|
66
|
+
- Section rhythm has **three** sizes, not five. Five shipped with zero consumers,
|
|
67
|
+
which is the signature of a scale invented ahead of a need.
|
|
68
|
+
|
|
69
|
+
*Source: Utopia; measured — `--space-section-xs..xl` had no consumers in the monorepo.*
|
|
70
|
+
|
|
71
|
+
## 6. Density is a property of the surface
|
|
72
|
+
|
|
73
|
+
Three densities on a **4px grid**: rows **32 / 40 / 48px**. A table an operator
|
|
74
|
+
scans for six hours and the same component on a client dashboard have different
|
|
75
|
+
needs. Set once on a shell via `[data-density]`, inherited below.
|
|
76
|
+
|
|
77
|
+
*Source: Linear and Stripe both converge on 4px with a 32/40/48 row ladder.*
|
|
78
|
+
|
|
79
|
+
## 7. Motion is a decision before it is a curve
|
|
80
|
+
|
|
81
|
+
- **The LCP element never animates.** Animating it delays the metric by exactly
|
|
82
|
+
the animation's duration.
|
|
83
|
+
- **Transform and opacity only.** Everything else cannot be composited.
|
|
84
|
+
- **Exits run at 0.75× their entrance.** Arriving content is asking to be read;
|
|
85
|
+
leaving content lingering reads as lag.
|
|
86
|
+
- **No ease-in for UI, ever.** It accelerates away from the user.
|
|
87
|
+
- **UI durations ≤ 300ms.** Drawers and one gated reveal may exceed it.
|
|
88
|
+
- **Don't animate what fires 100×/day**, and never animate a keyboard-triggered
|
|
89
|
+
interaction — the user is moving faster than the animation.
|
|
90
|
+
- **One signature moment per page**, gated, never the LCP element.
|
|
91
|
+
|
|
92
|
+
*Source: Emil Kowalski, "Animations on the Web"; Core Web Vitals (LCP).*
|
|
93
|
+
|
|
94
|
+
## 8. Reduced motion collapses, never disables
|
|
95
|
+
|
|
96
|
+
`@media (prefers-reduced-motion: reduce)` sets `animation-duration` and
|
|
97
|
+
`transition-duration` to **0.01ms** and `animation-iteration-count` to 1.
|
|
98
|
+
|
|
99
|
+
**Never `animation: none`.** That drops the `forwards` fill along with the
|
|
100
|
+
animation, so a forwards-filled entrance never applies its end state and the
|
|
101
|
+
element keeps `opacity: 0` from its base rule — permanently invisible, for
|
|
102
|
+
exactly the users who asked for less motion. This shipped.
|
|
103
|
+
|
|
104
|
+
Images: AVIF and WebP, in that order.
|
|
105
|
+
|
|
106
|
+
*Source: WCAG 2.2 SC 2.3.3; measured — a live site was stranded at opacity 0 by this exact defect.*
|
|
107
|
+
|
|
108
|
+
## 9. Restraint is the budget
|
|
109
|
+
|
|
110
|
+
Per surface: **≤10 font sizes, ≤3 weights, ≤2 families** (plus mono),
|
|
111
|
+
**≤4 radii, ≤4 shadows**, accent hues clustered within **15° OKLCh**.
|
|
112
|
+
|
|
113
|
+
Differentiation guards pass anything that differs from its siblings, however
|
|
114
|
+
ugly. What they cannot see is accumulation — eighteen font sizes, six shadows,
|
|
115
|
+
four competing accents, each added reasonably, together reading as noise.
|
|
116
|
+
|
|
117
|
+
*Source: measured against the estate; the budget is the observed ceiling of the surfaces that read as designed.*
|
|
118
|
+
|
|
119
|
+
## 10. What is deliberately not a rule
|
|
120
|
+
|
|
121
|
+
The package emits **plain CSS custom properties** precisely so these stay free:
|
|
122
|
+
|
|
123
|
+
- **The styling engine.** Tailwind v3, v4, or none. Adapters exist for the first
|
|
124
|
+
two; the third needs nothing.
|
|
125
|
+
- **The motion library.** `EASE_TUPLE` carries the same control points as `EASE`,
|
|
126
|
+
so Framer Motion, GSAP and CSS agree without the package choosing one.
|
|
127
|
+
- **Where tokens live.** A `:root` block, a generated file, a Tailwind theme —
|
|
128
|
+
the package does not care.
|
|
129
|
+
- **Layout, grid and component structure.** Out of scope.
|
|
130
|
+
- **Brand voice, copy, and photography grading.** Separate standards.
|
|
131
|
+
|
|
132
|
+
A rule here has to be one that is wrong to break. Everything else is a default.
|
|
133
|
+
|
|
134
|
+
## 11. The numbers
|
|
135
|
+
|
|
136
|
+
<!-- craft:canonical -->
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"budget": {
|
|
140
|
+
"maxFontSizes": 10,
|
|
141
|
+
"maxFontWeights": 3,
|
|
142
|
+
"maxFontFamilies": 2,
|
|
143
|
+
"maxRadii": 4,
|
|
144
|
+
"maxShadows": 4,
|
|
145
|
+
"accentHueClusterDeg": 15,
|
|
146
|
+
"maxUiDurationMs": 300
|
|
147
|
+
},
|
|
148
|
+
"ease": {
|
|
149
|
+
"out": "cubic-bezier(0.23, 1, 0.32, 1)",
|
|
150
|
+
"inOut": "cubic-bezier(0.77, 0, 0.175, 1)",
|
|
151
|
+
"drawer": "cubic-bezier(0.32, 0.72, 0, 1)",
|
|
152
|
+
"reveal": "cubic-bezier(0.22, 0.61, 0.36, 1)"
|
|
153
|
+
},
|
|
154
|
+
"durationMs": {
|
|
155
|
+
"press": 120,
|
|
156
|
+
"tooltip": 150,
|
|
157
|
+
"dropdown": 200,
|
|
158
|
+
"modal": 300,
|
|
159
|
+
"drawer": 400,
|
|
160
|
+
"reveal": 500,
|
|
161
|
+
"stagger": 60
|
|
162
|
+
},
|
|
163
|
+
"exitRatio": 0.75,
|
|
164
|
+
"contrast": { "minWcag": 4.5, "minLc": 60, "deltaEOk": 0.02 }
|
|
165
|
+
}
|
|
166
|
+
```
|