@hugocxl/design-system 0.1.0 → 0.2.7

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/system/p9.css DELETED
@@ -1,240 +0,0 @@
1
- /* Design system — the only stylesheet a page built with the system loads. Values mirror the DESIGN.md front matter. */
2
- @font-face {
3
- font-family: "Geist Sans";
4
- src: url("fonts/Geist-Variable.woff2") format("woff2");
5
- font-weight: 100 900;
6
- font-display: swap;
7
- }
8
- @font-face {
9
- font-family: "Geist Mono";
10
- src: url("fonts/GeistMono-Variable.woff2") format("woff2");
11
- font-weight: 100 900;
12
- font-display: swap;
13
- }
14
-
15
- /* ─── Tokens ─────────────────────────────────────────────────────────── */
16
- :root {
17
- /* Palette: Superlogical paper and orange with neutral greys. Muted meets WCAG AA. */
18
- --p9-canvas: #f5f5f4;
19
- --p9-ink: #171717;
20
- --p9-muted: #6e6e6e;
21
- --p9-faint: #b3b3b3;
22
- --p9-rule: #1717171f;
23
- --p9-surface: #ebebea;
24
- --p9-accent: #fe9369;
25
- --p9-accent-text: #ce7755;
26
-
27
- --p9-sans: "Geist Sans", Helvetica, Arial, sans-serif;
28
- --p9-mono: "Geist Mono", ui-monospace, Menlo, monospace;
29
-
30
- --p9-size-reading: min(calc(1rem + .36vw), 1.54rem);
31
- --p9-size-title: calc(var(--p9-size-reading) * 1.4);
32
- --p9-size-small: calc(var(--p9-size-reading) * .8);
33
- --p9-size-control: 1rem;
34
- --p9-size-mono: .9375rem;
35
- --p9-size-label: .8125rem;
36
-
37
- --p9-space-1: .25rem;
38
- --p9-space-2: .5rem;
39
- --p9-space-3: .75rem;
40
- --p9-space-4: 1rem;
41
- --p9-space-5: 1.25rem;
42
- --p9-space-6: 2rem;
43
- --p9-space-7: 2.5rem;
44
- --p9-space-8: 3.5rem;
45
- --p9-space-9: 5rem;
46
- --p9-space-10: 8rem;
47
-
48
- --p9-radius-control: 6px;
49
- --p9-radius-media: 12px;
50
- --p9-radius-pill: 999px;
51
- --p9-target: 44px;
52
- --p9-measure: 30em;
53
- --p9-wide: 80rem;
54
- --p9-ease: 120ms ease-out;
55
-
56
- /* Hairline figure palette, derived from the theme. */
57
- --hairline-plate: var(--p9-canvas);
58
- --hairline-hi: var(--p9-ink);
59
- --hairline-edge: color-mix(in srgb, var(--p9-ink) 45%, var(--p9-canvas));
60
- --hairline-mid: color-mix(in srgb, var(--p9-ink) 22%, var(--p9-canvas));
61
- --hairline-lo: color-mix(in srgb, var(--p9-ink) 10%, var(--p9-canvas));
62
-
63
- accent-color: var(--p9-ink);
64
- color-scheme: light;
65
- }
66
- :root[data-theme=dark] {
67
- --p9-canvas: #111111;
68
- --p9-ink: #ededed;
69
- --p9-muted: #7d7d7d;
70
- --p9-faint: #737373;
71
- --p9-rule: #ededed24;
72
- --p9-surface: #1c1c1c;
73
- --p9-accent-text: #fe9369;
74
- color-scheme: dark;
75
- }
76
-
77
- /* ─── Shell and layout ───────────────────────────────────────────────── */
78
- .p9 {
79
- --p9-gutter: clamp(1.25rem, 4.5vw, 4rem);
80
- --p9-field: 0px;
81
- box-sizing: border-box;
82
- margin: 0;
83
- padding: 0 calc(var(--p9-field) + var(--p9-gutter)) 0 var(--p9-gutter);
84
- color: var(--p9-ink);
85
- background: var(--p9-canvas);
86
- font: 300 var(--p9-size-reading)/1.3 var(--p9-sans);
87
- letter-spacing: -.01em;
88
- -webkit-font-smoothing: antialiased;
89
- }
90
- .p9 *, .p9 *::before, .p9 *::after { box-sizing: border-box }
91
- .p9 main { container-type: inline-size }
92
- .p9 :where(h1, h2, h3, p, ol, ul, figure, pre, table) { margin: 0 }
93
- .p9[data-layout=field] { --p9-field: clamp(30vw, calc(100vw - 2 * var(--p9-gutter) - 47.6rem), 40vw) }
94
- .p9[data-layout=field]::after {
95
- content: "";
96
- position: fixed;
97
- inset: 12px 12px 12px auto;
98
- width: calc(var(--p9-field) - 12px);
99
- border-radius: var(--p9-radius-media);
100
- background: #777 url("images/gray-folds.png") center / cover;
101
- pointer-events: none;
102
- }
103
- .p9-column { max-width: var(--p9-measure); margin-inline: auto }
104
- .p9[data-layout=field] .p9-column { margin-inline: 0 }
105
- .p9-opening { padding-top: clamp(var(--p9-space-9), 8vw, var(--p9-space-10)) }
106
- .p9-wide {
107
- width: min(100cqw, var(--p9-wide));
108
- margin-block: var(--p9-space-8);
109
- margin-inline: calc((100% - min(100cqw, var(--p9-wide))) / 2);
110
- }
111
- .p9[data-layout=field] .p9-wide { margin-inline: 0 }
112
- @media (max-width: 760px) {
113
- .p9[data-layout=field] { --p9-field: 20px }
114
- .p9[data-layout=field]::after { inset: 6px 5px 6px auto; width: 12px; border-radius: 5px }
115
- }
116
-
117
- /* ─── Text ───────────────────────────────────────────────────────────── */
118
- .p9 :where(h1, h2, h3) { font: inherit; letter-spacing: inherit }
119
- .p9 :where(p, ul, ol, .p9-code, .p9-table, .p9-table-scroll) + :where(p, ul, ol, .p9-code, .p9-table, .p9-table-scroll) { margin-top: var(--p9-space-5) }
120
- .p9 p { text-wrap: pretty }
121
- .p9-section :where(ul:not([class]), ol:not([class])) { padding-left: 1.2em }
122
- .p9-section :where(ul:not([class]), ol:not([class])) > li + li { margin-top: var(--p9-space-2) }
123
- .p9 strong { font-weight: 500 }
124
- .p9 a { color: inherit; text-decoration-line: underline; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: .2em }
125
- .p9 a:hover { text-decoration-color: currentColor }
126
- .p9 :where(code, kbd, samp) { font-family: var(--p9-mono); font-size: .85em; font-weight: 400; letter-spacing: 0 }
127
- .p9 :focus-visible { outline: 2px solid var(--p9-ink); outline-offset: 3px }
128
- .p9-muted { color: var(--p9-muted) }
129
- .p9-accent { color: var(--p9-accent-text) }
130
- .p9-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0 }
131
-
132
- .p9-title { font-size: var(--p9-size-title); font-weight: 500; line-height: 1.15; letter-spacing: -.02em; text-wrap: balance }
133
- .p9-title > * { display: block }
134
- .p9-title > :not(:first-child) { color: var(--p9-muted) }
135
- .p9-statement { font-size: var(--p9-size-title); font-weight: 500; line-height: 1.15; letter-spacing: -.02em; text-wrap: balance }
136
-
137
- .p9-section { margin-top: var(--p9-space-7); scroll-margin-top: var(--p9-space-6) }
138
- .p9-section > h2 { margin-bottom: var(--p9-space-4); color: var(--p9-muted); font-weight: 400 }
139
- .p9-section h3 { font-weight: 400 }
140
-
141
- .p9-label { font: 400 var(--p9-size-label)/1.5 var(--p9-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--p9-muted) }
142
- .p9-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--p9-space-2) var(--p9-space-5); margin-top: var(--p9-space-6); list-style: none; padding: 0 }
143
- .p9-meta + * { margin-top: var(--p9-space-8) }
144
- .p9-dot { display: inline-block; width: .5rem; height: .5rem; margin-right: var(--p9-space-2); border-radius: 50%; background: var(--p9-accent); vertical-align: .05em }
145
-
146
- /* ─── Masthead and footer ────────────────────────────────────────────── */
147
- .p9-masthead { display: flex; align-items: center; gap: var(--p9-space-5); padding-top: var(--p9-space-6); font-size: var(--p9-size-small) }
148
- .p9-masthead a { display: inline-flex; align-items: center; min-height: var(--p9-target); text-decoration: none }
149
- .p9-masthead a:hover { text-decoration: underline }
150
- .p9-wordmark { margin-right: auto; font-size: 1.125rem; font-weight: 600; letter-spacing: -.055em }
151
- .p9-masthead .p9-wordmark:hover { text-decoration: none }
152
- @media (max-width: 480px) { .p9-masthead { gap: var(--p9-space-3) } }
153
- .p9-theme { flex: none; width: var(--p9-target); height: var(--p9-target); border: 1px solid var(--p9-rule); border-radius: 50%; color: inherit; background: transparent; font: inherit; cursor: pointer }
154
-
155
- .p9-footer { display: flex; align-items: center; gap: var(--p9-space-5); margin-top: var(--p9-space-9); padding-bottom: var(--p9-space-7); font: 400 var(--p9-size-mono)/1.4 var(--p9-mono); letter-spacing: 0 }
156
- .p9-footer::before { content: ""; order: 1; flex: 1; min-width: var(--p9-space-6); border-top: 1px solid var(--p9-rule) }
157
- .p9-footer ul { display: flex; flex-wrap: wrap; gap: var(--p9-space-2) var(--p9-space-5); margin: 0; padding: 0; list-style: none }
158
- .p9-footer ul:last-child { order: 2 }
159
- .p9-footer li + li { margin-top: 0 }
160
- .p9-footer a { text-decoration: none }
161
- .p9-footer a:hover { text-decoration: underline }
162
-
163
- /* ─── Figures ────────────────────────────────────────────────────────── */
164
- .p9-media { display: grid; place-items: center; aspect-ratio: 3 / 2; overflow: hidden; border-radius: var(--p9-radius-media); background: var(--p9-surface); --hairline-plate: var(--p9-surface) }
165
- .p9-media > [data-figure] { width: auto; height: 82%; max-width: 92%; aspect-ratio: 5 / 4 }
166
- .p9-media > img { width: 100%; height: 100%; object-fit: cover }
167
- .p9-caption { display: flex; align-items: center; justify-content: space-between; gap: var(--p9-space-4); min-height: var(--p9-target); margin-top: var(--p9-space-3) }
168
-
169
- .p9-grid { display: grid; grid-template-columns: repeat(var(--p9-cols, 3), minmax(0, 1fr)); list-style: none; padding: 0 }
170
- .p9-grid[data-columns="2"] { --p9-cols: 2 }
171
- .p9-grid[data-columns="4"] { --p9-cols: 4 }
172
- .p9-grid > li { display: flex; flex-direction: column; padding: 0 var(--p9-space-6) }
173
- .p9-grid > li:first-child { padding-left: 0 }
174
- .p9-grid > li:last-child { padding-right: 0 }
175
- .p9-grid > li + li { border-left: 1px solid var(--p9-rule) }
176
- .p9-grid [data-figure] { width: 100%; aspect-ratio: 5 / 4; margin-block: var(--p9-space-5) }
177
- .p9-grid h3 { margin-top: auto; font-weight: 400 }
178
- .p9-grid p { margin-top: var(--p9-space-2); font-size: var(--p9-size-small); line-height: 1.4; color: var(--p9-muted) }
179
- @container (max-width: 34rem) {
180
- .p9-grid { grid-template-columns: minmax(0, 1fr) }
181
- .p9-grid > li { padding: var(--p9-space-5) 0 }
182
- .p9-grid > li + li { border-left: 0; border-top: 1px solid var(--p9-rule) }
183
- }
184
-
185
- /* ─── Index list and table ───────────────────────────────────────────── */
186
- .p9-index { list-style: none; padding: 0; border-bottom: 1px solid var(--p9-rule) }
187
- .p9-index > li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--p9-space-2) var(--p9-space-5); padding-block: var(--p9-space-5); border-top: 1px solid var(--p9-rule) }
188
- .p9-index .p9-label { padding-top: .35em }
189
- .p9-index h3 { font-weight: 400 }
190
- .p9-index p { margin-top: var(--p9-space-2); color: var(--p9-muted) }
191
- @container (max-width: 30rem) { .p9-index > li { grid-template-columns: minmax(0, 1fr) } }
192
-
193
- .p9-table { width: 100%; border-collapse: collapse; font-size: var(--p9-size-small); font-variant-numeric: tabular-nums }
194
- .p9-table th { font: 400 var(--p9-size-label)/1.5 var(--p9-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--p9-muted); text-align: left }
195
- .p9-table :where(th, td) { padding: var(--p9-space-3) var(--p9-space-4) var(--p9-space-3) 0; border-bottom: 1px solid var(--p9-rule); vertical-align: top }
196
- .p9-table tbody th { font: inherit; letter-spacing: inherit; text-transform: none; color: var(--p9-ink) }
197
- .p9-table-scroll { overflow-x: auto }
198
-
199
- /* ─── Controls ───────────────────────────────────────────────────────── */
200
- .p9-button { display: inline-flex; align-items: center; gap: var(--p9-space-3); min-height: var(--p9-target); padding: 0 var(--p9-space-5); border: 0; border-radius: var(--p9-radius-control); color: var(--p9-canvas); background: var(--p9-ink); font: 400 var(--p9-size-control)/1 var(--p9-sans); letter-spacing: -.01em; text-decoration: none; cursor: pointer }
201
- .p9 a.p9-button { color: var(--p9-canvas); text-decoration: none }
202
- .p9-button:hover { opacity: .84 }
203
-
204
- .p9-form { margin-top: var(--p9-space-7) }
205
- .p9-form label { display: block }
206
- .p9-input { display: flex; align-items: center; max-width: 20em; margin-top: var(--p9-space-4); border-bottom: 1px solid var(--p9-rule) }
207
- .p9-input:hover, .p9-input:focus-within { border-color: color-mix(in srgb, var(--p9-ink) 40%, transparent) }
208
- .p9-input input { flex: 1; min-width: 0; min-height: var(--p9-target); padding: 0; border: 0; border-radius: 0; color: inherit; background: transparent; font: inherit; letter-spacing: inherit; appearance: none }
209
- .p9-input input::placeholder { color: var(--p9-faint) }
210
- .p9-input input:focus-visible { outline: none }
211
- .p9-input:has(input:focus-visible) { outline: 2px solid var(--p9-ink); outline-offset: 3px }
212
- .p9-input input[aria-invalid=true] { text-decoration: underline wavy var(--p9-muted) 1px; text-underline-offset: .25em }
213
- .p9-input button { flex: none; width: var(--p9-target); height: var(--p9-target); padding: 0; border: 0; color: var(--p9-muted); background: transparent; font: inherit; cursor: pointer }
214
- .p9-input button:hover { color: var(--p9-ink) }
215
- .p9-help { margin-top: var(--p9-space-5); color: var(--p9-muted) }
216
- .p9-feedback { display: block; margin-top: var(--p9-space-3); font-size: var(--p9-size-small) }
217
- .p9-feedback:empty { display: none }
218
-
219
- .p9-code { position: relative; border-radius: var(--p9-radius-control); background: var(--p9-surface) }
220
- .p9-code pre { padding: var(--p9-space-4) var(--p9-space-5); overflow-x: auto; font: 400 .8125rem/1.6 var(--p9-mono); letter-spacing: 0 }
221
- .p9-code pre code { font-size: inherit }
222
- .p9-code button { position: absolute; top: 0; right: 0; min-width: var(--p9-target); min-height: var(--p9-target); padding: 0 var(--p9-space-3); border: 0; border-radius: var(--p9-radius-control); color: var(--p9-ink); background: var(--p9-surface); font: 400 var(--p9-size-label)/1 var(--p9-mono); letter-spacing: .08em; text-transform: uppercase; cursor: pointer }
223
- .p9-code button:hover { text-decoration: underline }
224
-
225
- .p9-pager { display: inline-flex; padding: 2px; border: 1px solid var(--p9-rule); border-radius: var(--p9-radius-pill); background: var(--p9-canvas) }
226
- .p9-pager button { width: var(--p9-target); height: var(--p9-target); padding: 0; border: 0; border-radius: 50%; color: inherit; background: transparent; font: 400 1.1rem/1 var(--p9-sans); cursor: pointer }
227
- .p9-pager button:hover { background: var(--p9-surface) }
228
-
229
- @media (prefers-reduced-motion: no-preference) {
230
- .p9-button, .p9-pager button, .p9-input { transition: transform var(--p9-ease), background-color var(--p9-ease), border-color var(--p9-ease), opacity var(--p9-ease) }
231
- .p9-button:active, .p9-pager button:active { transform: scale(.96) }
232
- }
233
-
234
- /* Icons from @hugocxl/icons (Stroke): inline before a link, button or label, at the size and color of its text. */
235
- .p9-icon { display: inline-block; width: 1em; height: 1em; margin-inline-end: var(--p9-space-2); vertical-align: -.125em; flex: none }
236
-
237
- /* Vectors from @hugocxl/vectors: a 4:3 line illustration in place of a drawing, in ink. */
238
- .p9-vector { display: block; color: var(--p9-ink) }
239
- .p9-media > .p9-vector { width: auto; height: 82%; max-width: 92%; aspect-ratio: 4 / 3 }
240
- .p9-grid .p9-vector { width: 100%; height: auto; aspect-ratio: 4 / 3; margin-block: var(--p9-space-5) }
package/system/p9.js DELETED
@@ -1,30 +0,0 @@
1
- // Design system runtime: mounts [data-figure] drawings and wires .p9-code copy buttons.
2
- import * as figures from './figures/index.js';
3
-
4
- const mounted = new Map();
5
-
6
- export function show(element, name) {
7
- mounted.get(element)?.destroy();
8
- element.dataset.figure = name;
9
- mounted.set(element, figures[name](element));
10
- }
11
-
12
- export function mountFigures(root = document) {
13
- for (const element of root.querySelectorAll('[data-figure]')) {
14
- if (!mounted.has(element) && figures[element.dataset.figure]) show(element, element.dataset.figure);
15
- }
16
- }
17
-
18
- document.addEventListener('click', async event => {
19
- const button = event.target.closest('.p9-code button');
20
- if (!button) return;
21
- try {
22
- await navigator.clipboard.writeText(button.closest('.p9-code').querySelector('pre').textContent);
23
- button.textContent = 'Copied';
24
- } catch {
25
- button.textContent = 'Select to copy';
26
- }
27
- setTimeout(() => { button.textContent = 'Copy' }, 1600);
28
- });
29
-
30
- mountFigures();