@bridgebrew/shell 0.0.0-stage → 0.0.2
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/browser/approvals.tsx +373 -0
- package/browser/browser.tsx +2025 -0
- package/browser/css.d.ts +2 -0
- package/browser/errors.tsx +552 -0
- package/browser/keep-focus.ts +65 -0
- package/browser/look.css +118 -0
- package/browser/look.ts +218 -0
- package/browser/mobile.css +305 -0
- package/browser/mobile.tsx +1528 -0
- package/browser/node-actions.ts +29 -0
- package/browser/notifications.ts +1264 -0
- package/browser/page-slot.ts +48 -0
- package/browser/restart-screen.tsx +156 -0
- package/browser/shell-state.ts +1800 -0
- package/browser/shell.d.ts +924 -0
- package/browser/shortcuts.ts +528 -0
- package/browser/theme-controls.tsx +379 -0
- package/browser/transition.ts +140 -0
- package/browser/tsconfig.json +15 -0
- package/browser/view-scopes.ts +75 -0
- package/browser/wallpaper-ink.ts +167 -0
- package/browser/window.css +9 -0
- package/package.json +89 -4
- package/tsconfig.json +5 -0
- package/README.md +0 -3
package/browser/look.css
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* The ink of a painted canvas (research-018 slice 8, research-028, ./look.ts): what its colours ask for (`data-ink`),
|
|
2
|
+
light as the prototype's `--canvas-fg` and `--canvas-muted`, or dark, on what sits on the canvas (`data-canvas-ink`:
|
|
3
|
+
the rail, the sidebar column, the dock); hover, active and borders a tint of it. None on the theme's own paint seeds:
|
|
4
|
+
the theme's ink. A surface of its own inside (`data-window-ink`: a dock chip, a field) takes the theme's tokens back,
|
|
5
|
+
kept at the root as `--theme-…`. A file, not a `<style>`: the page's CSP forbids inline styles. */
|
|
6
|
+
[data-slot='shell']:is([data-ink], [data-wallpaper]) {
|
|
7
|
+
--theme-fg: var(--fg);
|
|
8
|
+
--theme-fg-secondary: var(--fg-secondary);
|
|
9
|
+
--theme-fg-muted: var(--fg-muted);
|
|
10
|
+
--theme-fg-placeholder: var(--fg-placeholder);
|
|
11
|
+
--theme-bg-hover: var(--bg-hover);
|
|
12
|
+
--theme-bg-active: var(--bg-active);
|
|
13
|
+
--theme-border: var(--border);
|
|
14
|
+
--theme-border-subtle: var(--border-subtle);
|
|
15
|
+
--theme-border-input: var(--border-input);
|
|
16
|
+
}
|
|
17
|
+
[data-slot='shell']:is([data-ink='light'], [data-wallpaper]) {
|
|
18
|
+
--canvas-ink: oklch(96% 0.01 80);
|
|
19
|
+
--canvas-ink-secondary: oklch(89% 0.015 80);
|
|
20
|
+
--canvas-ink-muted: oklch(82% 0.02 80);
|
|
21
|
+
--canvas-ink-placeholder: oklch(74% 0.02 80);
|
|
22
|
+
}
|
|
23
|
+
[data-slot='shell'][data-ink='dark'] {
|
|
24
|
+
--canvas-ink: oklch(22% 0.01 260);
|
|
25
|
+
--canvas-ink-secondary: oklch(32% 0.012 260);
|
|
26
|
+
--canvas-ink-muted: oklch(40% 0.012 260);
|
|
27
|
+
--canvas-ink-placeholder: oklch(48% 0.01 260);
|
|
28
|
+
}
|
|
29
|
+
[data-slot='shell'][data-ink] [data-canvas-ink],
|
|
30
|
+
[data-slot='shell'][data-wallpaper] [data-slot='shell-sidebar'] {
|
|
31
|
+
--fg: var(--canvas-ink);
|
|
32
|
+
--fg-secondary: var(--canvas-ink-secondary);
|
|
33
|
+
--fg-muted: var(--canvas-ink-muted);
|
|
34
|
+
--fg-placeholder: var(--canvas-ink-placeholder);
|
|
35
|
+
--bg-hover: color-mix(in oklch, var(--canvas-ink) 10%, transparent);
|
|
36
|
+
--bg-active: color-mix(in oklch, var(--canvas-ink) 16%, transparent);
|
|
37
|
+
--border: color-mix(in oklch, var(--canvas-ink) 20%, transparent);
|
|
38
|
+
--border-subtle: color-mix(in oklch, var(--canvas-ink) 14%, transparent);
|
|
39
|
+
--border-input: color-mix(in oklch, var(--canvas-ink) 28%, transparent);
|
|
40
|
+
color: var(--fg);
|
|
41
|
+
}
|
|
42
|
+
[data-slot='shell'][data-ink] [data-canvas-ink] [data-window-ink],
|
|
43
|
+
[data-slot='shell'][data-wallpaper]
|
|
44
|
+
[data-slot='shell-sidebar']
|
|
45
|
+
:is([data-window-ink], [data-slot='badge']) {
|
|
46
|
+
text-shadow: none;
|
|
47
|
+
--fg: var(--theme-fg);
|
|
48
|
+
--fg-secondary: var(--theme-fg-secondary);
|
|
49
|
+
--fg-muted: var(--theme-fg-muted);
|
|
50
|
+
--fg-placeholder: var(--theme-fg-placeholder);
|
|
51
|
+
--bg-hover: var(--theme-bg-hover);
|
|
52
|
+
--bg-active: var(--theme-bg-active);
|
|
53
|
+
--border: var(--theme-border);
|
|
54
|
+
--border-subtle: var(--theme-border-subtle);
|
|
55
|
+
--border-input: var(--theme-border-input);
|
|
56
|
+
color: var(--fg);
|
|
57
|
+
}
|
|
58
|
+
/* A wallpaper (CAP-8, ./look.ts): the rail and the dock frosted panes floating over it as the windows do, the image
|
|
59
|
+
showing around them; the sidebar column nothing, the image as it is under it, the ink that reads on it
|
|
60
|
+
(`data-wallpaper-ink`, ./wallpaper-ink.ts: dark on a bright image, else light) over a soft shadow of the other; an empty stage's notice frosted whole. In the mode's tint (`light-dark()`, the theme's `color-scheme`), with the theme's ink: the tint keeps it at
|
|
61
|
+
4.5:1 or more on a white or a black image behind it. A pane is a pseudo-element behind its content (`z-index: -1` in
|
|
62
|
+
the shell's stacking context), so only the wallpaper is blurred; the dock's is inset by the room it keeps above it
|
|
63
|
+
(`pt-2`), its chips 6px in. Opaque where the browser cannot blur or the user asks for less transparency. Embedded in
|
|
64
|
+
the desktop app, the home rail's tint lies over the rail's room instead. */
|
|
65
|
+
[data-slot='shell'][data-wallpaper] {
|
|
66
|
+
--shell-frost: light-dark(rgb(250 250 252 / 0.72), rgb(14 14 20 / 0.65));
|
|
67
|
+
--shell-frost-filter: blur(24px) saturate(1.2);
|
|
68
|
+
}
|
|
69
|
+
[data-slot='shell'][data-wallpaper]
|
|
70
|
+
:is([data-slot='shell-rail'], [data-slot='windows-dock'])::before {
|
|
71
|
+
content: '';
|
|
72
|
+
position: absolute;
|
|
73
|
+
z-index: -1;
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
border-radius: var(--windows-radius, 12px);
|
|
76
|
+
background: var(--shell-frost);
|
|
77
|
+
backdrop-filter: var(--shell-frost-filter);
|
|
78
|
+
}
|
|
79
|
+
[data-slot='shell'][data-wallpaper] [data-slot='shell-rail'] {
|
|
80
|
+
position: relative;
|
|
81
|
+
}
|
|
82
|
+
[data-slot='shell'][data-wallpaper] [data-slot='shell-rail']::before {
|
|
83
|
+
inset: 8px 4px;
|
|
84
|
+
}
|
|
85
|
+
[data-slot='shell'][data-wallpaper] [data-slot='windows-dock'] {
|
|
86
|
+
height: 48px;
|
|
87
|
+
padding-left: 6px;
|
|
88
|
+
}
|
|
89
|
+
[data-slot='shell'][data-wallpaper] [data-slot='windows-dock']::before {
|
|
90
|
+
inset: 8px 0 0;
|
|
91
|
+
}
|
|
92
|
+
[data-slot='shell'][data-wallpaper] [data-slot='shell-sidebar'] {
|
|
93
|
+
text-shadow: 0 1px 2px rgb(0 0 0 / 0.55);
|
|
94
|
+
}
|
|
95
|
+
[data-slot='shell'][data-wallpaper][data-wallpaper-ink='dark'] {
|
|
96
|
+
--canvas-ink: oklch(22% 0.01 260);
|
|
97
|
+
--canvas-ink-secondary: oklch(32% 0.012 260);
|
|
98
|
+
--canvas-ink-muted: oklch(40% 0.012 260);
|
|
99
|
+
--canvas-ink-placeholder: oklch(48% 0.01 260);
|
|
100
|
+
}
|
|
101
|
+
[data-slot='shell'][data-wallpaper][data-wallpaper-ink='dark'] [data-slot='shell-sidebar'] {
|
|
102
|
+
text-shadow: 0 1px 2px rgb(255 255 255 / 0.45);
|
|
103
|
+
}
|
|
104
|
+
[data-slot='shell'][data-wallpaper] [data-slot='windows-empty'] {
|
|
105
|
+
background: var(--shell-frost);
|
|
106
|
+
backdrop-filter: var(--shell-frost-filter);
|
|
107
|
+
}
|
|
108
|
+
@supports not (backdrop-filter: blur(1px)) {
|
|
109
|
+
[data-slot='shell'][data-wallpaper] {
|
|
110
|
+
--shell-frost: light-dark(rgb(250 250 252), rgb(14 14 20));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
114
|
+
[data-slot='shell'][data-wallpaper] {
|
|
115
|
+
--shell-frost: light-dark(rgb(250 250 252), rgb(14 14 20));
|
|
116
|
+
--shell-frost-filter: none;
|
|
117
|
+
}
|
|
118
|
+
}
|
package/browser/look.ts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// A workspace's look on the shell's canvas (research-018 slice 8, the prototype's `.shell[data-paint]`; research-028):
|
|
2
|
+
// the paint (`@bridge/kernel/look`, as Settings' swatches of the look) behind the rail, the sidebar and the stage, and
|
|
3
|
+
// the ink drawn on it. Each colour is one value or a light and a dark one (`light-dark()`: the theme's `color-scheme`
|
|
4
|
+
// picks), a value left unset the theme's own: its paint seeds (`--paint-c1`, `--paint-c2`), its accent. The ink follows
|
|
5
|
+
// the mode: on the theme's seeds the theme's own ink; on a paint colour of the look's, the ink its lightness asks for
|
|
6
|
+
// (`inkOf`: light on a dark one, dark on a light one), on the parts marked `data-canvas-ink` (the rail, the sidebar
|
|
7
|
+
// column, the dock), whose own surfaces (`data-window-ink`: a dock chip, a field) get the theme's back (./look.css).
|
|
8
|
+
// The windows keep the theme's colours. No look, or `neutral`: the canvas as without one. `accent` rings the focused
|
|
9
|
+
// window (`--ws-accent`); the theme's accent stays everywhere else (white text on a mid-light accent would fall under
|
|
10
|
+
// 4.5:1). A wallpaper (CAP-8) is a paint of its own (`wallpaper`): laid by its fit in the window's box over the theme's
|
|
11
|
+
// canvas, its dark image in dark mode when it has one; the rail and the dock frosted over it (./look.css). Under another
|
|
12
|
+
// paint, the look keeps it unseen.
|
|
13
|
+
import { colourIn, modeColour, paintSeeds, paintStyles as paints } from '@bridge/kernel/look';
|
|
14
|
+
import type { WorkspaceLook, wallpaperFits } from '@bridge/kernel/status';
|
|
15
|
+
|
|
16
|
+
/** Each wallpaper fit (CAP-8), as a background layer's position, size and repeat, in the root's box: the window's
|
|
17
|
+
* (`fixed inset-0`). `tile` starts at its top left corner; the others are centred in it. */
|
|
18
|
+
const fits = {
|
|
19
|
+
cover: 'center / cover no-repeat',
|
|
20
|
+
contain: 'center / contain no-repeat',
|
|
21
|
+
tile: '0 0 / auto repeat',
|
|
22
|
+
centre: 'center / auto no-repeat',
|
|
23
|
+
} satisfies Record<(typeof wallpaperFits)[number], string>;
|
|
24
|
+
|
|
25
|
+
type Mode = 'light' | 'dark';
|
|
26
|
+
|
|
27
|
+
/** The paint `look` puts on the canvas, if any (`neutral`, none, or an unknown one: the theme's canvas). */
|
|
28
|
+
export const paintOf = (look: WorkspaceLook | undefined) =>
|
|
29
|
+
look?.paint !== undefined && Object.hasOwn(paints, look.paint) ? look.paint : undefined;
|
|
30
|
+
|
|
31
|
+
/** The wallpaper `look` shows: its own, under the `wallpaper` paint only. */
|
|
32
|
+
export const wallpaperOf = (look: WorkspaceLook | undefined) =>
|
|
33
|
+
look?.paint === 'wallpaper' ? look.wallpaper : undefined;
|
|
34
|
+
|
|
35
|
+
/** What the shell's root marks as painted (`data-paint`): the paint, else `image` under a wallpaper shown. */
|
|
36
|
+
export const canvasOf = (look: WorkspaceLook | undefined) =>
|
|
37
|
+
paintOf(look) ?? (wallpaperOf(look) !== undefined ? 'image' : undefined);
|
|
38
|
+
|
|
39
|
+
/** `colour`'s relative luminance (WCAG), when it reads as a hex colour, `rgb()` or `oklch()`/`oklab()` (its lightness
|
|
40
|
+
* cubed, close enough to choose an ink); `parse` reads any other (the page draws it on a canvas). */
|
|
41
|
+
export function luminanceOf(
|
|
42
|
+
colour: string,
|
|
43
|
+
parse?: (colour: string) => [number, number, number] | undefined,
|
|
44
|
+
): number | undefined {
|
|
45
|
+
const linear = (channel: number) => {
|
|
46
|
+
const c = channel / 255;
|
|
47
|
+
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
48
|
+
};
|
|
49
|
+
const fromRgb = ([r, g, b]: [number, number, number]) =>
|
|
50
|
+
0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);
|
|
51
|
+
const hex = /^#([0-9a-f]{3,8})$/i.exec(colour)?.[1];
|
|
52
|
+
if (hex) {
|
|
53
|
+
const full =
|
|
54
|
+
hex.length <= 4 ? [...hex.slice(0, 3)].map((c) => c + c).join('') : hex.slice(0, 6);
|
|
55
|
+
return fromRgb(
|
|
56
|
+
[0, 2, 4].map((at) => parseInt(full.slice(at, at + 2), 16)) as [number, number, number],
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const rgb = /^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)/i.exec(colour);
|
|
60
|
+
const channel = (text: string) =>
|
|
61
|
+
text.endsWith('%') ? Number(text.slice(0, -1)) * 2.55 : Number(text);
|
|
62
|
+
if (rgb) return fromRgb([channel(rgb[1]!), channel(rgb[2]!), channel(rgb[3]!)]);
|
|
63
|
+
const ok = /^okl(?:ch|ab)\(\s*([\d.]+)(%?)/i.exec(colour);
|
|
64
|
+
if (ok) return (Number(ok[1]) / (ok[2] ? 100 : 1)) ** 3;
|
|
65
|
+
const parsed = parse?.(colour);
|
|
66
|
+
return parsed && fromRgb(parsed);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The ink a painted canvas takes in `mode` (`data-ink`): none on the theme's own paint seeds (the theme's ink fits them);
|
|
70
|
+
* on a colour the look sets for this mode (its first, else its second: the other is drawn from it, `lookStyle`), light
|
|
71
|
+
* ink on a dark one and dark on a light one (the better contrast: white against a near-black); light when its lightness
|
|
72
|
+
* cannot be read. None without a paint. */
|
|
73
|
+
export function inkOf(
|
|
74
|
+
look: WorkspaceLook | undefined,
|
|
75
|
+
mode: Mode,
|
|
76
|
+
parse?: Parse,
|
|
77
|
+
): 'light' | 'dark' | undefined {
|
|
78
|
+
if (paintOf(look) === undefined) return undefined;
|
|
79
|
+
const set = colourIn(look!.c1, mode) ?? colourIn(look!.c2, mode);
|
|
80
|
+
return set === undefined ? undefined : inkFor(set, parse);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A paint colour drawn from the other one the look sets in a mode: a quarter of the way to a mid grey (a lighter one
|
|
84
|
+
* from a dark colour, a darker one from a light), so the canvas keeps one ink. Never across modes. */
|
|
85
|
+
export const pairedColour = (colour: string) =>
|
|
86
|
+
`color-mix(in oklch, ${colour} 72%, oklch(60% 0 0))`;
|
|
87
|
+
|
|
88
|
+
type Parse = (colour: string) => [number, number, number] | undefined;
|
|
89
|
+
/** The ink `colour` asks for: light on a dark one, dark on a light one (the better contrast: white against a
|
|
90
|
+
* near-black); light when its lightness cannot be read. */
|
|
91
|
+
const inkFor = (colour: string, parse?: Parse): 'light' | 'dark' => {
|
|
92
|
+
const luminance = luminanceOf(colour, parse);
|
|
93
|
+
return luminance === undefined || (luminance + 0.05) ** 2 < 1.05 * 0.07 ? 'light' : 'dark';
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/** `look`'s `--c1` and `--c2`, by mode (`light-dark()` when they differ): each set value as it is; neither set, the
|
|
97
|
+
* theme's seeds. One set in a mode and not the other: the other is the theme's seed (A7), unless the set one asks for
|
|
98
|
+
* the ink the mode does not have (a dark colour in light mode, a 4e `{ c1 }` say): then it is drawn from the set one
|
|
99
|
+
* (`pairedColour`), so the canvas keeps one ink where a seed would put a pale band under light ink. */
|
|
100
|
+
export function paintColours(look: WorkspaceLook, parse?: Parse): [string, string] {
|
|
101
|
+
const inMode = (mode: Mode): [string, string] => {
|
|
102
|
+
const [c1, c2] = [colourIn(look.c1, mode), colourIn(look.c2, mode)];
|
|
103
|
+
const set = c1 ?? c2;
|
|
104
|
+
const against =
|
|
105
|
+
set !== undefined &&
|
|
106
|
+
(c1 === undefined || c2 === undefined) &&
|
|
107
|
+
inkFor(set, parse) !== (mode === 'light' ? 'dark' : 'light');
|
|
108
|
+
return [
|
|
109
|
+
c1 ?? (against ? pairedColour(set!) : paintSeeds.c1),
|
|
110
|
+
c2 ?? (against ? pairedColour(set!) : paintSeeds.c2),
|
|
111
|
+
];
|
|
112
|
+
};
|
|
113
|
+
const [light, dark] = [inMode('light'), inMode('dark')];
|
|
114
|
+
return [0, 1].map((at) =>
|
|
115
|
+
light[at] === dark[at] ? light[at]! : `light-dark(${light[at]}, ${dark[at]})`,
|
|
116
|
+
) as [string, string];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The custom properties the shell's root takes for workspace `slug`'s `look` in `mode`: the paint (`--shell-paint`,
|
|
120
|
+
* the root's background) from its colours (`light-dark()` when they differ by mode; the theme's seeds where unset), or
|
|
121
|
+
* the wallpaper of the mode over the theme's canvas (served by the host at its hash: a new one shows at once), a solid stand-in
|
|
122
|
+
* (`--shell-canvas`, `c1`: what rings a dot on it), and the accent. */
|
|
123
|
+
export function lookStyle(
|
|
124
|
+
look: WorkspaceLook | undefined,
|
|
125
|
+
slug: string,
|
|
126
|
+
mode: Mode = 'light',
|
|
127
|
+
parse?: Parse,
|
|
128
|
+
imageOf?: (id: string) => string | undefined,
|
|
129
|
+
): Record<string, string> {
|
|
130
|
+
const paint = paintOf(look);
|
|
131
|
+
const wallpaper = wallpaperOf(look);
|
|
132
|
+
const accent = modeColour(look?.accent, 'var(--accent)');
|
|
133
|
+
const [c1, c2] = paint === undefined ? [] : paintColours(look!, parse);
|
|
134
|
+
return {
|
|
135
|
+
...(paint !== undefined && {
|
|
136
|
+
'--c1': c1!,
|
|
137
|
+
'--c2': c2!,
|
|
138
|
+
'--shell-paint': paints[paint]!,
|
|
139
|
+
'--shell-canvas': 'var(--c1)',
|
|
140
|
+
}),
|
|
141
|
+
...(wallpaper !== undefined && {
|
|
142
|
+
'--shell-paint': `url("${wallpaperUrl(slug, mode === 'dark' && wallpaper.dark !== undefined ? wallpaper.dark : wallpaper.hash, imageOf)}") ${fits[wallpaper.fit]}, var(--shell-canvas)`,
|
|
143
|
+
}),
|
|
144
|
+
...(accent !== undefined && { '--ws-accent': accent }),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** A wallpaper's URL: the user's own image (Mine's, `imageOf`: a data URL the client keeps), else the copy the host
|
|
149
|
+
* serves at its hash. */
|
|
150
|
+
export const wallpaperUrl = (
|
|
151
|
+
slug: string,
|
|
152
|
+
id: string,
|
|
153
|
+
imageOf?: (id: string) => string | undefined,
|
|
154
|
+
) => imageOf?.(id) ?? `/_bridge/workspaces/${encodeURIComponent(slug)}/wallpaper?${id}`;
|
|
155
|
+
|
|
156
|
+
/** The localStorage keys of a browser's choices from before Mine (theme, style, icons, window manager). */
|
|
157
|
+
export const legacyKeys = [
|
|
158
|
+
'bridge.theme',
|
|
159
|
+
'bridge.kit',
|
|
160
|
+
'bridge.icons',
|
|
161
|
+
'bridge.windowManager.choice',
|
|
162
|
+
] as const;
|
|
163
|
+
/** A browser's choices from before Mine (appearance slice 3), as Mine's fields and a mode: its theme as a theme pair (it
|
|
164
|
+
* and its counterpart; "system" none) with its mode, its style and icons, its window manager (`null`: `none`).
|
|
165
|
+
* `undefined` when it chose nothing. `themeOfMode`: the kit's. */
|
|
166
|
+
export function legacyMine(
|
|
167
|
+
read: (key: string) => string | null,
|
|
168
|
+
themeOfMode: (id: string, mode: Mode) => string | undefined,
|
|
169
|
+
): { fields: Record<string, string>; mode?: 'light' | 'dark' | 'system' } | undefined {
|
|
170
|
+
const [theme, kit, icons, manager] = legacyKeys.map(read) as [
|
|
171
|
+
string | null,
|
|
172
|
+
string | null,
|
|
173
|
+
string | null,
|
|
174
|
+
string | null,
|
|
175
|
+
];
|
|
176
|
+
const id = /^[a-z0-9-]+$/;
|
|
177
|
+
const fields: Record<string, string> = {};
|
|
178
|
+
let mode: 'light' | 'dark' | 'system' | undefined;
|
|
179
|
+
if (theme === 'system') mode = 'system';
|
|
180
|
+
else if (theme !== null) {
|
|
181
|
+
const light = themeOfMode(theme, 'light');
|
|
182
|
+
const dark = themeOfMode(theme, 'dark');
|
|
183
|
+
if (light !== undefined) fields.lightTheme = light;
|
|
184
|
+
if (dark !== undefined) fields.darkTheme = dark;
|
|
185
|
+
if (light !== undefined || dark !== undefined) mode = light === theme ? 'light' : 'dark';
|
|
186
|
+
}
|
|
187
|
+
if (kit !== null && id.test(kit)) fields.style = kit;
|
|
188
|
+
if (icons !== null && id.test(icons)) fields.icons = icons;
|
|
189
|
+
try {
|
|
190
|
+
const choice: unknown = manager === null ? undefined : JSON.parse(manager);
|
|
191
|
+
if (choice === null) fields.windowManager = 'none';
|
|
192
|
+
else if (typeof choice === 'string' && choice.length > 0 && choice.length <= 214)
|
|
193
|
+
fields.windowManager = choice;
|
|
194
|
+
} catch {
|
|
195
|
+
/* not a choice */
|
|
196
|
+
}
|
|
197
|
+
if (
|
|
198
|
+
Object.keys(fields).length === 0 &&
|
|
199
|
+
mode === undefined &&
|
|
200
|
+
legacyKeys.every((key) => read(key) === null)
|
|
201
|
+
)
|
|
202
|
+
return undefined;
|
|
203
|
+
return { fields, ...(mode !== undefined && { mode }) };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** The window manager chosen for the page: `null` while one is set aside for it, else the one `look` names (the user's
|
|
207
|
+
* Mine over the workspace's proposal; `none`: none), else `undefined`, the default (the first installed). */
|
|
208
|
+
export const managerOf = (
|
|
209
|
+
choice: string | null | undefined,
|
|
210
|
+
look: WorkspaceLook | undefined,
|
|
211
|
+
): string | null | undefined =>
|
|
212
|
+
choice !== undefined
|
|
213
|
+
? choice
|
|
214
|
+
: look?.windowManager === undefined
|
|
215
|
+
? undefined
|
|
216
|
+
: look.windowManager === 'none'
|
|
217
|
+
? null
|
|
218
|
+
: look.windowManager;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/* The phone's shell (./mobile.tsx): its own buttons drawn by their classes only (the kit's CSS has no preflight). In
|
|
2
|
+
the base layer, so the classes win. A file, not a `<style>`: the page's CSP forbids inline styles. */
|
|
3
|
+
@layer base {
|
|
4
|
+
[data-mobile] button {
|
|
5
|
+
appearance: none;
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: 0;
|
|
8
|
+
border: 0;
|
|
9
|
+
background: transparent;
|
|
10
|
+
color: inherit;
|
|
11
|
+
font: inherit;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
-webkit-tap-highlight-color: transparent;
|
|
14
|
+
}
|
|
15
|
+
[data-mobile] {
|
|
16
|
+
-webkit-text-size-adjust: 100%;
|
|
17
|
+
overscroll-behavior: none;
|
|
18
|
+
}
|
|
19
|
+
/* The page itself never scrolls on a phone (iOS's home screen app scrolled it, header and all, and bounced): each
|
|
20
|
+
screen scrolls inside the frame. */
|
|
21
|
+
html:has([data-slot='shell'][data-mobile]),
|
|
22
|
+
html:has([data-slot='shell'][data-mobile]) body {
|
|
23
|
+
height: 100%;
|
|
24
|
+
margin: 0;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
overscroll-behavior: none;
|
|
27
|
+
}
|
|
28
|
+
html:has([data-slot='shell'][data-mobile]) body {
|
|
29
|
+
position: fixed;
|
|
30
|
+
inset: 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Moving between screens on a phone (./mobile.tsx `transitions`): an item slides in from the right over its list, which
|
|
35
|
+
moves a third to the left and dims (iOS's push), and back the other way (`pop`); another screen of the drawer
|
|
36
|
+
cross-fades. The header cross-fades its title in place. */
|
|
37
|
+
::view-transition-group(mobile-screen) {
|
|
38
|
+
animation-duration: 320ms;
|
|
39
|
+
animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
|
|
40
|
+
}
|
|
41
|
+
::view-transition-old(mobile-screen),
|
|
42
|
+
::view-transition-new(mobile-screen) {
|
|
43
|
+
animation-duration: 320ms;
|
|
44
|
+
animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
|
|
45
|
+
mix-blend-mode: normal;
|
|
46
|
+
}
|
|
47
|
+
::view-transition-old(mobile-header),
|
|
48
|
+
::view-transition-new(mobile-header) {
|
|
49
|
+
animation-duration: 200ms;
|
|
50
|
+
}
|
|
51
|
+
html[data-transition='push']::view-transition-old(mobile-screen) {
|
|
52
|
+
animation-name: bridge-screen-behind;
|
|
53
|
+
}
|
|
54
|
+
html[data-transition='push']::view-transition-new(mobile-screen) {
|
|
55
|
+
animation-name: bridge-screen-in;
|
|
56
|
+
}
|
|
57
|
+
html[data-transition='pop']::view-transition-old(mobile-screen) {
|
|
58
|
+
animation-name: bridge-screen-in;
|
|
59
|
+
animation-direction: reverse;
|
|
60
|
+
z-index: 1;
|
|
61
|
+
}
|
|
62
|
+
html[data-transition='pop']::view-transition-new(mobile-screen) {
|
|
63
|
+
animation-name: bridge-screen-behind;
|
|
64
|
+
animation-direction: reverse;
|
|
65
|
+
}
|
|
66
|
+
html[data-transition='swap']::view-transition-old(mobile-screen),
|
|
67
|
+
html[data-transition='swap']::view-transition-new(mobile-screen) {
|
|
68
|
+
animation-duration: 180ms;
|
|
69
|
+
}
|
|
70
|
+
@keyframes bridge-screen-in {
|
|
71
|
+
from {
|
|
72
|
+
transform: translateX(100%);
|
|
73
|
+
box-shadow: -8px 0 24px rgb(0 0 0 / 0);
|
|
74
|
+
}
|
|
75
|
+
to {
|
|
76
|
+
transform: translateX(0);
|
|
77
|
+
box-shadow: -8px 0 24px rgb(0 0 0 / 0.12);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
@keyframes bridge-screen-behind {
|
|
81
|
+
from {
|
|
82
|
+
transform: translateX(0);
|
|
83
|
+
filter: brightness(1);
|
|
84
|
+
}
|
|
85
|
+
to {
|
|
86
|
+
transform: translateX(-30%);
|
|
87
|
+
filter: brightness(0.92);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* iOS 26's glass (research-020): what draws over the screen (the bottom bar, the round buttons, the capsule of actions)
|
|
92
|
+
is translucent, the screen blurred and saturated behind it, a light edge on top; it shrinks a little under the finger.
|
|
93
|
+
An imitation: iOS's own Liquid Glass (its refraction, its morphing) is for native controls, drawn by the app later. */
|
|
94
|
+
@layer components {
|
|
95
|
+
.mobile-glass {
|
|
96
|
+
background: light-dark(rgb(255 255 255 / 0.62), rgb(40 40 44 / 0.58));
|
|
97
|
+
-webkit-backdrop-filter: blur(24px) saturate(2);
|
|
98
|
+
backdrop-filter: blur(24px) saturate(2);
|
|
99
|
+
border: 0.5px solid light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.14));
|
|
100
|
+
box-shadow:
|
|
101
|
+
0 8px 28px light-dark(rgb(0 0 0 / 0.12), rgb(0 0 0 / 0.45)),
|
|
102
|
+
inset 0 1px 0 light-dark(rgb(255 255 255 / 0.9), rgb(255 255 255 / 0.12));
|
|
103
|
+
color: var(--fg);
|
|
104
|
+
}
|
|
105
|
+
.mobile-press {
|
|
106
|
+
transition:
|
|
107
|
+
transform 160ms cubic-bezier(0.32, 0.72, 0, 1),
|
|
108
|
+
background-color 160ms;
|
|
109
|
+
}
|
|
110
|
+
.mobile-press:active {
|
|
111
|
+
transform: scale(0.92);
|
|
112
|
+
}
|
|
113
|
+
.mobile-tab {
|
|
114
|
+
color: var(--fg-secondary);
|
|
115
|
+
}
|
|
116
|
+
.mobile-tab[aria-current='page'] {
|
|
117
|
+
color: var(--accent, var(--fg));
|
|
118
|
+
}
|
|
119
|
+
.mobile-edge-blur {
|
|
120
|
+
height: calc(100% + 2.5rem);
|
|
121
|
+
-webkit-backdrop-filter: blur(10px);
|
|
122
|
+
backdrop-filter: blur(10px);
|
|
123
|
+
background: linear-gradient(
|
|
124
|
+
to top,
|
|
125
|
+
light-dark(rgb(250 250 250 / 0.7), rgb(10 10 12 / 0.6)),
|
|
126
|
+
transparent
|
|
127
|
+
);
|
|
128
|
+
-webkit-mask-image: linear-gradient(to top, black 45%, transparent);
|
|
129
|
+
mask-image: linear-gradient(to top, black 45%, transparent);
|
|
130
|
+
}
|
|
131
|
+
.mobile-tab-pill {
|
|
132
|
+
background: light-dark(rgb(0 0 0 / 0.07), rgb(255 255 255 / 0.12));
|
|
133
|
+
view-transition-name: mobile-tab-pill;
|
|
134
|
+
}
|
|
135
|
+
.mobile-primary {
|
|
136
|
+
color: var(--accent, var(--fg));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* The bottom bar stays put while the screen changes under it (its glass is no snapshot cross-fading over itself); only
|
|
141
|
+
its lit pill moves, sliding to the tab chosen with a little spring, as iOS 26's tab bar does. Leaving for an item
|
|
142
|
+
(the bar goes) or coming back (it comes), it fades. */
|
|
143
|
+
::view-transition-old(mobile-bottom):not(:only-child),
|
|
144
|
+
::view-transition-old(mobile-primary):not(:only-child) {
|
|
145
|
+
display: none;
|
|
146
|
+
}
|
|
147
|
+
::view-transition-new(mobile-bottom):not(:only-child),
|
|
148
|
+
::view-transition-new(mobile-primary):not(:only-child) {
|
|
149
|
+
animation: none;
|
|
150
|
+
}
|
|
151
|
+
::view-transition-group(mobile-tab-pill) {
|
|
152
|
+
animation-duration: 380ms;
|
|
153
|
+
animation-timing-function: cubic-bezier(0.34, 1.36, 0.64, 1);
|
|
154
|
+
}
|
|
155
|
+
::view-transition-old(mobile-tab-pill),
|
|
156
|
+
::view-transition-new(mobile-tab-pill) {
|
|
157
|
+
animation: none;
|
|
158
|
+
}
|
|
159
|
+
::view-transition-old(mobile-tab-pill):not(:only-child) {
|
|
160
|
+
display: none;
|
|
161
|
+
}
|
|
162
|
+
/* Sliding, the pill is drawn over the bar's picture: blended, the icons it passes over show through it. */
|
|
163
|
+
::view-transition-group(mobile-tab-pill) {
|
|
164
|
+
mix-blend-mode: multiply;
|
|
165
|
+
}
|
|
166
|
+
html[data-theme$='dark']::view-transition-group(mobile-tab-pill) {
|
|
167
|
+
mix-blend-mode: screen;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* Text on a phone, after a phone app's typography: Bridge's desktop sizes are a step
|
|
171
|
+
denser than a phone reads, so the kit's small steps grow to a phone's roles, `text-sm` (the desktop's body) to its body
|
|
172
|
+
and `text-xs` (the desktop's meta) to its label (13/16 of it). Everything follows `--phone-text`, the size this
|
|
173
|
+
device chose (Look's `phoneTextSize`, set by ./mobile.tsx; 16px unset); the larger steps keep the kit's ratios. On
|
|
174
|
+
`html`, so the sheets and dialogs portalled out of the shell grow too; outside any layer, so no plugin's
|
|
175
|
+
`@layer theme` declared first wins over it. */
|
|
176
|
+
html:has([data-slot='shell'][data-mobile]) {
|
|
177
|
+
--text-xs: calc(var(--phone-text, 16px) * 13 / 16);
|
|
178
|
+
--text-xs--line-height: calc(var(--phone-text, 16px) * 17 / 16);
|
|
179
|
+
--text-sm: var(--phone-text, 16px);
|
|
180
|
+
--text-sm--line-height: calc(var(--phone-text, 16px) * 23 / 16);
|
|
181
|
+
--text-base: var(--phone-text, 16px);
|
|
182
|
+
--text-base--line-height: calc(var(--phone-text, 16px) * 24 / 16);
|
|
183
|
+
--text-lg: calc(var(--phone-text, 16px) * 20 / 16);
|
|
184
|
+
--text-lg--line-height: calc(var(--phone-text, 16px) * 28 / 16);
|
|
185
|
+
--text-xl: calc(var(--phone-text, 16px) * 24 / 16);
|
|
186
|
+
--text-xl--line-height: calc(var(--phone-text, 16px) * 32 / 16);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* The phone's settings sheet over the drawer (./mobile.tsx `PhoneSettings`): Base UI draws no backdrop for a nested
|
|
190
|
+
dialog, so the drawer dims itself while one is open (`data-nested-dialog-open`), the sheet standing out from it as from
|
|
191
|
+
any screen; darker in a dark theme, where 40 % hardly shows. */
|
|
192
|
+
.mobile-drawer::after {
|
|
193
|
+
content: '';
|
|
194
|
+
position: absolute;
|
|
195
|
+
inset: 0;
|
|
196
|
+
pointer-events: none;
|
|
197
|
+
background: rgb(0 0 0 / 0);
|
|
198
|
+
transition: background-color 300ms ease-out;
|
|
199
|
+
}
|
|
200
|
+
.mobile-drawer[data-nested-dialog-open]::after {
|
|
201
|
+
background: light-dark(rgb(0 0 0 / 0.4), rgb(0 0 0 / 0.6));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* The phone's settings sheet, grouped as iOS draws its own: the sheet a step off the page's background, its cards
|
|
205
|
+
another step off the sheet, the choice made a step further. The theme's own steps (--bg, --bg-surface) are too close
|
|
206
|
+
to tell apart on a phone, so each is the background mixed with the theme's text colour, which works in any theme:
|
|
207
|
+
the sheet darker than the cards in a light theme, lighter than the page and the cards lighter still in a dark one. */
|
|
208
|
+
.phone-sheet {
|
|
209
|
+
background: light-dark(
|
|
210
|
+
color-mix(in oklab, var(--bg) 94%, var(--fg)),
|
|
211
|
+
color-mix(in oklab, var(--bg) 92%, var(--fg))
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
.phone-card {
|
|
215
|
+
background: light-dark(var(--bg-surface), color-mix(in oklab, var(--bg) 84%, var(--fg)));
|
|
216
|
+
}
|
|
217
|
+
.phone-choice[aria-checked='true'] {
|
|
218
|
+
background: light-dark(
|
|
219
|
+
color-mix(in oklab, var(--bg) 90%, var(--fg)),
|
|
220
|
+
color-mix(in oklab, var(--bg) 72%, var(--fg))
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
/* The slider's track (the kit's `bg-border`) is the card's own colour in a dark theme: a step lighter there. */
|
|
224
|
+
.phone-card [data-slot='slider-track'] {
|
|
225
|
+
background: light-dark(var(--border), color-mix(in oklab, var(--bg) 62%, var(--fg)));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* A node's page in the phone's menu (the `pages` style): from the right going down a node, from the left going up. */
|
|
229
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
230
|
+
.mobile-menu-page[data-direction='push'] {
|
|
231
|
+
animation: bridge-menu-page 240ms ease-out;
|
|
232
|
+
}
|
|
233
|
+
.mobile-menu-page[data-direction='pop'] {
|
|
234
|
+
animation: bridge-menu-page 240ms ease-out;
|
|
235
|
+
--menu-from: -24px;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
@keyframes bridge-menu-page {
|
|
239
|
+
from {
|
|
240
|
+
transform: translateX(var(--menu-from, 24px));
|
|
241
|
+
opacity: 0;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* The tree's triangles in the phone's menu: the kit's 16px box, with a finger's reach around it; on the right no further
|
|
246
|
+
than the row's own 6px (past it, the open group around the row would scroll sideways once the triangle has focus). */
|
|
247
|
+
.mobile-menu [data-slot='sidebar-tree-toggle'] {
|
|
248
|
+
box-sizing: content-box;
|
|
249
|
+
padding: 12px 6px 12px 12px;
|
|
250
|
+
margin: -12px -6px -12px -12px;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* The phone's menu as a floating panel (the `tree` style): iOS 26's glass, grown from the bottom bar with a small bounce.
|
|
254
|
+
Outside any layer, so it wins over the dialog's own background and transitions. */
|
|
255
|
+
.mobile-panel {
|
|
256
|
+
background: light-dark(rgb(255 255 255 / 0.2), rgb(30 30 34 / 0.24));
|
|
257
|
+
-webkit-backdrop-filter: blur(8px) saturate(1.6);
|
|
258
|
+
backdrop-filter: blur(8px) saturate(1.6);
|
|
259
|
+
border: 0.5px solid light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.14));
|
|
260
|
+
box-shadow:
|
|
261
|
+
0 12px 40px light-dark(rgb(0 0 0 / 0.18), rgb(0 0 0 / 0.5)),
|
|
262
|
+
inset 0 1px 0 light-dark(rgb(255 255 255 / 0.9), rgb(255 255 255 / 0.12));
|
|
263
|
+
transform-origin: bottom center;
|
|
264
|
+
transition:
|
|
265
|
+
scale 420ms cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
266
|
+
opacity 180ms ease-out;
|
|
267
|
+
}
|
|
268
|
+
.mobile-panel[data-starting-style] {
|
|
269
|
+
scale: 0.6;
|
|
270
|
+
opacity: 0;
|
|
271
|
+
}
|
|
272
|
+
.mobile-panel[data-ending-style] {
|
|
273
|
+
scale: 0.9;
|
|
274
|
+
opacity: 0;
|
|
275
|
+
transition-duration: 160ms;
|
|
276
|
+
transition-timing-function: ease-in;
|
|
277
|
+
}
|
|
278
|
+
@media (prefers-reduced-motion: reduce) {
|
|
279
|
+
.mobile-panel {
|
|
280
|
+
transition: opacity 180ms ease-out;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/* The phone's menu trees: their guides' branches reach the middle of its taller rows (`h-11`). */
|
|
285
|
+
.mobile-menu [role='tree'] {
|
|
286
|
+
--height-md: 2.75rem;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/* The view shown, in the floating panel: a light tint over the glass, not the theme's opaque selection. */
|
|
290
|
+
.mobile-panel [role='treeitem'][aria-current] > [data-slot='sidebar-tree-item'] {
|
|
291
|
+
background: light-dark(rgb(0 0 0 / 0.06), rgb(255 255 255 / 0.08));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/* The phone's menu triangles: 18px (the kit's 12px is a mouse's), a lighter stroke at that size. */
|
|
295
|
+
.mobile-menu [data-variant='navigation'] [data-slot='sidebar-tree-toggle'] svg {
|
|
296
|
+
width: 18px;
|
|
297
|
+
height: 18px;
|
|
298
|
+
stroke-width: 2;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* The menu's list scrolls under its header and fades out there (the header has no background of its own). */
|
|
302
|
+
.mobile-menu-page {
|
|
303
|
+
-webkit-mask-image: linear-gradient(to bottom, transparent 1.25rem, black 3.25rem);
|
|
304
|
+
mask-image: linear-gradient(to bottom, transparent 1.25rem, black 3.25rem);
|
|
305
|
+
}
|