@n1kname/components 0.14.0 → 0.16.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/package.json +4 -3
- package/src/AppShell.astro +412 -0
- package/src/FlowDiagram.astro +536 -0
- package/src/PeriodPicker.astro +264 -0
- package/src/SideNav.astro +188 -0
- package/src/icons.ts +34 -0
- package/src/page-change.css +41 -2
- package/src/period.js +160 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A period stepper: ‹ 2025 ›. Time is mostly read a step at a time, so the arrows do the common
|
|
4
|
+
* thing, and the period itself opens every period at once, in a grid. With `all`, the line ends in
|
|
5
|
+
* a choice covering every period ("All years"): forward from the newest period is all of them,
|
|
6
|
+
* and back from there is the newest again.
|
|
7
|
+
*
|
|
8
|
+
* With `param`, the choice lives in the address (?year=2025), so a link or a reload keeps it and
|
|
9
|
+
* Back steps back through it; "all" is no parameter at all. The periods are known at build time
|
|
10
|
+
* (`periods`) or set later from script with setPeriods() from period.js, such as years read from
|
|
11
|
+
* an API. Each change fires `period-change` on the element, with the period as `detail.value`
|
|
12
|
+
* ("all" for all of them).
|
|
13
|
+
*
|
|
14
|
+
* Keyboard: Tab reaches each part; in the list, the arrow keys move through the periods and
|
|
15
|
+
* Escape closes it.
|
|
16
|
+
*/
|
|
17
|
+
interface Props {
|
|
18
|
+
/** The address parameter that holds the choice. Leave it out to keep the choice in the page. */
|
|
19
|
+
param?: string;
|
|
20
|
+
/** Periods known at build time, oldest first. */
|
|
21
|
+
periods?: string[];
|
|
22
|
+
/** The words for a choice covering every period, such as "All years". Leave it out for none. */
|
|
23
|
+
all?: string;
|
|
24
|
+
/** The period chosen when the address says nothing: "all", or one of the periods. Default: all if there is one, otherwise the newest. */
|
|
25
|
+
initial?: string;
|
|
26
|
+
/** The words a screen reader hears. */
|
|
27
|
+
labels?: { name?: string; previous?: string; next?: string; list?: string };
|
|
28
|
+
/** Unique on the page. */
|
|
29
|
+
id?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const { param, periods = [], all, initial, labels = {}, id = 'period' } = Astro.props;
|
|
33
|
+
const words = { name: 'Period', previous: 'Previous', next: 'Next', list: 'Choose a period', ...labels };
|
|
34
|
+
const chevron = (d: string) =>
|
|
35
|
+
`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
36
|
+
const start = initial ?? (all ? 'all' : periods.at(-1));
|
|
37
|
+
const shown = start === 'all' ? all : start;
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
<div
|
|
41
|
+
class="period"
|
|
42
|
+
id={id}
|
|
43
|
+
data-period
|
|
44
|
+
data-param={param}
|
|
45
|
+
data-all={all}
|
|
46
|
+
data-value={start}
|
|
47
|
+
hidden={!periods.length}
|
|
48
|
+
>
|
|
49
|
+
<button type="button" class="step" data-step="-1" aria-label={words.previous}><Fragment set:html={chevron('m15 18-6-6 6-6')} /></button>
|
|
50
|
+
<button type="button" class="current" popovertarget={`${id}-list`} aria-haspopup="true" aria-expanded="false">
|
|
51
|
+
<span class="sr">{words.name}: </span><span class="label"><span class="sizer" aria-hidden="true">{shown}</span><span class="now">{shown}</span></span>
|
|
52
|
+
<svg class="chev" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"></path></svg>
|
|
53
|
+
</button>
|
|
54
|
+
<button type="button" class="step" data-step="1" aria-label={words.next}><Fragment set:html={chevron('m9 18 6-6-6-6')} /></button>
|
|
55
|
+
<div id={`${id}-list`} class="period-list" popover role="group" aria-label={words.list}>
|
|
56
|
+
{all && <button type="button" class="option all" data-value="all">{all}</button>}
|
|
57
|
+
<div class="periods">
|
|
58
|
+
{
|
|
59
|
+
[...periods].reverse().map((p) => (
|
|
60
|
+
<button type="button" class="option" data-value={p}>
|
|
61
|
+
{p}
|
|
62
|
+
</button>
|
|
63
|
+
))
|
|
64
|
+
}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<script>
|
|
70
|
+
import { wirePeriodPicker } from './period.js';
|
|
71
|
+
document.querySelectorAll<HTMLElement>('[data-period]').forEach(wirePeriodPicker);
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<style>
|
|
75
|
+
.period {
|
|
76
|
+
display: inline-flex;
|
|
77
|
+
align-items: stretch;
|
|
78
|
+
min-height: 40px;
|
|
79
|
+
border: 1px solid var(--c-border-strong);
|
|
80
|
+
border-radius: var(--radius-sm);
|
|
81
|
+
background: var(--c-surface);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.period[hidden] {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.period > button {
|
|
89
|
+
display: inline-flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
gap: var(--sp-2);
|
|
92
|
+
border: 0;
|
|
93
|
+
background: none;
|
|
94
|
+
color: var(--c-text);
|
|
95
|
+
font: inherit;
|
|
96
|
+
font-size: var(--text-body-sm);
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
transition:
|
|
100
|
+
background-color var(--motion-hover) var(--ease-hover),
|
|
101
|
+
color var(--motion-hover) var(--ease-hover);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.period > button:hover:not(:disabled) {
|
|
105
|
+
background: var(--c-surface-hover);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.period > button:active:not(:disabled) {
|
|
109
|
+
transform: scale(0.97);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.period > button:disabled {
|
|
113
|
+
color: var(--c-text-muted);
|
|
114
|
+
cursor: default;
|
|
115
|
+
opacity: 0.5;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.step {
|
|
119
|
+
padding: 0 var(--sp-2);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.step:first-child {
|
|
123
|
+
border-radius: var(--radius-sm) 0 0 var(--radius-sm);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.step:last-of-type {
|
|
127
|
+
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.current {
|
|
131
|
+
padding: 0 var(--sp-3);
|
|
132
|
+
border-inline: 1px solid var(--c-border) !important;
|
|
133
|
+
font-variant-numeric: tabular-nums;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* The period rolls: the old one leaves the way time went and the new one arrives from the
|
|
137
|
+
other side. The sizer, the longest words it may show, keeps the control's width still. */
|
|
138
|
+
.label {
|
|
139
|
+
display: inline-grid;
|
|
140
|
+
overflow: hidden;
|
|
141
|
+
justify-items: center;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.label > :global(span) {
|
|
145
|
+
grid-area: 1 / 1;
|
|
146
|
+
white-space: nowrap;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.sizer {
|
|
150
|
+
visibility: hidden;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.chev {
|
|
154
|
+
color: var(--c-text-muted);
|
|
155
|
+
transition: transform var(--motion-base) var(--ease-out);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.current[aria-expanded='true'] .chev {
|
|
159
|
+
transform: rotate(180deg);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.period-list {
|
|
163
|
+
position: fixed;
|
|
164
|
+
inset: auto;
|
|
165
|
+
margin: 0;
|
|
166
|
+
width: 17rem;
|
|
167
|
+
max-width: calc(100vw - 2 * var(--sp-4));
|
|
168
|
+
padding: var(--sp-2);
|
|
169
|
+
border: 1px solid var(--c-border-strong);
|
|
170
|
+
border-radius: var(--radius-md);
|
|
171
|
+
background: var(--c-surface);
|
|
172
|
+
color: var(--c-text);
|
|
173
|
+
box-shadow: 0 12px 32px rgb(0 0 0 / 0.18);
|
|
174
|
+
/* It opens on the spring from the control it belongs to, and leaves quicker. */
|
|
175
|
+
opacity: 0;
|
|
176
|
+
transform: translateY(-4px) scale(0.98);
|
|
177
|
+
transform-origin: top center;
|
|
178
|
+
transition:
|
|
179
|
+
opacity var(--motion-fast) var(--ease-standard),
|
|
180
|
+
transform var(--motion-fast) var(--ease-standard),
|
|
181
|
+
overlay var(--motion-fast) allow-discrete,
|
|
182
|
+
display var(--motion-fast) allow-discrete;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.period-list:popover-open {
|
|
186
|
+
opacity: 1;
|
|
187
|
+
transform: none;
|
|
188
|
+
transition:
|
|
189
|
+
opacity var(--motion-base) var(--ease-out),
|
|
190
|
+
transform var(--motion-spring) var(--ease-spring),
|
|
191
|
+
overlay var(--motion-spring) allow-discrete,
|
|
192
|
+
display var(--motion-spring) allow-discrete;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@starting-style {
|
|
196
|
+
.period-list:popover-open {
|
|
197
|
+
opacity: 0;
|
|
198
|
+
transform: translateY(-6px) scale(0.97);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.periods {
|
|
203
|
+
display: grid;
|
|
204
|
+
grid-template-columns: repeat(4, 1fr);
|
|
205
|
+
gap: 2px;
|
|
206
|
+
margin-top: 2px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* Periods set from script are made in the page, so :global reaches them. */
|
|
210
|
+
.period-list :global(.option) {
|
|
211
|
+
min-height: 36px;
|
|
212
|
+
border: 0;
|
|
213
|
+
border-radius: var(--radius-sm);
|
|
214
|
+
background: none;
|
|
215
|
+
color: var(--c-text-secondary);
|
|
216
|
+
font: inherit;
|
|
217
|
+
font-size: var(--text-body-sm);
|
|
218
|
+
font-variant-numeric: tabular-nums;
|
|
219
|
+
cursor: pointer;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.period-list :global(.option.all) {
|
|
223
|
+
width: 100%;
|
|
224
|
+
text-align: start;
|
|
225
|
+
padding-inline: var(--sp-3);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.period-list :global(.option:hover) {
|
|
229
|
+
background: var(--c-surface-hover);
|
|
230
|
+
color: var(--c-text);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.period-list :global(.option[aria-pressed='true']) {
|
|
234
|
+
background: var(--c-text);
|
|
235
|
+
color: var(--c-bg);
|
|
236
|
+
font-weight: 600;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.period-list :global(.option:focus-visible),
|
|
240
|
+
.period > button:focus-visible {
|
|
241
|
+
outline: 2px solid var(--c-focus);
|
|
242
|
+
outline-offset: -2px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.sr {
|
|
246
|
+
position: absolute;
|
|
247
|
+
width: 1px;
|
|
248
|
+
height: 1px;
|
|
249
|
+
overflow: hidden;
|
|
250
|
+
clip-path: inset(50%);
|
|
251
|
+
white-space: nowrap;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@media (prefers-reduced-motion: reduce) {
|
|
255
|
+
.period > button:active:not(:disabled) {
|
|
256
|
+
transform: none;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.period-list,
|
|
260
|
+
.period-list:popover-open {
|
|
261
|
+
transform: none;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
</style>
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Navigation down the side, in groups, for a site with more pages than a row holds, such as a
|
|
4
|
+
* dashboard's ten. With page-change.css, the current page's marker glides to the next page's
|
|
5
|
+
* link while the words and icons stay put above it. Usually inside AppShell, which gives it a
|
|
6
|
+
* column, a phone drawer and the button that folds it.
|
|
7
|
+
*
|
|
8
|
+
* Inside an element with data-nav-collapsed it shows its icons only: the words stay for a screen
|
|
9
|
+
* reader, and a pointer or keyboard on a link shows its name beside it.
|
|
10
|
+
*
|
|
11
|
+
* One with a marker per page: the marker's transition name must be unique, so a second copy of
|
|
12
|
+
* the same navigation (AppShell's drawer) leaves it out.
|
|
13
|
+
*/
|
|
14
|
+
import { ICONS, type IconName } from './icons';
|
|
15
|
+
|
|
16
|
+
interface Item {
|
|
17
|
+
href: string;
|
|
18
|
+
label: string;
|
|
19
|
+
icon?: IconName;
|
|
20
|
+
current?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Group {
|
|
24
|
+
label: string;
|
|
25
|
+
items: Item[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Props {
|
|
29
|
+
groups: Group[];
|
|
30
|
+
/** Names the navigation for a screen reader. */
|
|
31
|
+
label?: string;
|
|
32
|
+
/** Leave the gliding marker out, for a second copy of the same navigation. */
|
|
33
|
+
marker?: boolean;
|
|
34
|
+
/** The nav's id, and the start of its group labels' ids. */
|
|
35
|
+
id?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { groups, label = 'Pages', marker = true, id = 'side-nav' } = Astro.props;
|
|
39
|
+
const icon = (name?: IconName) =>
|
|
40
|
+
name
|
|
41
|
+
? `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ICONS[name]}</svg>`
|
|
42
|
+
: '';
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
<nav id={id} class:list={['side-nav', { glides: marker }]} aria-label={label} data-side-nav>
|
|
46
|
+
{
|
|
47
|
+
groups.map((g, i) => (
|
|
48
|
+
<div class="group">
|
|
49
|
+
<p class="group-label" id={`${id}-g${i}`}>
|
|
50
|
+
<span>{g.label}</span>
|
|
51
|
+
</p>
|
|
52
|
+
<ul aria-labelledby={`${id}-g${i}`}>
|
|
53
|
+
{g.items.map((item) => (
|
|
54
|
+
<li>
|
|
55
|
+
<a href={item.href} aria-current={item.current ? 'page' : undefined}>
|
|
56
|
+
{item.current && <span class="marker" aria-hidden="true" />}
|
|
57
|
+
<Fragment set:html={icon(item.icon)} />
|
|
58
|
+
<span class="label">{item.label}</span>
|
|
59
|
+
</a>
|
|
60
|
+
</li>
|
|
61
|
+
))}
|
|
62
|
+
</ul>
|
|
63
|
+
</div>
|
|
64
|
+
))
|
|
65
|
+
}
|
|
66
|
+
<span class="tip" aria-hidden="true" hidden></span>
|
|
67
|
+
</nav>
|
|
68
|
+
|
|
69
|
+
<script>
|
|
70
|
+
// Collapsed, a link's name appears beside it on hover and on keyboard focus. Measured, since
|
|
71
|
+
// the column it sits in scrolls and would clip anything that stuck out of it.
|
|
72
|
+
document.querySelectorAll<HTMLElement>('[data-side-nav]').forEach((nav) => {
|
|
73
|
+
const tip = nav.querySelector<HTMLElement>('.tip')!;
|
|
74
|
+
const show = (a: HTMLElement) => {
|
|
75
|
+
if (!nav.closest('[data-nav-collapsed]')) return;
|
|
76
|
+
const r = a.getBoundingClientRect();
|
|
77
|
+
tip.textContent = a.querySelector('.label')?.textContent ?? '';
|
|
78
|
+
tip.style.top = `${r.top + r.height / 2}px`;
|
|
79
|
+
tip.style.left = `${r.right + 8}px`;
|
|
80
|
+
tip.hidden = false;
|
|
81
|
+
};
|
|
82
|
+
const hide = () => (tip.hidden = true);
|
|
83
|
+
nav.addEventListener('pointerover', (e) => {
|
|
84
|
+
const a = (e.target as Element).closest<HTMLElement>('a');
|
|
85
|
+
if (a) show(a);
|
|
86
|
+
});
|
|
87
|
+
nav.addEventListener('pointerleave', hide);
|
|
88
|
+
nav.addEventListener('focusin', (e) => {
|
|
89
|
+
const a = (e.target as Element).closest<HTMLElement>('a');
|
|
90
|
+
if (a?.matches(':focus-visible')) show(a);
|
|
91
|
+
});
|
|
92
|
+
nav.addEventListener('focusout', hide);
|
|
93
|
+
nav.closest('[data-nav-scroll]')?.addEventListener('scroll', hide, { passive: true });
|
|
94
|
+
addEventListener('keydown', (e) => e.key === 'Escape' && hide());
|
|
95
|
+
});
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<style>
|
|
99
|
+
/* The tracks may be narrower than the words, so that collapsed, a link is as wide as its column
|
|
100
|
+
and the words are cut off inside it, not past it. */
|
|
101
|
+
.side-nav { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
|
|
102
|
+
.group-label {
|
|
103
|
+
position: relative;
|
|
104
|
+
margin: 0 0 var(--sp-1);
|
|
105
|
+
padding-inline: 11px;
|
|
106
|
+
font-size: var(--text-label);
|
|
107
|
+
font-weight: 600;
|
|
108
|
+
letter-spacing: 0.04em;
|
|
109
|
+
text-transform: uppercase;
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
color: var(--c-text-muted);
|
|
112
|
+
}
|
|
113
|
+
ul { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0; padding: 0; list-style: none; }
|
|
114
|
+
a {
|
|
115
|
+
position: relative;
|
|
116
|
+
isolation: isolate;
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
gap: var(--sp-3);
|
|
120
|
+
min-height: 36px;
|
|
121
|
+
/* 11px each side, so an icon sits in the middle of a 40px square, collapsed or not. */
|
|
122
|
+
padding: var(--sp-1) 11px;
|
|
123
|
+
border-radius: var(--radius-md);
|
|
124
|
+
font-size: var(--text-body-sm);
|
|
125
|
+
color: var(--c-text-secondary);
|
|
126
|
+
text-decoration: none;
|
|
127
|
+
white-space: nowrap;
|
|
128
|
+
transition:
|
|
129
|
+
color var(--motion-hover) var(--ease-hover),
|
|
130
|
+
background-color var(--motion-hover) var(--ease-hover);
|
|
131
|
+
}
|
|
132
|
+
a :global(svg) { flex: none; color: var(--c-text-muted); transition: color var(--motion-hover) var(--ease-hover); }
|
|
133
|
+
a:hover { color: var(--c-text); }
|
|
134
|
+
a:hover :global(svg) { color: var(--c-text-secondary); }
|
|
135
|
+
a:not([aria-current]):hover { background: var(--c-surface-hover); }
|
|
136
|
+
a:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
|
|
137
|
+
a[aria-current='page'] { color: var(--c-text); font-weight: 600; }
|
|
138
|
+
a[aria-current="page"] :global(svg) { color: var(--c-accent); }
|
|
139
|
+
.marker {
|
|
140
|
+
position: absolute;
|
|
141
|
+
inset: 0;
|
|
142
|
+
z-index: -1;
|
|
143
|
+
border: 1px solid var(--c-border);
|
|
144
|
+
border-radius: inherit;
|
|
145
|
+
background: var(--c-surface);
|
|
146
|
+
}
|
|
147
|
+
/* The words and icons are a layer of their own while the page changes, above the marker, so the
|
|
148
|
+
marker passes under them instead of over them (page-change.css). */
|
|
149
|
+
.glides { view-transition-name: side-nav; }
|
|
150
|
+
.glides .marker { view-transition-name: side-nav-current; }
|
|
151
|
+
|
|
152
|
+
/* Collapsed: icons only. The words fade, and the group names give way to a short rule, keeping
|
|
153
|
+
their height so no icon moves up or down. */
|
|
154
|
+
.label, .group-label > span { transition: opacity var(--motion-base) var(--ease-standard); }
|
|
155
|
+
.group-label::before {
|
|
156
|
+
content: '';
|
|
157
|
+
position: absolute;
|
|
158
|
+
top: 50%;
|
|
159
|
+
left: 11px;
|
|
160
|
+
width: 18px;
|
|
161
|
+
border-top: 1px solid var(--c-border-strong);
|
|
162
|
+
opacity: 0;
|
|
163
|
+
transition: opacity var(--motion-base) var(--ease-standard);
|
|
164
|
+
}
|
|
165
|
+
:global([data-nav-collapsed]) .label,
|
|
166
|
+
:global([data-nav-collapsed]) .group-label > span { opacity: 0; }
|
|
167
|
+
:global([data-nav-collapsed]) .group-label::before { opacity: 1; }
|
|
168
|
+
:global([data-nav-collapsed]) a { overflow: hidden; }
|
|
169
|
+
|
|
170
|
+
.tip {
|
|
171
|
+
position: fixed;
|
|
172
|
+
z-index: var(--z-panel);
|
|
173
|
+
translate: 0 -50%;
|
|
174
|
+
padding: var(--sp-1) var(--sp-2);
|
|
175
|
+
border-radius: var(--radius-sm);
|
|
176
|
+
background: var(--c-text);
|
|
177
|
+
color: var(--c-bg);
|
|
178
|
+
font-size: var(--text-caption);
|
|
179
|
+
font-weight: 600;
|
|
180
|
+
white-space: nowrap;
|
|
181
|
+
pointer-events: none;
|
|
182
|
+
}
|
|
183
|
+
/* No motion: a name you look for many times a day should just be there. */
|
|
184
|
+
.tip[hidden] { display: none; }
|
|
185
|
+
|
|
186
|
+
@media (pointer: coarse) { a { min-height: 44px; } }
|
|
187
|
+
@media (forced-colors: active) { .marker { border-color: CanvasText; } }
|
|
188
|
+
</style>
|
package/src/icons.ts
CHANGED
|
@@ -64,6 +64,40 @@ export const ICONS = {
|
|
|
64
64
|
'<path d="M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"/><path d="M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"/>',
|
|
65
65
|
'message-square':
|
|
66
66
|
'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',
|
|
67
|
+
'utility-pole':
|
|
68
|
+
'<path d="M12 2v20"/><path d="M2 5h20"/><path d="M3 3v2"/><path d="M7 3v2"/><path d="M17 3v2"/><path d="M21 3v2"/><path d="m19 5-7 7-7-7"/>',
|
|
69
|
+
'house-plug':
|
|
70
|
+
'<path d="M10 12V8.964"/><path d="M14 12V8.964"/><path d="M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z"/><path d="M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2"/>',
|
|
71
|
+
'building-2':
|
|
72
|
+
'<path d="M10 12h4"/><path d="M10 8h4"/><path d="M14 21v-3a2 2 0 0 0-4 0v3"/><path d="M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2"/><path d="M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16"/>',
|
|
73
|
+
car: '<path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2"/><circle cx="7" cy="17" r="2"/><path d="M9 17h6"/><circle cx="17" cy="17" r="2"/>',
|
|
74
|
+
// Pages in a side nav (a dashboard's), and the controls of AppShell and PeriodPicker.
|
|
75
|
+
'layout-dashboard':
|
|
76
|
+
'<rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/>',
|
|
77
|
+
calendar:
|
|
78
|
+
'<path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/>',
|
|
79
|
+
map:
|
|
80
|
+
'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>',
|
|
81
|
+
activity:
|
|
82
|
+
'<path d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"/>',
|
|
83
|
+
heart:
|
|
84
|
+
'<path d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5"/>',
|
|
85
|
+
moon:
|
|
86
|
+
'<path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/>',
|
|
87
|
+
dumbbell:
|
|
88
|
+
'<path d="M17.596 12.768a2 2 0 1 0 2.829-2.829l-1.768-1.767a2 2 0 0 0 2.828-2.829l-2.828-2.828a2 2 0 0 0-2.829 2.828l-1.767-1.768a2 2 0 1 0-2.829 2.829z"/><path d="m2.5 21.5 1.4-1.4"/><path d="m20.1 3.9 1.4-1.4"/><path d="M5.343 21.485a2 2 0 1 0 2.829-2.828l1.767 1.768a2 2 0 1 0 2.829-2.829l-6.364-6.364a2 2 0 1 0-2.829 2.829l1.768 1.767a2 2 0 0 0-2.828 2.829z"/><path d="m9.6 14.4 4.8-4.8"/>',
|
|
89
|
+
scale:
|
|
90
|
+
'<path d="M12 3v18"/><path d="m19 8 3 8a5 5 0 0 1-6 0zV7"/><path d="M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1"/><path d="m5 8 3 8a5 5 0 0 1-6 0zV7"/><path d="M7 21h10"/>',
|
|
91
|
+
menu:
|
|
92
|
+
'<path d="M4 5h16"/><path d="M4 12h16"/><path d="M4 19h16"/>',
|
|
93
|
+
'chevron-left':
|
|
94
|
+
'<path d="m15 18-6-6 6-6"/>',
|
|
95
|
+
'chevron-right':
|
|
96
|
+
'<path d="m9 18 6-6-6-6"/>',
|
|
97
|
+
'panel-left':
|
|
98
|
+
'<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/>',
|
|
99
|
+
x:
|
|
100
|
+
'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
|
|
67
101
|
} as const;
|
|
68
102
|
|
|
69
103
|
export type IconName = keyof typeof ICONS;
|
package/src/page-change.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Moving between pages: a short cross-fade of the whole page, PageNav's pill
|
|
3
|
-
* link you left to the one you arrived at, and a picture with view-transition-class: media (a
|
|
2
|
+
* Moving between pages: a short cross-fade of the whole page, PageNav's pill (or SideNav's
|
|
3
|
+
* marker) gliding from the link you left to the one you arrived at, and a picture with view-transition-class: media (a
|
|
4
4
|
* LinkCard's, say) growing into the picture of the same name on the next page, all on the spring. For a site whose pages are
|
|
5
5
|
* separate documents. Import once, per site, on every page: both pages must opt in.
|
|
6
6
|
*
|
|
@@ -36,6 +36,45 @@
|
|
|
36
36
|
height: 100%;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/* SideNav's marker, the same way. The column it sits in (AppShell's side-rail) holds still: it
|
|
40
|
+
* shows the new page's column at once, the marker glides over its background, and the words
|
|
41
|
+
* and icons (side-nav) lie on top, so the marker never covers them on its way. */
|
|
42
|
+
::view-transition-group(side-nav-current) {
|
|
43
|
+
z-index: 1;
|
|
44
|
+
animation-duration: var(--motion-spring);
|
|
45
|
+
animation-timing-function: var(--ease-spring);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
::view-transition-old(side-nav-current) {
|
|
49
|
+
animation: none;
|
|
50
|
+
opacity: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
::view-transition-new(side-nav-current) {
|
|
54
|
+
animation: none;
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 100%;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
::view-transition-group(side-rail),
|
|
60
|
+
::view-transition-group(side-nav) {
|
|
61
|
+
animation: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
::view-transition-group(side-nav) {
|
|
65
|
+
z-index: 2;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
::view-transition-old(side-rail),
|
|
69
|
+
::view-transition-old(side-nav) {
|
|
70
|
+
display: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
::view-transition-new(side-rail),
|
|
74
|
+
::view-transition-new(side-nav) {
|
|
75
|
+
animation: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
39
78
|
/* A picture that carries over, such as a case thumbnail becoming that case's header image. */
|
|
40
79
|
::view-transition-group(*.media) {
|
|
41
80
|
animation-duration: var(--motion-spring);
|