@instacks/peak 0.0.0-stage → 1.0.1
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 +314 -2
- package/dist/peak-scheme.js +50 -0
- package/dist/peak.css +5352 -0
- package/dist/peak.min.css +22 -0
- package/dist/peak.scoped.css +5396 -0
- package/dist/peak.scoped.min.css +23 -0
- package/package.json +81 -4
- package/tokens.json +717 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Futural UG (haftungsbeschränkt)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,315 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Peak
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@instacks/peak)
|
|
4
|
+
|
|
5
|
+
A zero-JS CSS layer on top of [Blades CSS](https://blades.dev/) (a Pico CSS fork): a small set of
|
|
6
|
+
`--peak-*` inputs generates the whole palette, type and spacing, with native popovers, anchor
|
|
7
|
+
positioning and entry/exit transitions.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@instacks/peak/dist/peak.min.css" />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or `npm install @instacks/peak` and import `@instacks/peak` (minified) or
|
|
14
|
+
`@instacks/peak/unminified`.
|
|
15
|
+
|
|
16
|
+
**Documentation:** <https://instacks.github.io/peak/>, with live examples of every component, a
|
|
17
|
+
token reference and a customizer that writes your theme's CSS. Build it locally with
|
|
18
|
+
`npm run build && npm run docs` (output in `_site/`, `npm run docs:serve` to browse it).
|
|
19
|
+
|
|
20
|
+
### Scoped build
|
|
21
|
+
|
|
22
|
+
`peak.scoped.css` (`@instacks/peak/scoped`) styles only what's inside `.peak`, and skips anything
|
|
23
|
+
inside `.peak-ignore`. Use it where other code shares the page, such as third-party stacks in a
|
|
24
|
+
Stacks 6 site:
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@instacks/peak/dist/peak.scoped.min.css" />
|
|
28
|
+
|
|
29
|
+
<body>
|
|
30
|
+
<header class="peak">…</header>
|
|
31
|
+
<main class="peak">
|
|
32
|
+
…
|
|
33
|
+
<div class="peak-ignore">A third-party stack, left alone</div>
|
|
34
|
+
</main>
|
|
35
|
+
</body>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- Inputs work the same in both builds: set them on `:root`, `.peak`, `[data-theme]` or
|
|
39
|
+
`[data-peak-scope]`. Only `--peak-*` defaults are declared outside the scope.
|
|
40
|
+
- Inherited properties (color, font) still flow into `.peak-ignore`; nothing else does.
|
|
41
|
+
- `rem` refers to `<html>`. On a nested `.peak` the fluid root size is off, so text, headings and
|
|
42
|
+
spacing stay in proportion; put `class="peak"` on `<html>` to get it back.
|
|
43
|
+
- Needs `@scope`: Chrome/Edge 118+, Safari 17.4+, Firefox 146+. Older browsers ignore the whole
|
|
44
|
+
stylesheet, so the global build is the safer choice for a public site that must support them.
|
|
45
|
+
|
|
46
|
+
## Theming
|
|
47
|
+
|
|
48
|
+
Set inputs on `:root`, or on any `[data-theme]` or `[data-peak-scope]` element for one section:
|
|
49
|
+
|
|
50
|
+
```css
|
|
51
|
+
:root {
|
|
52
|
+
--peak-hue: 160;
|
|
53
|
+
--peak-chroma: 0.12;
|
|
54
|
+
--peak-radius: 0.75rem;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<section data-peak-scope style="--peak-hue: 30">…</section>
|
|
60
|
+
<section data-theme="dark">…</section>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
For designs the derived palette can't match, exact light and dark values replace the derived page
|
|
64
|
+
background, surfaces, text, headings, muted text, borders and the secondary fill. Each is outside
|
|
65
|
+
the contrast guarantee:
|
|
66
|
+
|
|
67
|
+
```css
|
|
68
|
+
:root {
|
|
69
|
+
--peak-bg-light: #fafaf7;
|
|
70
|
+
--peak-bg-dark: #0e1113;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
<!-- tokens:start (generated from tokens.json) -->
|
|
75
|
+
| Input | Default | Range | |
|
|
76
|
+
|---|---|---|---|
|
|
77
|
+
| `--peak-logo-size` | `2rem` | 1–4rem | Logo size. Height of the logo image in the site title |
|
|
78
|
+
| `--peak-hue` | `250` | 0–360 | Brand hue. OKLCH hue of the brand color |
|
|
79
|
+
| `--peak-chroma` | `0.16` | 0–0.3 | Brand saturation. OKLCH chroma of the brand color |
|
|
80
|
+
| `--peak-brand` | unset | any color | Brand color. Picker path: takes hue and chroma from any color and overrides the two above. Lightness is still set per scheme |
|
|
81
|
+
| `--peak-neutral-chroma` | `0.012` | 0–0.04 | Neutral tint. Tints surfaces, text and borders toward the brand hue (or the neutral hue) |
|
|
82
|
+
| `--peak-neutral-hue` | unset | 0–360 | Neutral hue. Hue of the neutral tint (surfaces, text, borders, contrast); unset follows the brand hue |
|
|
83
|
+
| `--peak-neutral-hue-dark` | unset | 0–360 | Dark neutral hue. Hue of the dark scheme's surfaces and borders, e.g. warm paper in light mode and a cool night in dark mode; unset follows the neutral hue |
|
|
84
|
+
| `--peak-ink-hue` | unset | 0–360 | Text hue. Hue of text, headings, muted text and the contrast color; unset follows the neutral ramp |
|
|
85
|
+
| `--peak-ink-chroma` | `0.012` | 0–0.04 | Text tint. OKLCH chroma of text; applies only with `--peak-ink-hue` |
|
|
86
|
+
| `--peak-secondary-hue` | unset | 0–360 | Secondary hue. Makes secondary a color of its own; unset, secondary is the neutral ramp tinted four times as strongly |
|
|
87
|
+
| `--peak-secondary-chroma` | `0.05` | 0–0.3 | Secondary saturation. OKLCH chroma of the secondary color; applies only with `--peak-secondary-hue` |
|
|
88
|
+
| `--peak-accent-hue` | `40` | 0–360 | Accent hue. Hue of the accent color, for highlights used sparingly (badges, icons) |
|
|
89
|
+
| `--peak-accent-chroma` | `0.18` | 0–0.25 | Accent saturation. OKLCH chroma of the accent color |
|
|
90
|
+
| `--peak-accent-color` | unset | any color | Accent color. Picker path for the accent, like `--peak-brand`: hue and chroma come from the color (chroma capped at 0.25), lightness is set per use |
|
|
91
|
+
| `--peak-success-hue` | `150` | 0–360 | Success hue. Valid fields, `<ins>` |
|
|
92
|
+
| `--peak-warning-hue` | `80` | 0–360 | Warning hue. `<mark>` |
|
|
93
|
+
| `--peak-danger-hue` | `27` | 0–360 | Danger hue. Invalid fields, `<del>` |
|
|
94
|
+
| `--peak-info-hue` | `235` | 0–360 | Info hue |
|
|
95
|
+
| `--peak-status-chroma` | `0.15` | 0–0.25 | Status saturation. Shared by the four status colors |
|
|
96
|
+
| `--peak-dark-fills` | `0` | 0 or 1 | Deep fills in dark mode. 1: primary and secondary buttons keep the light scheme's deep fill with white text in dark mode, instead of a light fill with dark text |
|
|
97
|
+
| `--peak-bg-light` | unset | any color | Page background, light. Exact light-scheme color for `--peak-bg`, the page background; outside the contrast guarantee. Unset: derived |
|
|
98
|
+
| `--peak-bg-dark` | unset | any color | Page background, dark. Exact dark-scheme color for `--peak-bg`, the page background; outside the contrast guarantee. Unset: derived |
|
|
99
|
+
| `--peak-surface-light` | unset | any color | Surface, light. Exact light-scheme color for `--peak-surface`: cards, inputs, menus; outside the contrast guarantee. Unset: derived |
|
|
100
|
+
| `--peak-surface-dark` | unset | any color | Surface, dark. Exact dark-scheme color for `--peak-surface`: cards, inputs, menus; outside the contrast guarantee. Unset: derived |
|
|
101
|
+
| `--peak-text-light` | unset | any color | Text, light. Exact light-scheme color for `--peak-text`, body text; outside the contrast guarantee. Unset: derived |
|
|
102
|
+
| `--peak-text-dark` | unset | any color | Text, dark. Exact dark-scheme color for `--peak-text`, body text; outside the contrast guarantee. Unset: derived |
|
|
103
|
+
| `--peak-heading-light` | unset | any color | Headings, light. Exact light-scheme color for `--peak-heading` and every heading level; outside the contrast guarantee. Unset: derived |
|
|
104
|
+
| `--peak-heading-dark` | unset | any color | Headings, dark. Exact dark-scheme color for `--peak-heading` and every heading level; outside the contrast guarantee. Unset: derived |
|
|
105
|
+
| `--peak-muted-light` | unset | any color | Muted text, light. Exact light-scheme color for `--peak-muted`: captions, placeholders, hints; outside the contrast guarantee. Unset: derived |
|
|
106
|
+
| `--peak-muted-dark` | unset | any color | Muted text, dark. Exact dark-scheme color for `--peak-muted`: captions, placeholders, hints; outside the contrast guarantee. Unset: derived |
|
|
107
|
+
| `--peak-border-light` | unset | any color | Borders, light. Exact light-scheme color for `--peak-border`: rules, card and table borders; outside the contrast guarantee. Unset: derived |
|
|
108
|
+
| `--peak-border-dark` | unset | any color | Borders, dark. Exact dark-scheme color for `--peak-border`: rules, card and table borders; outside the contrast guarantee. Unset: derived |
|
|
109
|
+
| `--peak-secondary-fill-light` | unset | any color | Secondary fill, light. Exact light-scheme color for `--peak-secondary-fill`: secondary buttons; outside the contrast guarantee. Unset: derived |
|
|
110
|
+
| `--peak-secondary-fill-dark` | unset | any color | Secondary fill, dark. Exact dark-scheme color for `--peak-secondary-fill`: secondary buttons; outside the contrast guarantee. Unset: derived |
|
|
111
|
+
| `--peak-font-family` | unset | System, Humanist sans, Geometric sans, Transitional serif, Old-style serif, Monospace | Font. Body font stack; unset uses Blades' system stack |
|
|
112
|
+
| `--peak-font-family-heading` | unset | Same as body, Humanist sans, Geometric sans, Transitional serif, Old-style serif, Monospace | Heading font. Unset uses `--peak-font-family` |
|
|
113
|
+
| `--peak-font-family-mono` | unset | System, Code, Typewriter | Monospace font. Font stack for code, kbd, pre and samp; unset uses Blades' monospace stack |
|
|
114
|
+
| `--peak-font-size-min` | `1rem` | 0.875–1.125rem | Text size, small screens. Lower bound of the fluid root size `0.875rem + 0.5vw` |
|
|
115
|
+
| `--peak-font-size-max` | `1.3125rem` | 1–1.5rem | Text size, large screens. Upper bound of the fluid root size |
|
|
116
|
+
| `--peak-type-ratio` | `1.15` | 1.05–1.5 | Heading scale. h6 is 1rem, each level up multiplies by this |
|
|
117
|
+
| `--peak-line-height` | `1.5` | 1.2–1.9 | Line height |
|
|
118
|
+
| `--peak-heading-line-height` | `1.2` | 1–1.5 | Heading line height. Line height of `h4`; each level up is 0.025 tighter, each level down 0.025 looser, as in Blades |
|
|
119
|
+
| `--peak-font-weight` | `400` | 300–500 | Font weight |
|
|
120
|
+
| `--peak-heading-font-weight` | `700` | 400–900 | Heading weight |
|
|
121
|
+
| `--peak-display-weight` | unset | 300–900 | H1 weight. Weight of `h1` and `.peak-display`; unset follows `--peak-heading-font-weight` |
|
|
122
|
+
| `--peak-subheading-font-weight` | unset | 300–900 | H4–h6 weight. Weight of `h4`–`h6`; unset follows `--peak-heading-font-weight` |
|
|
123
|
+
| `--peak-heading-tracking` | `0em` | -0.05–0.05em | Heading letter-spacing. Letter-spacing of `h2`–`h4` and the site title; `h1` gets 4/3 of it and `.peak-display` 5/3, `h5`/`h6` none |
|
|
124
|
+
| `--peak-display-size-min` | `2.25rem` | 1.5–3rem | Display size, small screens. Lower bound of `.peak-display`'s fluid size `1rem + 4vw` |
|
|
125
|
+
| `--peak-display-size-max` | `3.5rem` | 2.5–5rem | Display size, large screens. Upper bound of `.peak-display`'s fluid size |
|
|
126
|
+
| `--peak-button-font-weight` | unset | 300–800 | Button weight. Weight of buttons; unset follows the body weight |
|
|
127
|
+
| `--peak-font-smoothing` | `auto` | System default, Antialiased | Font smoothing. `antialiased` renders lighter, thinner text on macOS (WebKit and Chromium) |
|
|
128
|
+
| `--peak-code-max-height` | unset | 10–50rem | Code block height. Maximum height of `pre`; taller blocks scroll. Unset: no limit |
|
|
129
|
+
| `--peak-spacing` | `1rem` | 0.5–2rem | Spacing. Base rhythm: block spacing, grid gaps, `--peak-space-*` |
|
|
130
|
+
| `--peak-section-spacing` | unset | 1–8rem | Section spacing. Space after each `section`; unset follows `--peak-spacing` |
|
|
131
|
+
| `--peak-density` | `1` | 0.75–1.25 | Density. Multiplies form, nav and text spacing |
|
|
132
|
+
| `--peak-radius` | `0.375rem` | 0–1.5rem | Corner radius |
|
|
133
|
+
| `--peak-border-width` | `0.0625rem` | 0–0.25rem | Border width |
|
|
134
|
+
| `--peak-outline-width` | `0.125rem` | 0.0625–0.25rem | Focus ring width |
|
|
135
|
+
| `--peak-container-sm` | `510px` | 360–544px | Content width ≥ 576px. `.container` width from the 576px breakpoint |
|
|
136
|
+
| `--peak-container-md` | `700px` | 480–736px | Content width ≥ 768px |
|
|
137
|
+
| `--peak-container-lg` | `950px` | 640–992px | Content width ≥ 1024px |
|
|
138
|
+
| `--peak-container-xl` | `1200px` | 800–1248px | Content width ≥ 1280px |
|
|
139
|
+
| `--peak-container-2xl` | `1450px` | 960–1504px | Content width ≥ 1536px |
|
|
140
|
+
| `--peak-container-max` | `1450px` | 600–2000px | Maximum content width. Caps every breakpoint |
|
|
141
|
+
| `--peak-measure` | `65ch` | 40–90ch | Text width. Maximum line length of `.peak-lead` and other running text |
|
|
142
|
+
| `--peak-grid-min` | `15rem` | 8–30rem | Grid column minimum. Narrowest column of `.peak-grid-auto`, which fits as many columns as there is room for; set it per grid with `style="--peak-grid-min: …"` |
|
|
143
|
+
| `--peak-sidebar-width` | `16rem` | 10–24rem | Sidebar width. Width of the aside in `.peak-with-sidebar` (and the theme's sidebar navigation); set it per layout with `style="--peak-sidebar-width: …"` |
|
|
144
|
+
| `--peak-duration` | `200ms` | 0–600ms | Transition duration. 0s under `prefers-reduced-motion: reduce` |
|
|
145
|
+
| `--peak-easing` | `ease-in-out` | Ease in-out, Ease, Ease out, Emphasized, Linear | Transition easing |
|
|
146
|
+
<!-- tokens:end -->
|
|
147
|
+
|
|
148
|
+
Lightness is pinned per color scheme, so every text/background pair meets WCAG 2 contrast for any
|
|
149
|
+
hue, chroma, neutral tint and status hue in the ranges above (checked by `test/contrast.test.mjs`).
|
|
150
|
+
|
|
151
|
+
Derived tokens are readable in your own CSS: `--peak-bg`, `--peak-surface`,
|
|
152
|
+
`--peak-surface-raised`, `--peak-surface-sunken`, `--peak-text`, `--peak-heading`,
|
|
153
|
+
`--peak-muted`, `--peak-border`, `--peak-border-strong`, `--peak-primary` (with `-hover`,
|
|
154
|
+
`-hover-bg`, `-focus`, `-subtle`, `-underline`, and `--peak-on-primary`), the same for
|
|
155
|
+
`secondary` and `contrast`, `--peak-accent` (with `-hover`, `-fill`, `-hover-bg`, `-subtle`,
|
|
156
|
+
and `--peak-on-accent`), `--peak-{success,warning,danger,info}` (with `-hover`, `-subtle`,
|
|
157
|
+
`-border`, `--peak-on-*`), `--peak-h1` … `--peak-h6`, and `--peak-space-3xs` … `--peak-space-3xl`.
|
|
158
|
+
|
|
159
|
+
Peak lives in sub-layers of `@layer peak`, after `@layer blades`:
|
|
160
|
+
`peak.tokens`, `peak.base`, `peak.layout`, `peak.components`, `peak.utilities` (later ones win).
|
|
161
|
+
Any unlayered CSS overrides all of them; to slot your own rules between Peak's, write them into
|
|
162
|
+
a Peak sub-layer, e.g. `@layer peak.components { … }`.
|
|
163
|
+
|
|
164
|
+
## Layout, cards and badges
|
|
165
|
+
|
|
166
|
+
```html
|
|
167
|
+
<!-- As many columns of at least --peak-grid-min (15rem) as fit; cards line up, footers at the bottom -->
|
|
168
|
+
<div class="peak-grid-auto" style="--peak-grid-min: 18rem">
|
|
169
|
+
<article>
|
|
170
|
+
<header><small>Content</small> <span class="peak-badge accent">New</span></header>
|
|
171
|
+
<h3>Poster CMS</h3>
|
|
172
|
+
<p>Blog and multi-purpose content.</p>
|
|
173
|
+
<footer><a href="/poster/" class="peak-card-link">Learn more →</a></footer>
|
|
174
|
+
</article>
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<!-- A wrapping row; the gap is a per-element knob -->
|
|
178
|
+
<div class="peak-cluster align-end" style="--peak-gap: 2rem">…</div>
|
|
179
|
+
|
|
180
|
+
<!-- Full-bleed background band, content stays in the container; a hero -->
|
|
181
|
+
<section class="peak-band"><section class="peak-hero">…</section></section>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
More layouts: `.peak-grid` (at most `--peak-cols` columns, fewer when narrow; `.peak-span-2`,
|
|
185
|
+
`-3`, `-full`), `.peak-with-sidebar` (an `aside` beside the content, wrapping when narrow;
|
|
186
|
+
`.sticky`), `.peak-media` (image beside text), `.peak-switcher` (one row from
|
|
187
|
+
`--peak-switch-at`, 40rem, all stacked below it) and `.peak-card.horizontal` (its image beside
|
|
188
|
+
the content from a 32rem card width, a container query).
|
|
189
|
+
|
|
190
|
+
```html
|
|
191
|
+
<!-- Tabs from exclusive details, CSS only (an accordion where ::details-content is missing) -->
|
|
192
|
+
<div class="peak-tabs">
|
|
193
|
+
<details name="tabs" open><summary>Overview</summary><p>…</p></details>
|
|
194
|
+
<details name="tabs"><summary>Specs</summary><p>…</p></details>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<!-- Chips: a link, a filter (hidden checkbox), removable; a callout -->
|
|
198
|
+
<label class="peak-chip"><input type="checkbox"> Poster CMS</label>
|
|
199
|
+
<aside class="peak-callout warning"><strong>Heads up</strong><p>…</p></aside>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Accordions (`<details>`, exclusive with `name`, grouped in `.peak-accordion`) open and close with
|
|
203
|
+
an animation where the browser supports it, except with reduced motion. Callouts take the badge
|
|
204
|
+
variants.
|
|
205
|
+
|
|
206
|
+
`.peak-card-link` on one link makes the whole card clickable (other links stay clickable) and
|
|
207
|
+
lifts it on hover. Badges: `.peak-badge` with `.secondary`, `.contrast`, `.accent`, `.success`,
|
|
208
|
+
`.warning`, `.danger`, `.info`, plus `.solid`, `.outline`, `.dot`. `.peak-card` gives any element
|
|
209
|
+
the card look. All of these classes also work on a Stacks container stack's class field.
|
|
210
|
+
|
|
211
|
+
## Typography
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<!-- An eyebrow line before a heading: classless inside hgroup -->
|
|
215
|
+
<hgroup>
|
|
216
|
+
<p>Mock-up</p>
|
|
217
|
+
<h2>Our stacks</h2>
|
|
218
|
+
</hgroup>
|
|
219
|
+
<p class="peak-eyebrow secondary">Elsewhere, with the class</p>
|
|
220
|
+
|
|
221
|
+
<!-- Display headline (fluid, above h1) and a lead paragraph -->
|
|
222
|
+
<h1 class="peak-display">Stacks that <span class="peak-text-primary">just work</span></h1>
|
|
223
|
+
<p class="peak-lead">One step of the type scale up, muted, at a readable width.</p>
|
|
224
|
+
|
|
225
|
+
<!-- A heading's size apart from its level; tabular numbers -->
|
|
226
|
+
<h3 class="peak-h5">Small h3</h3>
|
|
227
|
+
<p class="peak-tabular">€ 49,00 · 1.284 downloads</p>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Code blocks that scroll get a shade along each edge with more code beyond it (CSS only).
|
|
231
|
+
`.peak-prose` sets running text (CMS output) at a readable width with media and tables that fit;
|
|
232
|
+
`<a class="peak-anchor" href="#id">#</a>` in a heading is a link to it, shown on hover and focus.
|
|
233
|
+
|
|
234
|
+
Text colors: `.peak-text-primary`, `-secondary`, `-contrast`, `-muted`, `-success`, `-danger`,
|
|
235
|
+
`-info`. Headings get balanced line breaks, letter-spacing from `--peak-heading-tracking` (h1 4/3
|
|
236
|
+
of it, `.peak-display` 5/3) and Blades' per-level line heights around `--peak-heading-line-height`.
|
|
237
|
+
Optional weights for h1 (`--peak-display-weight`), h4–h6 (`--peak-subheading-font-weight`) and
|
|
238
|
+
buttons (`--peak-button-font-weight`) fall back to the heading or body weight while unset.
|
|
239
|
+
|
|
240
|
+
## Components
|
|
241
|
+
|
|
242
|
+
All of these work without JavaScript.
|
|
243
|
+
|
|
244
|
+
```html
|
|
245
|
+
<!-- Menu, anchored to its button, flips at the viewport edges -->
|
|
246
|
+
<button popovertarget="actions">Actions</button>
|
|
247
|
+
<ul id="actions" popover>
|
|
248
|
+
<li><a href="#">Edit</a></li>
|
|
249
|
+
</ul>
|
|
250
|
+
|
|
251
|
+
<!-- Generic popover: centered by default, anchored with data-peak-anchor -->
|
|
252
|
+
<span data-peak-anchor>
|
|
253
|
+
<button popovertarget="info">Info</button>
|
|
254
|
+
<div id="info" popover>…</div>
|
|
255
|
+
</span>
|
|
256
|
+
|
|
257
|
+
<!-- Dialog that fades in and out -->
|
|
258
|
+
<button command="show-modal" commandfor="d">Open</button>
|
|
259
|
+
<dialog id="d" closedby="any"><article>…</article></dialog>
|
|
260
|
+
|
|
261
|
+
<!-- Tooltips: anchored and flipping where supported -->
|
|
262
|
+
<span data-tooltip="Saved" data-placement="bottom">Status</span>
|
|
263
|
+
|
|
264
|
+
<!-- Legacy dropdowns keep Pico's positioning unless opted in -->
|
|
265
|
+
<details class="dropdown" data-peak-anchor>…</details>
|
|
266
|
+
|
|
267
|
+
<!-- A drawer at the inline end (.start for the other side); also dialog.peak-wide, .peak-full -->
|
|
268
|
+
<dialog class="peak-drawer" id="cart"><article>…</article></dialog>
|
|
269
|
+
|
|
270
|
+
<!-- A toast in the corner; showing it after an action needs showPopover() -->
|
|
271
|
+
<div class="peak-toast success" popover="manual" role="status" id="saved">Saved.</div>
|
|
272
|
+
|
|
273
|
+
<!-- Stats, steps, avatars, pagination, sidebar navigation -->
|
|
274
|
+
<dl class="peak-stats"><div><dt>Downloads</dt><dd>1,284</dd></div></dl>
|
|
275
|
+
<ol class="peak-steps"><li>Download</li><li aria-current="step">Install</li><li>Activate</li></ol>
|
|
276
|
+
<span class="peak-avatar" role="img" aria-label="Ada Lovelace">AL</span>
|
|
277
|
+
<nav class="peak-pagination" aria-label="Pages"><ul><li><a aria-current="page">1</a></li>…</ul></nav>
|
|
278
|
+
<aside><nav class="peak-sidebar-nav"><ul><li><a aria-current="page">…</a></li></ul></nav></aside>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
One script ships for the one thing CSS can't do: `@instacks/peak/scheme` (`dist/peak-scheme.js`)
|
|
282
|
+
remembers a `<select class="peak-scheme">` light/dark choice across pages. Load it in `<head>`
|
|
283
|
+
without `defer`; the select works for the current page without it.
|
|
284
|
+
|
|
285
|
+
## Accessibility preferences
|
|
286
|
+
|
|
287
|
+
Peak follows the visitor's settings: reduced motion (no transitions, slides or animated
|
|
288
|
+
accordions), more contrast (muted text and borders get stronger), reduced transparency (no
|
|
289
|
+
blur behind dialogs), and forced colors such as Windows High Contrast (borders where shadows
|
|
290
|
+
drew a shape, outline focus rings, highlighted current and selected states). Printing uses the
|
|
291
|
+
light scheme, drops the site's navigation and shadows, and prints external link addresses in
|
|
292
|
+
prose.
|
|
293
|
+
|
|
294
|
+
## Browser support
|
|
295
|
+
|
|
296
|
+
Chrome/Edge 123+, Firefox 128+, Safari 18+. Anchor positioning, `@starting-style` and `overlay`
|
|
297
|
+
are progressive enhancements: without them, menus open centered and closing is instant.
|
|
298
|
+
|
|
299
|
+
## Development
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
npm ci
|
|
303
|
+
npm run build # dist/peak(.min).css and dist/peak.scoped(.min).css
|
|
304
|
+
npm run watch # rebuild on change
|
|
305
|
+
npm run tokens # after editing tokens.json: regenerate src/inputs.css and this table
|
|
306
|
+
npm test # Chromium checks; needs Playwright installed (see docs/PLAN.md §8.4)
|
|
307
|
+
npm run serve # http://localhost:8000/index.html
|
|
308
|
+
npm run docs # the documentation site, in _site/ (sources in site/)
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
See `docs/PLAN.md` for the design and roadmap.
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
MIT
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* peak-scheme.js: remembers Peak's light/dark switch across pages (docs: site/pages/theming.html).
|
|
3
|
+
*
|
|
4
|
+
* Load it in <head> as a classic script (no module, no defer), so a saved scheme is set on <html>
|
|
5
|
+
* before the first paint. It wires up every <select class="peak-scheme"> (values "", "light",
|
|
6
|
+
* "dark") and sets data-theme on <html> and on every .peak scope root. Without this script the
|
|
7
|
+
* switch still works for the current page: Peak's CSS reads the select with :has().
|
|
8
|
+
*/
|
|
9
|
+
(() => {
|
|
10
|
+
const KEY = "peak-scheme";
|
|
11
|
+
const valid = (value) => value === "light" || value === "dark";
|
|
12
|
+
let saved = null;
|
|
13
|
+
try {
|
|
14
|
+
saved = localStorage.getItem(KEY);
|
|
15
|
+
} catch {
|
|
16
|
+
// Storage blocked (private mode, settings): the switch still works on this page
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const apply = (value) => {
|
|
20
|
+
for (const root of [document.documentElement, ...document.querySelectorAll(".peak")]) {
|
|
21
|
+
if (valid(value)) root.setAttribute("data-theme", value);
|
|
22
|
+
else root.removeAttribute("data-theme");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
if (valid(saved)) document.documentElement.setAttribute("data-theme", saved);
|
|
27
|
+
|
|
28
|
+
const ready = () => {
|
|
29
|
+
const selects = [...document.querySelectorAll("select.peak-scheme")];
|
|
30
|
+
if (saved !== null) {
|
|
31
|
+
apply(saved);
|
|
32
|
+
for (const select of selects) select.value = valid(saved) ? saved : "";
|
|
33
|
+
}
|
|
34
|
+
for (const select of selects) {
|
|
35
|
+
select.addEventListener("change", () => {
|
|
36
|
+
const value = select.value;
|
|
37
|
+
try {
|
|
38
|
+
localStorage.setItem(KEY, valid(value) ? value : "");
|
|
39
|
+
} catch {
|
|
40
|
+
// See above
|
|
41
|
+
}
|
|
42
|
+
apply(value);
|
|
43
|
+
for (const other of selects) other.value = value;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", ready);
|
|
49
|
+
else ready();
|
|
50
|
+
})();
|