@bigpixelrocket/uiok 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -1
- package/README.md +1 -1
- package/dist/activity/ActivityBar.d.ts +21 -8
- package/dist/activity/ActivityBar.js +15 -5
- package/dist/activity/activity.css +53 -6
- package/dist/button/Button.d.ts +10 -6
- package/dist/button/Button.js +6 -1
- package/dist/button/button.css +201 -33
- package/dist/charts/Line.logic.d.ts +6 -0
- package/dist/charts/Line.logic.js +9 -0
- package/dist/charts/LineChart.js +11 -4
- package/dist/charts/Pie.logic.d.ts +89 -1
- package/dist/charts/Pie.logic.js +272 -2
- package/dist/charts/PieChart.d.ts +2 -1
- package/dist/charts/PieChart.js +12 -5
- package/dist/charts/PieFill.d.ts +15 -0
- package/dist/charts/PieFill.js +33 -0
- package/dist/charts/ResultChart.d.ts +2 -2
- package/dist/charts/ResultChart.js +173 -47
- package/dist/charts/ResultChart.logic.d.ts +60 -4
- package/dist/charts/ResultChart.logic.js +105 -6
- package/dist/charts/Scatter.logic.d.ts +18 -4
- package/dist/charts/Scatter.logic.js +98 -22
- package/dist/charts/ScatterChart.js +19 -5
- package/dist/charts/charts.css +233 -116
- package/dist/charts/seriesColour.d.ts +2 -0
- package/dist/charts/seriesColour.js +1 -1
- package/dist/datetime/DateTimePicker.d.ts +12 -2
- package/dist/datetime/DateTimePicker.js +61 -16
- package/dist/datetime/DateTimePicker.logic.d.ts +29 -0
- package/dist/datetime/DateTimePicker.logic.js +25 -0
- package/dist/datetime/datetime.css +89 -49
- package/dist/dialog/ConfirmDialog.d.ts +69 -20
- package/dist/dialog/ConfirmDialog.js +39 -12
- package/dist/dialog/DialogLayer.d.ts +25 -0
- package/dist/dialog/DialogLayer.js +24 -0
- package/dist/dialog/DialogLegend.d.ts +2 -1
- package/dist/dialog/DialogLegend.js +10 -5
- package/dist/dialog/DialogLegend.logic.d.ts +15 -3
- package/dist/dialog/DialogLegend.logic.js +8 -4
- package/dist/dialog/DialogLists.d.ts +157 -0
- package/dist/dialog/DialogLists.js +137 -0
- package/dist/dialog/ModalDialog.d.ts +20 -15
- package/dist/dialog/ModalDialog.js +22 -7
- package/dist/dialog/dialog.css +570 -127
- package/dist/dialog/index.d.ts +7 -1
- package/dist/dialog/index.js +7 -1
- package/dist/field/Check.d.ts +15 -0
- package/dist/field/Check.js +23 -0
- package/dist/field/field.css +812 -0
- package/dist/field/index.d.ts +10 -0
- package/dist/field/index.js +10 -0
- package/dist/field/labelHelp.d.ts +33 -0
- package/dist/field/labelHelp.js +22 -0
- package/dist/filter/FilterIcon.js +2 -1
- package/dist/filter/filter.css +72 -20
- package/dist/grid/DataGrid.d.ts +8 -1
- package/dist/grid/DataGrid.js +115 -40
- package/dist/grid/DataGrid.logic.d.ts +15 -3
- package/dist/grid/DataGrid.logic.js +18 -5
- package/dist/grid/grid.css +481 -56
- package/dist/icon/Spinner.d.ts +16 -0
- package/dist/icon/Spinner.js +13 -0
- package/dist/icon/index.d.ts +5 -0
- package/dist/icon/index.js +5 -0
- package/dist/icon/sizes.d.ts +19 -0
- package/dist/icon/sizes.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/keychord/KeyChord.d.ts +12 -1
- package/dist/keychord/KeyChord.js +2 -2
- package/dist/keychord/index.d.ts +1 -1
- package/dist/keychord/keychord.css +87 -9
- package/dist/labels/dialog.d.ts +12 -1
- package/dist/labels/dialog.js +3 -1
- package/dist/labels/selectAll.d.ts +4 -4
- package/dist/labels/selectAll.js +1 -1
- package/dist/legend/KeyLegendStrip.js +1 -1
- package/dist/legend/legend.css +82 -57
- package/dist/listing/Listing.d.ts +17 -10
- package/dist/listing/Listing.js +33 -26
- package/dist/listing/listing.css +1665 -237
- package/dist/menu/menu.css +227 -67
- package/dist/menu/useBellBeat.js +2 -2
- package/dist/namecut/NameCut.d.ts +3 -1
- package/dist/namecut/NameCut.js +152 -5
- package/dist/namecut/NameCut.logic.d.ts +5 -3
- package/dist/namecut/NameCut.logic.js +20 -5
- package/dist/namecut/namecut.css +27 -7
- package/dist/pager/Pager.d.ts +12 -4
- package/dist/pager/Pager.js +21 -7
- package/dist/pager/pager.css +41 -30
- package/dist/palette/Palette.js +2 -1
- package/dist/palette/palette.css +121 -60
- package/dist/pane/PaneActions.d.ts +56 -14
- package/dist/pane/PaneActions.js +64 -16
- package/dist/pane/PaneFrame.d.ts +37 -5
- package/dist/pane/PaneFrame.js +246 -11
- package/dist/pane/index.d.ts +4 -2
- package/dist/pane/index.js +4 -2
- package/dist/pane/toolWords.d.ts +14 -0
- package/dist/pane/toolWords.js +26 -0
- package/dist/pane/useToolbarFit.d.ts +25 -0
- package/dist/pane/useToolbarFit.js +95 -0
- package/dist/run/RunHeader.d.ts +5 -3
- package/dist/run/RunHeader.js +11 -8
- package/dist/run/run.css +64 -79
- package/dist/segmented/SegmentedChoice.d.ts +18 -2
- package/dist/segmented/SegmentedChoice.js +18 -7
- package/dist/segmented/segmented.css +62 -22
- package/dist/selectall/SelectAllBar.d.ts +4 -3
- package/dist/selectall/SelectAllBar.js +4 -3
- package/dist/selectall/selectall.css +17 -12
- package/dist/shell/shell.css +1073 -0
- package/dist/styles.css +620 -22
- package/dist/surface/surface.css +154 -0
- package/dist/tabs/PageTabs.d.ts +10 -5
- package/dist/tabs/PageTabs.js +126 -37
- package/dist/tabs/tabs.css +131 -51
- package/dist/terminal/Terminal.js +3 -1
- package/dist/terminal/Terminal.logic.d.ts +5 -4
- package/dist/terminal/Terminal.logic.js +9 -4
- package/dist/terminal/TerminalMenu.d.ts +4 -1
- package/dist/terminal/TerminalMenu.js +12 -5
- package/dist/terminal/ghostty/contrast.logic.d.ts +45 -0
- package/dist/terminal/ghostty/contrast.logic.js +130 -0
- package/dist/terminal/ghostty/core.d.ts +6 -0
- package/dist/terminal/ghostty/renderer.d.ts +9 -2
- package/dist/terminal/ghostty/renderer.js +91 -14
- package/dist/terminal/ghostty/surface.d.ts +8 -0
- package/dist/terminal/ghostty/surface.js +27 -1
- package/dist/terminal/terminal.css +87 -61
- package/dist/text/text.css +16 -7
- package/dist/themes/catalog.js +4 -3
- package/dist/themes/themes.generated.css +1307 -264
- package/dist/themes/tokens.d.ts +69 -14
- package/dist/themes/tokens.js +920 -97
- package/dist/tokens.css +239 -0
- package/dist/tooltip/Tooltip.d.ts +6 -0
- package/dist/tooltip/Tooltip.js +48 -6
- package/dist/tooltip/Tooltip.logic.d.ts +89 -12
- package/dist/tooltip/Tooltip.logic.js +142 -20
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tooltip/index.js +1 -1
- package/dist/tooltip/tooltip.css +39 -9
- package/package.json +3 -3
package/dist/themes/tokens.js
CHANGED
|
@@ -10,29 +10,128 @@
|
|
|
10
10
|
* the override. A token other tokens read straight from the palette (the
|
|
11
11
|
* panel, the text, the primary hue, the group hues) takes no override; a
|
|
12
12
|
* theme sets it through its palette, or a group hue through `Theme.groups`.
|
|
13
|
-
* Tokens that read the same in every theme (aliases,
|
|
14
|
-
* opacity
|
|
13
|
+
* Tokens that read the same in every theme (aliases, washes, the disabled
|
|
14
|
+
* opacity) are fixed.
|
|
15
|
+
*
|
|
16
|
+
* Every colour has one job. A fill the text sits on (`--accent`, `--danger`)
|
|
17
|
+
* is not the colour of a word: each coloured word has a text role
|
|
18
|
+
* (`--accent-text`, `--danger-text`) floored at 4.5:1 on every ground the
|
|
19
|
+
* word is drawn on, and each mark read by shape (a dot, an icon, a chart
|
|
20
|
+
* line, a control's outline) has a role floored at 3:1 on its grounds.
|
|
15
21
|
*
|
|
16
22
|
* An app that needs tokens of its own derives them from the same theme and
|
|
17
23
|
* emits them through `themeStylesheet`'s options, so one stylesheet holds
|
|
18
24
|
* both sets under the same selectors.
|
|
19
25
|
*/
|
|
20
26
|
import { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, THEMES } from './catalog.js';
|
|
21
|
-
import { contrast, firstLegible, legibleOn, luminance, mix, translucent } from './color.js';
|
|
27
|
+
import { contrast, firstLegible, legibleOn, luminance, mix, rgbOf, translucent } from './color.js';
|
|
22
28
|
import { THEME_ATTRIBUTES, THEME_PREVIEW_ATTRIBUTE } from './ids.js';
|
|
23
29
|
const WHITE = '#ffffff';
|
|
24
30
|
const BLACK = '#000000';
|
|
25
31
|
/** Body text and anything read as words. */
|
|
26
32
|
const TEXT_CONTRAST = 4.5;
|
|
27
|
-
/** Marks read by shape alone: a dot, a glyph. */
|
|
33
|
+
/** Marks read by shape alone: a dot, a glyph, a control's outline, a chart line. */
|
|
28
34
|
const MARK_CONTRAST = 3;
|
|
35
|
+
/**
|
|
36
|
+
* The least a hairline stands apart from the grounds it divides: `--border`
|
|
37
|
+
* at the divider's floor, `--border-strong` at the frame's. Lines are not
|
|
38
|
+
* read alone, so they sit under the 3:1 a control's outline needs.
|
|
39
|
+
*/
|
|
40
|
+
const BORDER_CONTRAST = 1.15;
|
|
41
|
+
const BORDER_STRONG_CONTRAST = 1.3;
|
|
42
|
+
/**
|
|
43
|
+
* The least a marked row's tint stands apart from the ground under it, so a
|
|
44
|
+
* marked row reads apart from its neighbours (zebra rows included) before
|
|
45
|
+
* its leading bar is noticed.
|
|
46
|
+
*/
|
|
47
|
+
const MARKED_CONTRAST = 1.25;
|
|
48
|
+
/**
|
|
49
|
+
* The washes and lines of a hue, in percent of the hue over whatever is
|
|
50
|
+
* under them (`FIXED_TOKENS` writes them as `color-mix` with transparent;
|
|
51
|
+
* the rules below lay them over each ground to floor what is drawn on them).
|
|
52
|
+
* A wash tints a band or a row; the strong wash tints what must stand out
|
|
53
|
+
* from a wash; a line draws a hue's rule or ring.
|
|
54
|
+
*/
|
|
55
|
+
const WASH = {
|
|
56
|
+
accent: 12,
|
|
57
|
+
accentStrong: 20,
|
|
58
|
+
status: 8,
|
|
59
|
+
statusStrong: 16,
|
|
60
|
+
line: 45
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The tint of the current item (the open page, the chosen tab) at most; the
|
|
64
|
+
* tint steps down where the text on it would fall under 4.5:1.
|
|
65
|
+
*/
|
|
66
|
+
const CURRENT_TINT = 18;
|
|
67
|
+
/**
|
|
68
|
+
* The share of the accent in a marked row's tint: at least MARKED_TINT and
|
|
69
|
+
* at most MARKED_TINT_MAX, so the same state reads alike in every theme. A
|
|
70
|
+
* cursor on a marked row adds MARKED_CURSOR_STEP where the text keeps its
|
|
71
|
+
* contrast, and never less than MARKED_CURSOR_MIN, so the cursor always
|
|
72
|
+
* shows on a marked row.
|
|
73
|
+
*/
|
|
74
|
+
const MARKED_TINT = 16;
|
|
75
|
+
const MARKED_TINT_MAX = 20;
|
|
76
|
+
const MARKED_CURSOR_STEP = 10;
|
|
77
|
+
const MARKED_CURSOR_MIN = 4;
|
|
78
|
+
/** The text's share in a zebra row's tint (`--row-zebra`). */
|
|
79
|
+
const ZEBRA_TINT = 3;
|
|
80
|
+
/**
|
|
81
|
+
* The least a state wash stands apart from what it lies on: a hovered row
|
|
82
|
+
* from its row (`--row-hover`), and a pressed control from its ground and
|
|
83
|
+
* from its own hovered face (`--pressed-wash`).
|
|
84
|
+
*/
|
|
85
|
+
const ROW_HOVER_CONTRAST = 1.12;
|
|
86
|
+
const PRESSED_CONTRAST = 1.12;
|
|
87
|
+
const PRESSED_FROM_HOVER = 1.12;
|
|
88
|
+
/**
|
|
89
|
+
* The least a hovered face stands apart from its resting face: the frosted
|
|
90
|
+
* wash an outlined control takes (`--hover-wash`) over every ground it rests
|
|
91
|
+
* on. A press stands PRESSED_FROM_HOVER past that.
|
|
92
|
+
*/
|
|
93
|
+
const HOVER_FROM_REST = 1.04;
|
|
94
|
+
/** The most white the frosted hover may take before it turns a text tint. */
|
|
95
|
+
const HOVER_WHITE_MAX = 70;
|
|
96
|
+
/**
|
|
97
|
+
* The least each state of a filled button stands apart from the one before
|
|
98
|
+
* it: hover from rest, and pressed from hover. The primary steps away from
|
|
99
|
+
* its text, the tonal fill toward the accent, so a held fill reads as
|
|
100
|
+
* pressed in every theme.
|
|
101
|
+
*/
|
|
102
|
+
const FILL_STEP = 1.1;
|
|
103
|
+
/** The accent's least share over the tonal fill on hover, and over the hovered fill when pressed. */
|
|
104
|
+
const TONAL_HOVER_SHARE = 14;
|
|
105
|
+
const TONAL_PRESSED_SHARE = 12;
|
|
106
|
+
/**
|
|
107
|
+
* How far a state laid over a fill moves the fill away from the text on it,
|
|
108
|
+
* in percent of the fill kept: a primary's hover and press keep at most
|
|
109
|
+
* these, and less where the step would fall under FILL_STEP.
|
|
110
|
+
*/
|
|
111
|
+
const PRIMARY_HOVER_KEEP = 88;
|
|
112
|
+
const PRIMARY_PRESSED_KEEP = 76;
|
|
113
|
+
const SELECTION_CURSOR_KEEP = 80;
|
|
114
|
+
const SELECTION_HIT_KEEP = 70;
|
|
115
|
+
/**
|
|
116
|
+
* How far apart two chart series must be, as the distance between their
|
|
117
|
+
* sRGB channels (0 to 441), so no two series of one chart look alike.
|
|
118
|
+
*/
|
|
119
|
+
const SERIES_DISTANCE = 48;
|
|
120
|
+
/** How many series colours a theme defines (`--chart-1` to `--chart-8`). */
|
|
121
|
+
const SERIES_COUNT = 8;
|
|
29
122
|
/**
|
|
30
123
|
* How opaque a control that cannot act right now is drawn (`--disabled-opacity`,
|
|
31
124
|
* which the base stylesheet applies to every disabled control): its words,
|
|
32
125
|
* icons, and fill fade together, far enough from enabled text to read as
|
|
33
126
|
* unavailable at a glance in every theme, and near enough to stay legible.
|
|
34
127
|
*/
|
|
35
|
-
const DISABLED_OPACITY = 0.
|
|
128
|
+
const DISABLED_OPACITY = 0.5;
|
|
129
|
+
/** How opaque an item being dragged is drawn (`--dragging-opacity`), the same in every theme. */
|
|
130
|
+
const DRAGGING_OPACITY = 0.5;
|
|
131
|
+
/** How opaque a part set back while another is lit is drawn (`--dimmed-opacity`). */
|
|
132
|
+
const DIMMED_OPACITY = 0.45;
|
|
133
|
+
/** How opaque the fill under a chart's area series is (`--chart-area-opacity`). */
|
|
134
|
+
const CHART_AREA_OPACITY = 0.16;
|
|
36
135
|
/**
|
|
37
136
|
* What a theme's appearance decides on its own, the same for every theme of
|
|
38
137
|
* that appearance: how much each wash and lift shows over the grounds.
|
|
@@ -42,20 +141,21 @@ const BY_APPEARANCE = {
|
|
|
42
141
|
cursorRow: 10,
|
|
43
142
|
rowLift: () => translucent(WHITE, 35),
|
|
44
143
|
glassEdge: translucent(WHITE, 60),
|
|
45
|
-
|
|
46
|
-
// A pale fill barely brightens, so its hover deepens a touch instead.
|
|
47
|
-
tonalHoverBrightness: '0.97',
|
|
144
|
+
hoverWhite: 50,
|
|
48
145
|
fileListLift: 30,
|
|
49
|
-
terminalSelection: 22
|
|
146
|
+
terminalSelection: 22,
|
|
147
|
+
pressedBlack: 7,
|
|
148
|
+
shadow: { raised: 12, popover: 18, modal: 28, modalContact: 12, modalRing: 0 }
|
|
50
149
|
},
|
|
51
150
|
dark: {
|
|
52
151
|
cursorRow: 14,
|
|
53
152
|
rowLift: (palette) => translucent(palette.base, 50),
|
|
54
153
|
glassEdge: translucent(WHITE, 10),
|
|
55
|
-
|
|
56
|
-
tonalHoverBrightness: '1.12',
|
|
154
|
+
hoverWhite: 6,
|
|
57
155
|
fileListLift: 0,
|
|
58
|
-
terminalSelection: 28
|
|
156
|
+
terminalSelection: 28,
|
|
157
|
+
pressedBlack: 24,
|
|
158
|
+
shadow: { raised: 30, popover: 45, modal: 55, modalContact: 35, modalRing: 35 }
|
|
59
159
|
}
|
|
60
160
|
};
|
|
61
161
|
/**
|
|
@@ -66,6 +166,108 @@ function onFill(fill, palette) {
|
|
|
66
166
|
const ink = luminance(palette.text) < luminance(palette.crust) ? palette.text : palette.crust;
|
|
67
167
|
return contrast(WHITE, fill) >= contrast(ink, fill) ? WHITE : ink;
|
|
68
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* The text colour for a status fill, which may be a mid tone: `onFill`'s
|
|
171
|
+
* pick where it keeps 4.5:1, else white or black, whichever does.
|
|
172
|
+
*/
|
|
173
|
+
function textOnFill(fill, palette) {
|
|
174
|
+
const picks = [onFill(fill, palette), WHITE, BLACK];
|
|
175
|
+
return (picks.find((ink) => contrast(ink, fill) >= TEXT_CONTRAST) ??
|
|
176
|
+
(contrast(WHITE, fill) >= contrast(BLACK, fill) ? WHITE : BLACK));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* `fill` moved away from the text on it (`on`), keeping `keep` percent:
|
|
180
|
+
* toward black under white text, toward white under dark text, so a state
|
|
181
|
+
* laid over a fill (a hover, a cursor on a selection) never brings the fill
|
|
182
|
+
* nearer its text.
|
|
183
|
+
*/
|
|
184
|
+
function awayFrom(fill, on, keep) {
|
|
185
|
+
return mix(fill, luminance(on) > 0.5 ? BLACK : WHITE, keep);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* `color` moved only as far as it needs to keep `ratio` on every one of
|
|
189
|
+
* `grounds`: toward the first ground while it still keeps it (a tone that
|
|
190
|
+
* passes with room to spare is quietened), else away from it as `legibleOn`
|
|
191
|
+
* moves it. A mark drawn this way sits just over its floor, so it never
|
|
192
|
+
* outweighs a mark held at the same floor by rule.
|
|
193
|
+
*/
|
|
194
|
+
function nearestLegible(color, grounds, ratio) {
|
|
195
|
+
const keeps = (tone) => grounds.every((ground) => contrast(tone, ground) >= ratio);
|
|
196
|
+
if (!keeps(color))
|
|
197
|
+
return legibleOn(color, grounds, ratio);
|
|
198
|
+
const toward = grounds[0] ?? WHITE;
|
|
199
|
+
let tone = color;
|
|
200
|
+
for (let share = 99; share > 0; share -= 1) {
|
|
201
|
+
const next = mix(color, toward, share);
|
|
202
|
+
if (!keeps(next))
|
|
203
|
+
break;
|
|
204
|
+
tone = next;
|
|
205
|
+
}
|
|
206
|
+
return tone;
|
|
207
|
+
}
|
|
208
|
+
/** The distance between two colours' sRGB channels, 0 to 441. */
|
|
209
|
+
function channelDistance(a, b) {
|
|
210
|
+
const x = rgbOf(a);
|
|
211
|
+
const y = rgbOf(b);
|
|
212
|
+
return Math.hypot(x.r - y.r, x.g - y.g, x.b - y.b);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The chart series: the palette's hues in the order a chart has always
|
|
216
|
+
* assigned them (blue, peach, green, mauve, teal, red, yellow, pink), then
|
|
217
|
+
* the rest, each moved until it keeps 3:1 on every ground a chart is drawn
|
|
218
|
+
* on, taking the first eight that stand `SERIES_DISTANCE` apart from every
|
|
219
|
+
* series taken before. Where a palette runs out (several roles share one
|
|
220
|
+
* colour), the remainder are shades of the taken series toward the text
|
|
221
|
+
* and then deeper and paler (each moved back to 3:1), then midpoints between neighbouring series, so the
|
|
222
|
+
* eight stay distinct.
|
|
223
|
+
*/
|
|
224
|
+
function chartSeries(palette, grounds) {
|
|
225
|
+
const hues = [
|
|
226
|
+
palette.blue,
|
|
227
|
+
palette.peach,
|
|
228
|
+
palette.green,
|
|
229
|
+
palette.mauve,
|
|
230
|
+
palette.teal,
|
|
231
|
+
palette.red,
|
|
232
|
+
palette.yellow,
|
|
233
|
+
palette.pink,
|
|
234
|
+
palette.sky,
|
|
235
|
+
palette.sapphire,
|
|
236
|
+
palette.lavender,
|
|
237
|
+
palette.maroon,
|
|
238
|
+
palette.flamingo,
|
|
239
|
+
palette.rosewater
|
|
240
|
+
];
|
|
241
|
+
const taken = [];
|
|
242
|
+
const take = (hue) => {
|
|
243
|
+
if (taken.length >= SERIES_COUNT)
|
|
244
|
+
return;
|
|
245
|
+
const series = legibleOn(hue, grounds, MARK_CONTRAST);
|
|
246
|
+
if (taken.every((other) => channelDistance(series, other) >= SERIES_DISTANCE)) {
|
|
247
|
+
taken.push(series);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
hues.forEach(take);
|
|
251
|
+
// Shades of the series taken, a third and then half of the way to the
|
|
252
|
+
// text, then deeper ones (toward black on a light ground, white on a dark
|
|
253
|
+
// one), then the midpoints of neighbouring series.
|
|
254
|
+
const hueSeries = [...taken];
|
|
255
|
+
const far = luminance(grounds[0] ?? WHITE) > 0.18 ? BLACK : WHITE;
|
|
256
|
+
[35, 55].forEach((share) => hueSeries.forEach((series) => take(mix(palette.text, series, share))));
|
|
257
|
+
[35, 50].forEach((share) => hueSeries.forEach((series) => take(mix(far, series, share))));
|
|
258
|
+
const near = far === BLACK ? WHITE : BLACK;
|
|
259
|
+
[35, 50].forEach((share) => hueSeries.forEach((series) => take(mix(near, series, share))));
|
|
260
|
+
hueSeries.forEach((series, index) => {
|
|
261
|
+
const next = hueSeries[(index + 1) % hueSeries.length];
|
|
262
|
+
if (next !== undefined)
|
|
263
|
+
take(mix(series, next, 50));
|
|
264
|
+
});
|
|
265
|
+
// A palette too narrow for even that repeats its last series rather than
|
|
266
|
+
// leave a series unset; no theme in the catalog reaches this.
|
|
267
|
+
while (taken.length < SERIES_COUNT)
|
|
268
|
+
taken.push(taken.at(-1) ?? palette.blue);
|
|
269
|
+
return taken;
|
|
270
|
+
}
|
|
69
271
|
/**
|
|
70
272
|
* Every token a theme sets, as `themeTokens` gives it, before it is written
|
|
71
273
|
* into the stylesheet. `overrides` replaces a token where the theme was
|
|
@@ -83,22 +285,345 @@ function derivedTokens(palette, terminal, appearance, overrides, hues) {
|
|
|
83
285
|
const ground = tuned('--bg', palette.mantle);
|
|
84
286
|
const panel = palette.base;
|
|
85
287
|
const header = tuned('--bg-header', palette.crust);
|
|
288
|
+
const bare = [ground, panel, header];
|
|
86
289
|
const surfaceFill = tuned('--cursor-bg', palette.surface0);
|
|
290
|
+
// A listing's lift over the panel surface.
|
|
291
|
+
const fileList = mix(WHITE, panel, look.fileListLift);
|
|
292
|
+
// A listing's column strip: the header bar at 40% over the panel.
|
|
293
|
+
const strip = mix(header, panel, 40);
|
|
294
|
+
// A zebra row: the text's faint tint over the ground.
|
|
295
|
+
const zebra = mix(palette.text, ground, ZEBRA_TINT);
|
|
296
|
+
// What a row sits on: a panel, the ground (a grid), and a listing.
|
|
297
|
+
const rows = [panel, ground, fileList];
|
|
298
|
+
const shares = (from, to) => from <= to
|
|
299
|
+
? [...Array(to - from + 1).keys()].map((step) => from + step)
|
|
300
|
+
: [...Array(from - to + 1).keys()].map((step) => from - step);
|
|
301
|
+
// The frosted wash an outlined control takes on hover: white at the
|
|
302
|
+
// appearance's share, or the least more (up to HOVER_WHITE_MAX) that
|
|
303
|
+
// stands HOVER_FROM_REST apart from every ground a control rests on. On a
|
|
304
|
+
// panel already white or nearly (GitHub Light, One Light) no white can,
|
|
305
|
+
// so the wash is the text's least tint that does, with the text kept at
|
|
306
|
+
// 4.5:1 on the hovered face.
|
|
307
|
+
// A listing's ground is already lifted by white in a light theme; where no
|
|
308
|
+
// white reaches it but white reaches the bare grounds (Solarized Light),
|
|
309
|
+
// white stays, since a text tint there would darken the hover onto the
|
|
310
|
+
// press, which the text holds to 2% black.
|
|
311
|
+
const hoverUnder = [...bare, fileList];
|
|
312
|
+
const hoverStands = (tone, share, under = hoverUnder) => under.every((on) => contrast(mix(tone, on, share), on) >= HOVER_FROM_REST);
|
|
313
|
+
const whiteHover = shares(look.hoverWhite, HOVER_WHITE_MAX).find((share) => hoverStands(WHITE, share)) ??
|
|
314
|
+
shares(look.hoverWhite, HOVER_WHITE_MAX).find((share) => hoverStands(WHITE, share, bare));
|
|
315
|
+
const textHover = whiteHover === undefined
|
|
316
|
+
? (shares(2, 16).find((share) => hoverStands(palette.text, share) &&
|
|
317
|
+
hoverUnder.every((on) => contrast(palette.text, mix(palette.text, on, share)) >= TEXT_CONTRAST)) ?? 4)
|
|
318
|
+
: undefined;
|
|
319
|
+
const hoverTone = textHover === undefined ? WHITE : palette.text;
|
|
320
|
+
const hoverShare = textHover ?? whiteHover ?? look.hoverWhite;
|
|
321
|
+
const hovered = (on) => mix(hoverTone, on, hoverShare);
|
|
322
|
+
// Whether the text keeps 4.5:1 on `tint` at `share` over every one of `on`.
|
|
323
|
+
const holds = (tint, share, on) => on.every((under) => contrast(palette.text, mix(tint, under, share)) >= TEXT_CONTRAST);
|
|
324
|
+
// A status hue's strong wash: at most WASH.statusStrong, as strong as the
|
|
325
|
+
// text keeps 4.5:1 on it over every bare ground and a listing.
|
|
326
|
+
const statusStrong = (mark) => shares(WASH.statusStrong, WASH.status).find((share) => holds(mark, share, [...bare, fileList])) ?? WASH.status;
|
|
327
|
+
// The accent's state tints, for a given accent. A marked row (a row ticked
|
|
328
|
+
// in a list with a checkbox column): the accent's least tint from
|
|
329
|
+
// MARKED_TINT up to MARKED_TINT_MAX that stands MARKED_CONTRAST apart from
|
|
330
|
+
// the panel and the ground and keeps the text at 4.5:1, with room for the
|
|
331
|
+
// cursor's step on it. Where no tint does both (Solarized Light), the text
|
|
332
|
+
// wins: the strongest tint that keeps it, and the row's bar carries the
|
|
333
|
+
// mark. A cursor on a marked row adds MARKED_CURSOR_STEP where the text
|
|
334
|
+
// keeps 4.5:1, and never less than MARKED_CURSOR_MIN. The current item:
|
|
335
|
+
// the accent's tint at most CURRENT_TINT, stepped down until the text
|
|
336
|
+
// keeps 4.5:1 on it over every bare ground. With `markFloor`, each tint
|
|
337
|
+
// also stays light enough that the accent keeps 3:1 on it, for a theme
|
|
338
|
+
// whose accent cannot move (an override).
|
|
339
|
+
const stateShares = (tint, markFloor) => {
|
|
340
|
+
const fits = (share, on) => holds(tint, share, on) &&
|
|
341
|
+
(!markFloor || on.every((under) => contrast(tint, mix(tint, under, share)) >= MARK_CONTRAST));
|
|
342
|
+
const keeps = (share) => fits(share, rows) && fits(share + MARKED_CURSOR_MIN, rows);
|
|
343
|
+
const marked = shares(MARKED_TINT, MARKED_TINT_MAX).find((share) => keeps(share) &&
|
|
344
|
+
[panel, ground].every((on) => contrast(mix(tint, on, share), on) >= MARKED_CONTRAST)) ??
|
|
345
|
+
shares(MARKED_TINT_MAX, 1).find(keeps) ??
|
|
346
|
+
1;
|
|
347
|
+
const markedCursor = shares(marked + MARKED_CURSOR_STEP, marked + MARKED_CURSOR_MIN).find((share) => fits(share, rows)) ?? marked + MARKED_CURSOR_MIN;
|
|
348
|
+
const current = shares(CURRENT_TINT, 4).find((share) => fits(share, bare)) ?? 4;
|
|
349
|
+
return { marked, markedCursor, current };
|
|
350
|
+
};
|
|
351
|
+
const cursorRowOf = (tint) => tuned('--cursor-row-bg', mix(tint, panel, look.cursorRow));
|
|
87
352
|
// The accent: the blue, moved until the text on it keeps 4.5:1, as a
|
|
88
|
-
// selected row's name sits on it
|
|
89
|
-
|
|
353
|
+
// selected row's name sits on it; then moved on, a percent at a time, until
|
|
354
|
+
// it keeps 3:1 as a checked box, a ring, or a bar on every ground it marks:
|
|
355
|
+
// the bare grounds, a listing, the cursor row, and its own marked and
|
|
356
|
+
// current tints (Tokyo Night Day and One Light deepen a little). Where
|
|
357
|
+
// the accent is a theme's own (an override) or no step keeps both its
|
|
358
|
+
// text and its marks, the tints step down instead.
|
|
359
|
+
const accentBase = legibleOn(palette.blue, [onFill(palette.blue, palette)], TEXT_CONTRAST);
|
|
360
|
+
const accentMarks = (tint) => {
|
|
361
|
+
const state = stateShares(tint, false);
|
|
362
|
+
return [
|
|
363
|
+
...bare,
|
|
364
|
+
fileList,
|
|
365
|
+
cursorRowOf(tint),
|
|
366
|
+
...rows.map((on) => mix(tint, on, state.marked)),
|
|
367
|
+
...rows.map((on) => mix(tint, on, state.markedCursor)),
|
|
368
|
+
...bare.map((on) => mix(tint, on, state.current))
|
|
369
|
+
].every((on) => contrast(tint, on) >= MARK_CONTRAST);
|
|
370
|
+
};
|
|
371
|
+
const accentAway = luminance(ground) > 0.18 ? BLACK : WHITE;
|
|
372
|
+
const accentMoved = overrides['--accent'] === undefined
|
|
373
|
+
? shares(100, 60)
|
|
374
|
+
.map((share) => mix(accentBase, accentAway, share))
|
|
375
|
+
.find((tint) => contrast(onFill(tint, palette), tint) >= TEXT_CONTRAST && accentMarks(tint))
|
|
376
|
+
: undefined;
|
|
377
|
+
const accent = tuned('--accent', accentMoved ?? accentBase);
|
|
378
|
+
const onAccent = tuned('--on-accent', onFill(accent, palette));
|
|
379
|
+
const cursorRow = cursorRowOf(accent);
|
|
380
|
+
const state = stateShares(accent, accentMoved === undefined);
|
|
381
|
+
const marked = (on) => mix(accent, on, state.marked);
|
|
382
|
+
const markedCursor = (on) => mix(accent, on, state.markedCursor);
|
|
383
|
+
const current = (on) => mix(accent, on, state.current);
|
|
384
|
+
const markedGrounds = [...rows.map(marked), ...rows.map(markedCursor)];
|
|
385
|
+
const currentGrounds = bare.map(current);
|
|
90
386
|
// The neutral ramp from the quietest tone a word may wear to the text itself.
|
|
91
387
|
const quiet = [palette.subtext0, palette.subtext1, palette.text];
|
|
388
|
+
// The neutral ramp a mark or a control's outline steps up, quietest first.
|
|
389
|
+
const marks = [
|
|
390
|
+
palette.surface2,
|
|
391
|
+
palette.overlay0,
|
|
392
|
+
palette.overlay1,
|
|
393
|
+
palette.overlay2,
|
|
394
|
+
palette.subtext0,
|
|
395
|
+
palette.subtext1
|
|
396
|
+
];
|
|
92
397
|
// A recessed surface, such as a tab behind the selected one: the panel at
|
|
93
398
|
// 45% over the ground. The group marks keep their ring rule against it.
|
|
94
399
|
const recessed = mix(panel, ground, 45);
|
|
95
|
-
// A
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
400
|
+
// A row under the pointer: the text's least tint from 4% that stands
|
|
401
|
+
// ROW_HOVER_CONTRAST apart from every row ground (a zebra row included),
|
|
402
|
+
// darker on a light ground and lighter on a dark one, with the text kept.
|
|
403
|
+
const rowHoverUnder = [...rows, zebra];
|
|
404
|
+
const rowHoverShare = shares(4, 16).find((share) => rowHoverUnder.every((on) => {
|
|
405
|
+
const lit = mix(palette.text, on, share);
|
|
406
|
+
return (contrast(lit, on) >= ROW_HOVER_CONTRAST && contrast(palette.text, lit) >= TEXT_CONTRAST);
|
|
407
|
+
})) ?? 16;
|
|
408
|
+
const rowHovered = rowHoverUnder.map((on) => mix(palette.text, on, rowHoverShare));
|
|
409
|
+
// --text-dim sits on the ground, a panel, and the header bar, hovered or not.
|
|
410
|
+
const textDim = tuned('--text-dim', firstLegible(quiet, [...bare, ...bare.map(hovered)], TEXT_CONTRAST));
|
|
411
|
+
// A row's meta on a listing, the ground, a zebra row, the column strip,
|
|
412
|
+
// and under the frosted hover wash; a dialog's context on the title strip.
|
|
413
|
+
// On every state ground (a row under --row-hover included) a quiet word
|
|
414
|
+
// turns --text-on-surface, so the meta keeps its tone at rest.
|
|
415
|
+
const rowMeta = tuned('--row-meta-text', firstLegible([palette.overlay2, ...quiet], [fileList, panel, header, ground, zebra, strip, hovered(fileList), hovered(panel)], TEXT_CONTRAST));
|
|
101
416
|
const primary = tuned('--primary', legibleOn(palette.lavender, [onFill(palette.lavender, palette)], TEXT_CONTRAST));
|
|
417
|
+
const onPrimary = tuned('--on-primary', onFill(primary, palette));
|
|
418
|
+
// A primary's hover and press: each moved away from its text, keeping at
|
|
419
|
+
// most `keep` percent of the primary, and less until it stands FILL_STEP
|
|
420
|
+
// apart from the state before it (`from`).
|
|
421
|
+
// The press stands PRESSED_FROM_HOVER from the hover, as every press does;
|
|
422
|
+
// moving away from the text keeps the text at 4.5:1 on it.
|
|
423
|
+
const primaryStep = (from, keep, step) => shares(keep, 1)
|
|
424
|
+
.map((share) => awayFrom(primary, onPrimary, share))
|
|
425
|
+
.find((fill) => contrast(fill, from) >= step) ?? awayFrom(primary, onPrimary, 1);
|
|
426
|
+
const primaryHover = primaryStep(primary, PRIMARY_HOVER_KEEP, FILL_STEP);
|
|
427
|
+
const primaryPressed = primaryStep(primaryHover, PRIMARY_PRESSED_KEEP, PRESSED_FROM_HOVER);
|
|
428
|
+
// The trough of a segmented choice and a progress bar: the text's tint,
|
|
429
|
+
// the strongest from 8% down that keeps the accent fill at 3:1 on it over
|
|
430
|
+
// a panel and the ground, and the text at 4.5:1 over every bare ground,
|
|
431
|
+
// hovered or not (a hovered segment); a --control-border ring draws its
|
|
432
|
+
// edge.
|
|
433
|
+
const trackShare = shares(8, 3).find((share) => [panel, ground].every((on) => contrast(accent, mix(palette.text, on, share)) >= MARK_CONTRAST) &&
|
|
434
|
+
bare.every((on) => {
|
|
435
|
+
const track = mix(palette.text, on, share);
|
|
436
|
+
return (contrast(palette.text, track) >= TEXT_CONTRAST &&
|
|
437
|
+
contrast(palette.text, hovered(track)) >= TEXT_CONTRAST);
|
|
438
|
+
})) ?? 3;
|
|
439
|
+
const tracks = bare.map((on) => mix(palette.text, on, trackShare));
|
|
440
|
+
// Status marks: the palette hue, moved until it keeps 3:1 as a dot or an
|
|
441
|
+
// icon on every ground a mark sits on, the inactive cursor's fill included.
|
|
442
|
+
const markGrounds = [panel, ground, header, fileList, cursorRow, surfaceFill];
|
|
443
|
+
const warning = tuned('--warning', legibleOn(palette.yellow, markGrounds, MARK_CONTRAST));
|
|
444
|
+
// An edited cell: the warning's washes over the ground and a panel.
|
|
445
|
+
const editedGrounds = [ground, panel].flatMap((on) => [
|
|
446
|
+
mix(warning, on, WASH.status),
|
|
447
|
+
mix(warning, on, statusStrong(warning))
|
|
448
|
+
]);
|
|
449
|
+
// Every state ground a row or an item takes: the cursor row and the
|
|
450
|
+
// inactive pane's cursor (--fill), a hovered row, a marked row and the
|
|
451
|
+
// cursor on it, the current item, and an edited cell. A quiet word on any
|
|
452
|
+
// of them is --text-on-surface, and every coloured word keeps 4.5:1 on
|
|
453
|
+
// each.
|
|
454
|
+
const stateGrounds = [
|
|
455
|
+
cursorRow,
|
|
456
|
+
surfaceFill,
|
|
457
|
+
hovered(panel),
|
|
458
|
+
hovered(fileList),
|
|
459
|
+
...rowHovered,
|
|
460
|
+
...markedGrounds,
|
|
461
|
+
...currentGrounds,
|
|
462
|
+
...editedGrounds
|
|
463
|
+
];
|
|
464
|
+
const textOnSurface = tuned('--text-on-surface', firstLegible(quiet, [...stateGrounds, ...tracks], TEXT_CONTRAST));
|
|
465
|
+
// Every ground a coloured word is drawn on: the bare grounds, a listing,
|
|
466
|
+
// its column strip, and every state ground.
|
|
467
|
+
const wordGrounds = [panel, ground, header, fileList, strip, ...stateGrounds];
|
|
468
|
+
// The success green is also a finished run's bar on the control trough.
|
|
469
|
+
const success = tuned('--success', legibleOn(palette.green, [...markGrounds, ...tracks], MARK_CONTRAST));
|
|
470
|
+
// Errors and destructive marks: the red, moved until it keeps 4.5:1 on a
|
|
471
|
+
// panel, where error text sat before it had a text role.
|
|
472
|
+
const danger = tuned('--danger', legibleOn(palette.red, [panel], TEXT_CONTRAST));
|
|
473
|
+
// A status word: its mark moved until it keeps 4.5:1 on every word ground
|
|
474
|
+
// and on its own washes over the panel and the ground.
|
|
475
|
+
const statusText = (mark, strong = statusStrong(mark)) => legibleOn(mark, [
|
|
476
|
+
...wordGrounds,
|
|
477
|
+
...[panel, ground].flatMap((on) => [mix(mark, on, WASH.status), mix(mark, on, strong)])
|
|
478
|
+
], TEXT_CONTRAST);
|
|
479
|
+
// A solid fill held down (a checked box or radio pressed): the least move
|
|
480
|
+
// that stands PRESSED_FROM_HOVER from the fill while the mark drawn on it
|
|
481
|
+
// keeps 4.5:1 and the fill, which also edges the box, keeps 3:1 on every
|
|
482
|
+
// ground a box rests on. First away from the text on it (darker under
|
|
483
|
+
// white text, lighter under dark text, as the pale accents of the dark
|
|
484
|
+
// themes take); where that runs out of room (a pale yellow next to white),
|
|
485
|
+
// toward the text. Where no face keeps both the mark and the grounds (the
|
|
486
|
+
// warning of One Light, Rosé Pine Dawn, and Solarized Light, which sits
|
|
487
|
+
// near 3:1 on the header with black text near 4.5:1 on it), the mark wins
|
|
488
|
+
// and the box keeps its resting edge (--check-on), which holds 3:1.
|
|
489
|
+
const boxGrounds = [...bare, fileList];
|
|
490
|
+
const pressedFill = (fill, on) => {
|
|
491
|
+
const toward = luminance(on) > 0.5 ? WHITE : BLACK;
|
|
492
|
+
const faces = [
|
|
493
|
+
...shares(99, 1).map((keep) => awayFrom(fill, on, keep)),
|
|
494
|
+
...shares(99, 1).map((keep) => mix(fill, toward, keep))
|
|
495
|
+
];
|
|
496
|
+
const steps = (face) => contrast(face, fill) >= PRESSED_FROM_HOVER && contrast(on, face) >= TEXT_CONTRAST;
|
|
497
|
+
return (faces.find((face) => steps(face) && boxGrounds.every((under) => contrast(face, under) >= MARK_CONTRAST)) ??
|
|
498
|
+
faces.find(steps) ??
|
|
499
|
+
awayFrom(fill, on, 1));
|
|
500
|
+
};
|
|
501
|
+
const onDanger = tuned('--on-danger', textOnFill(danger, palette));
|
|
502
|
+
const onWarning = tuned('--on-warning', textOnFill(warning, palette));
|
|
503
|
+
const onSuccess = tuned('--on-success', textOnFill(success, palette));
|
|
504
|
+
// A quiet word on a listing's state rows (a hidden entry's name under the
|
|
505
|
+
// cursor, the pointer, or a mark): the tone nearest the row meta, toward
|
|
506
|
+
// the text, that keeps 4.5:1 on the cursor row, the inactive pane's
|
|
507
|
+
// cursor, a hovered row, and a marked row and the cursor on it. Where the
|
|
508
|
+
// text itself sits near 4.5:1 on those rows (Latte, Rosé Pine Dawn,
|
|
509
|
+
// Solarized Light and Dark, Tokyo Night Day, One Dark) it is the text or
|
|
510
|
+
// within a shade of it, and a quiet entry is told apart by its glyph in
|
|
511
|
+
// --control-border-strong, which keeps 3:1 on each of those rows.
|
|
512
|
+
const listingStateGrounds = [
|
|
513
|
+
cursorRow,
|
|
514
|
+
surfaceFill,
|
|
515
|
+
...rowHovered,
|
|
516
|
+
...markedGrounds
|
|
517
|
+
];
|
|
518
|
+
const textDimOnSurface = shares(0, 100)
|
|
519
|
+
.map((share) => mix(palette.text, rowMeta, share))
|
|
520
|
+
.find((tone) => listingStateGrounds.every((on) => contrast(tone, on) >= TEXT_CONTRAST)) ??
|
|
521
|
+
palette.text;
|
|
522
|
+
// The terminal's cursor: the palette's cursor moved toward the terminal's
|
|
523
|
+
// text until it stands 3:1 from the terminal's ground, as every mark does;
|
|
524
|
+
// the cell under a block cursor is drawn in the ground's colour.
|
|
525
|
+
const terminalCursor = shares(0, 100)
|
|
526
|
+
.map((share) => mix(palette.text, terminal.cursor, share))
|
|
527
|
+
.find((tone) => contrast(tone, palette.base) >= MARK_CONTRAST) ?? palette.text;
|
|
528
|
+
const selectionCursor = awayFrom(accent, onAccent, SELECTION_CURSOR_KEEP);
|
|
529
|
+
const selectionHit = awayFrom(accent, onAccent, SELECTION_HIT_KEEP);
|
|
530
|
+
// Quiet words on a selected row: the on-accent text mixed toward the
|
|
531
|
+
// accent, the quietest step that keeps 4.5:1 on the selection and the
|
|
532
|
+
// cursor on it.
|
|
533
|
+
const onSelectedDim = firstLegible([70, 80, 90].map((share) => mix(onAccent, accent, share)).concat(onAccent), [accent, selectionCursor], TEXT_CONTRAST);
|
|
534
|
+
// A control's outline keeps 3:1 wherever a control rests: the bare
|
|
535
|
+
// grounds, a listing, and a zebra row. On a tinted ground (a segment's
|
|
536
|
+
// thumb on the trough, a checkbox on a hovered, cursor, or marked row) it
|
|
537
|
+
// is the stronger outline, so a field at rest keeps its quiet edge.
|
|
538
|
+
const controlBorder = firstLegible(marks, [...bare, fileList, zebra], MARK_CONTRAST);
|
|
539
|
+
const controlBorderStrong = firstLegible(marks, [...bare, fileList, zebra, ...tracks, cursorRow, surfaceFill, ...rowHovered, ...markedGrounds], MARK_CONTRAST);
|
|
540
|
+
// The tonal fill (the cursor row's tint) and its two states, each the
|
|
541
|
+
// accent at TONAL_HOVER_SHARE (TONAL_PRESSED_SHARE) over the state before
|
|
542
|
+
// it, and more where that stands less than FILL_STEP apart from it, so
|
|
543
|
+
// hover and press deepen away from the panel as the primary's do. The
|
|
544
|
+
// text in the primary hue is floored after, at 4.5:1 on all three fills.
|
|
545
|
+
const tonalStep = (from, least, step) => shares(least, 100)
|
|
546
|
+
.map((share) => mix(accent, from, share))
|
|
547
|
+
.find((fill) => contrast(fill, from) >= step) ?? accent;
|
|
548
|
+
const tonalHover = tuned('--tonal-hover', tonalStep(cursorRow, TONAL_HOVER_SHARE, FILL_STEP));
|
|
549
|
+
const tonalPressed = tuned('--tonal-pressed', tonalStep(tonalHover, TONAL_PRESSED_SHARE, PRESSED_FROM_HOVER));
|
|
550
|
+
const onTonal = tuned('--on-tonal', legibleOn(palette.lavender, [cursorRow, tonalHover, tonalPressed], TEXT_CONTRAST));
|
|
551
|
+
// A press on an outlined control. In a light theme, black at the
|
|
552
|
+
// appearance's share, stepped down where the text on it would fall under
|
|
553
|
+
// 4.5:1 (the recipe's inner line carries the press there). In a dark
|
|
554
|
+
// theme, the least black from the appearance's share up to twice it that
|
|
555
|
+
// stands PRESSED_CONTRAST apart from every bare ground; where black cannot
|
|
556
|
+
// darken a ground that far (the near-black grounds of the darkest
|
|
557
|
+
// themes, where nothing darker than rest can stand apart from it), the
|
|
558
|
+
// text's least tint that lifts the face past its hovered face, at least
|
|
559
|
+
// PRESSED_FROM_HOVER apart from it, so the press is one clear step from
|
|
560
|
+
// hover as hover is from rest (under it where the text leaves no room
|
|
561
|
+
// above it, as in Solarized Dark). Black darkens a ground at least
|
|
562
|
+
// PRESSED_FROM_HOVER from the frosted hover in every theme but Solarized
|
|
563
|
+
// Light, whose text leaves black 2%; the recipe's inner line and inset
|
|
564
|
+
// shadow carry that press.
|
|
565
|
+
const pressedUnder = [...bare, strip];
|
|
566
|
+
const textKeeps = (fill) => pressedUnder.every((on) => contrast(palette.text, fill(on)) >= TEXT_CONTRAST);
|
|
567
|
+
const blackStands = (share) => bare.every((on) => contrast(mix(BLACK, on, share), on) >= PRESSED_CONTRAST);
|
|
568
|
+
// In a light theme, the least black from the appearance's share up to
|
|
569
|
+
// twice it that stands PRESSED_FROM_HOVER past the hovered face, which a
|
|
570
|
+
// text tint darkens where white cannot lift the panel; else the strongest
|
|
571
|
+
// from the appearance's share down that the text keeps.
|
|
572
|
+
const blackFromHover = (share) => bare.every((on) => contrast(mix(BLACK, on, share), hovered(on)) >= PRESSED_FROM_HOVER);
|
|
573
|
+
const blackShare = appearance === 'light'
|
|
574
|
+
? (shares(look.pressedBlack, 2 * look.pressedBlack).find((share) => blackFromHover(share) && textKeeps((on) => mix(BLACK, on, share))) ??
|
|
575
|
+
shares(look.pressedBlack, 2).find((share) => textKeeps((on) => mix(BLACK, on, share))) ??
|
|
576
|
+
2)
|
|
577
|
+
: shares(look.pressedBlack, 2 * look.pressedBlack).find((share) => blackStands(share) && textKeeps((on) => mix(BLACK, on, share)));
|
|
578
|
+
const tintKeeps = (share) => textKeeps((on) => mix(palette.text, on, share));
|
|
579
|
+
const tintStands = (share) => bare.every((on) => contrast(mix(palette.text, on, share), on) >= PRESSED_CONTRAST);
|
|
580
|
+
// Where the text leaves no tint both far enough from rest and from hover
|
|
581
|
+
// (Solarized Dark), the strongest tint the text keeps that stands apart
|
|
582
|
+
// from rest; the recipe's inner line marks the press beside it.
|
|
583
|
+
const tintShare = blackShare === undefined
|
|
584
|
+
? (shares(4, 30).find((share) => tintKeeps(share) &&
|
|
585
|
+
tintStands(share) &&
|
|
586
|
+
bare.every((on) => contrast(mix(palette.text, on, share), hovered(on)) >= PRESSED_FROM_HOVER)) ??
|
|
587
|
+
shares(30, 4).find((share) => tintKeeps(share) && tintStands(share)) ??
|
|
588
|
+
10)
|
|
589
|
+
: undefined;
|
|
590
|
+
const pressedWash = blackShare === undefined
|
|
591
|
+
? translucent(palette.text, tintShare ?? 10)
|
|
592
|
+
: translucent(BLACK, blackShare);
|
|
593
|
+
// An accent tint the text keeps 4.5:1 on, the strongest from `most`
|
|
594
|
+
// percent of the accent down over every ground in `under`; transparent
|
|
595
|
+
// where none does.
|
|
596
|
+
const accentShare = (most, under) => shares(most, 1).find((step) => holds(accent, step, under));
|
|
597
|
+
const accentTint = (most, under) => {
|
|
598
|
+
const share = accentShare(most, under);
|
|
599
|
+
return share === undefined ? 'transparent' : translucent(accent, share);
|
|
600
|
+
};
|
|
601
|
+
// The accent's washes: a band or a marked column (over a zebra row too),
|
|
602
|
+
// and what stands out from a wash (a hovered level), each as strong as the
|
|
603
|
+
// text on it allows.
|
|
604
|
+
const washShare = accentShare(WASH.accent, [...bare, fileList, zebra]) ?? 0;
|
|
605
|
+
const washStrongShare = accentShare(WASH.accentStrong, [...bare, fileList]) ?? 0;
|
|
606
|
+
// What a control lit by the accent wash (a palette's level chip) takes
|
|
607
|
+
// while held: a face PRESSED_FROM_HOVER apart from the strong wash over a
|
|
608
|
+
// panel and the ground, with the text at 4.5:1 and the current ring at
|
|
609
|
+
// 3:1 on it. First the accent's least share past the strong wash (a dark
|
|
610
|
+
// theme, where more accent lifts the face); else the hovered face over
|
|
611
|
+
// the panel darkened by the least black that does (a light theme, where
|
|
612
|
+
// the palette's panel is under the chip), as an opaque face; else the
|
|
613
|
+
// outlined press (--pressed-wash).
|
|
614
|
+
const currentRing = legibleOn(accent, [...bare, ...currentGrounds], MARK_CONTRAST);
|
|
615
|
+
const pressedFace = (face, from) => contrast(face, from) >= PRESSED_FROM_HOVER &&
|
|
616
|
+
contrast(palette.text, face) >= TEXT_CONTRAST &&
|
|
617
|
+
contrast(currentRing, face) >= MARK_CONTRAST;
|
|
618
|
+
const washPressedShare = shares(washStrongShare + 1, 60).find((share) => [panel, ground].every((on) => pressedFace(mix(accent, on, share), mix(accent, on, washStrongShare))));
|
|
619
|
+
const washHoveredPanel = mix(accent, panel, washStrongShare);
|
|
620
|
+
const washPressedFace = shares(1, 30)
|
|
621
|
+
.map((share) => mix(BLACK, washHoveredPanel, share))
|
|
622
|
+
.find((face) => pressedFace(face, washHoveredPanel));
|
|
623
|
+
const accentWashPressed = washPressedShare !== undefined
|
|
624
|
+
? translucent(accent, washPressedShare)
|
|
625
|
+
: (washPressedFace ?? pressedWash);
|
|
626
|
+
const series = chartSeries(palette, [panel, ground]);
|
|
102
627
|
// Each group hue's palette role, unless the theme draws it apart
|
|
103
628
|
// (`Theme.groups`).
|
|
104
629
|
const groups = {
|
|
@@ -111,39 +636,112 @@ function derivedTokens(palette, terminal, appearance, overrides, hues) {
|
|
|
111
636
|
yellow: hues.yellow ?? palette.yellow,
|
|
112
637
|
red: hues.red ?? palette.red
|
|
113
638
|
};
|
|
639
|
+
const shadow = look.shadow;
|
|
114
640
|
return {
|
|
115
641
|
'--bg': ground,
|
|
116
642
|
'--bg-panel': panel,
|
|
117
643
|
'--bg-header': header,
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
'--border
|
|
644
|
+
// Dividers: the quietest of surface0 up that stands 1.15:1 apart from
|
|
645
|
+
// every bare ground (a light theme's header is as dark as surface0).
|
|
646
|
+
'--border': tuned('--border', firstLegible([palette.surface0, palette.surface1, palette.surface2, palette.overlay0], bare, BORDER_CONTRAST)),
|
|
647
|
+
// Frames and outlines on surface0 fills, where --border vanishes: the
|
|
648
|
+
// quietest of surface1 up that stands 1.3:1 apart from every bare ground.
|
|
649
|
+
'--border-strong': tuned('--border-strong', firstLegible([palette.surface1, palette.surface2, palette.overlay0, palette.overlay1], bare, BORDER_STRONG_CONTRAST)),
|
|
650
|
+
// The outline of what a user types in or toggles (a field, a select, a
|
|
651
|
+
// checkbox, a radio, a switch at rest) and of the neutral Button and
|
|
652
|
+
// IconButton: the quietest neutral from surface2 up that keeps 3:1 on
|
|
653
|
+
// every bare ground and a listing. Also a scrollbar's thumb and an idle
|
|
654
|
+
// status ring.
|
|
655
|
+
'--control-border': tuned('--control-border', controlBorder),
|
|
656
|
+
// A control's outline on a tinted ground: a segment's thumb on its
|
|
657
|
+
// trough, a checkbox on a hovered, cursor, or marked row. The quietest
|
|
658
|
+
// neutral from surface2 up that keeps 3:1 on each of them.
|
|
659
|
+
'--control-border-strong': controlBorderStrong,
|
|
660
|
+
// The trough of a segmented choice and a progress bar: the text's tint
|
|
661
|
+
// over whatever is under it; text on it is --text-on-surface.
|
|
662
|
+
'--control-track': translucent(palette.text, trackShare),
|
|
663
|
+
// A stopped or paused progress bar on the trough: surface2 moved only as
|
|
664
|
+
// far as it needs to keep 3:1 on the trough, never weightier than the
|
|
665
|
+
// accent of a running bar there.
|
|
666
|
+
'--progress-idle': nearestLegible(palette.surface2, [tracks[0] ?? ground, tracks[1] ?? panel], MARK_CONTRAST),
|
|
667
|
+
// An idle status mark (a hollow ring: stopped, not started): the
|
|
668
|
+
// quietest neutral from surface2 up that keeps 3:1 on a listing, the
|
|
669
|
+
// cursor row, a panel, and the ground.
|
|
670
|
+
'--idle-mark': firstLegible(marks, [fileList, cursorRow, panel, ground], MARK_CONTRAST),
|
|
121
671
|
'--text': palette.text,
|
|
122
672
|
// The quietest subtext that keeps 4.5:1 on the ground, a panel, and the header bar
|
|
123
673
|
// (Latte's subtext0 misses it on mantle).
|
|
124
674
|
'--text-dim': textDim,
|
|
125
|
-
// The quietest subtext that keeps 4.5:1 on surface0 fills
|
|
126
|
-
//
|
|
127
|
-
'--text-on-surface':
|
|
675
|
+
// The quietest subtext that keeps 4.5:1 on surface0 fills, the cursor
|
|
676
|
+
// row, and the control trough (Latte needs the text itself).
|
|
677
|
+
'--text-on-surface': textOnSurface,
|
|
678
|
+
// A quiet word on a listing's state rows (see textDimOnSurface): a
|
|
679
|
+
// hidden entry stays quieter than a plain one under the cursor, the
|
|
680
|
+
// pointer, and a mark, where the theme leaves room.
|
|
681
|
+
'--text-dim-on-surface': textDimOnSurface,
|
|
682
|
+
// Separators and decorative glyphs that are never words (a crumb's
|
|
683
|
+
// slash, a group heading's rule): the quietest neutral from overlay2 up
|
|
684
|
+
// that keeps 3:1 on every bare ground.
|
|
685
|
+
'--text-faint': tuned('--text-faint', firstLegible([palette.overlay2, ...quiet], bare, MARK_CONTRAST)),
|
|
128
686
|
// Selection, focus, and links.
|
|
129
687
|
'--accent': accent,
|
|
130
|
-
'--on-accent':
|
|
688
|
+
'--on-accent': onAccent,
|
|
689
|
+
// The accent as words (a link, a lit row action, a key cap's letter):
|
|
690
|
+
// moved until it keeps 4.5:1 on every word ground and on the accent's
|
|
691
|
+
// washes over the bare grounds.
|
|
692
|
+
'--accent-text': tuned('--accent-text', legibleOn(accent, [
|
|
693
|
+
...wordGrounds,
|
|
694
|
+
...bare.flatMap((on) => [mix(accent, on, washShare), mix(accent, on, washStrongShare)])
|
|
695
|
+
], TEXT_CONTRAST)),
|
|
696
|
+
// Quiet words on a selected row (its meta, a hidden entry's name).
|
|
697
|
+
'--on-selected-dim': onSelectedDim,
|
|
698
|
+
// A fill a step away from the text on it for a state laid over it: the
|
|
699
|
+
// cursor on a selection, a fuzzy match's characters over a selection,
|
|
700
|
+
// and a primary fill on hover.
|
|
701
|
+
'--selection-cursor': selectionCursor,
|
|
702
|
+
'--selection-hit': selectionHit,
|
|
703
|
+
// A marked row's tint (an accent wash floored apart from the ground),
|
|
704
|
+
// and the same row under the cursor.
|
|
705
|
+
'--marked-bg': translucent(accent, state.marked),
|
|
706
|
+
'--marked-cursor-bg': translucent(accent, state.markedCursor),
|
|
707
|
+
// The current item (the open page, the chosen tab): its own tint, never
|
|
708
|
+
// the cursor's, with the text at 4.5:1 on it, and an opaque ring at 3:1
|
|
709
|
+
// on the bare grounds and on the tint, which marks the item in every
|
|
710
|
+
// theme however faint the tint has to be.
|
|
711
|
+
'--current-bg': translucent(accent, state.current),
|
|
712
|
+
'--current-ring': currentRing,
|
|
713
|
+
// A fuzzy match's characters: the accent's wash (at most WASH.accent)
|
|
714
|
+
// that keeps the text at 4.5:1 on a listing, a panel, and the cursor row;
|
|
715
|
+
// its underline (--match-mark) carries the mark where the wash cannot.
|
|
716
|
+
'--match-bg': accentTint(WASH.accent, [fileList, panel, cursorRow]),
|
|
717
|
+
// Selected text (::selection): the accent's strong wash at most, as far
|
|
718
|
+
// as the text keeps 4.5:1 on every bare ground.
|
|
719
|
+
'--text-selection-bg': accentTint(WASH.accentStrong, bare),
|
|
131
720
|
// The palette's lavender as is, for icons and marks drawn in the primary
|
|
132
721
|
// hue; the primary fill and the tonal text derive from the same role.
|
|
133
722
|
'--primary-hue': palette.lavender,
|
|
723
|
+
// The primary hue as a mark (a folder icon): moved until it keeps 3:1 on
|
|
724
|
+
// a listing, the cursor row, a panel, and the ground.
|
|
725
|
+
'--primary-mark': legibleOn(palette.lavender, [fileList, cursorRow, panel, ground], MARK_CONTRAST),
|
|
134
726
|
// Primary actions wear the primary hue, moved until its text keeps
|
|
135
727
|
// 4.5:1, so they stand apart from the accent that marks selection,
|
|
136
728
|
// focus, and links.
|
|
137
729
|
'--primary': primary,
|
|
138
|
-
'--on-primary':
|
|
730
|
+
'--on-primary': onPrimary,
|
|
731
|
+
'--primary-hover': primaryHover,
|
|
732
|
+
// A pressed primary: a step past its hover, away from its text.
|
|
733
|
+
'--primary-pressed': primaryPressed,
|
|
139
734
|
// The middle button tier (.button-tonal) for a row's routine positive
|
|
140
735
|
// action such as Install: the cursor row's tint (--tonal) with text in
|
|
141
736
|
// the primary hue and a hairline, a quiet step below the solid primary and
|
|
142
737
|
// above the neutral outline; the hairline keeps it reading as a button,
|
|
143
|
-
// not as a highlighted row, inside tables.
|
|
144
|
-
|
|
738
|
+
// not as a highlighted row, inside tables. On hover the fill deepens a
|
|
739
|
+
// step toward the accent.
|
|
740
|
+
'--on-tonal': onTonal,
|
|
145
741
|
'--tonal-border': tuned('--tonal-border', mix(accent, cursorRow, 25)),
|
|
146
|
-
'--tonal-hover
|
|
742
|
+
'--tonal-hover': tonalHover,
|
|
743
|
+
// A pressed tonal button: a step past its hover, the text kept at 4.5:1.
|
|
744
|
+
'--tonal-pressed': tonalPressed,
|
|
147
745
|
// Listings lift themselves off the ground, so rows read as a pane rather
|
|
148
746
|
// than as the ground.
|
|
149
747
|
'--row-lift': look.rowLift(palette),
|
|
@@ -154,17 +752,70 @@ function derivedTokens(palette, terminal, appearance, overrides, hues) {
|
|
|
154
752
|
// A listing row's attributes one tone under its name, as Finder's are, so
|
|
155
753
|
// the names lead; a dialog's title strip names where it acts in the same
|
|
156
754
|
// tone. The quietest tone from overlay2 up that keeps 4.5:1 on the
|
|
157
|
-
// listing,
|
|
755
|
+
// listing, a panel, and the header bar.
|
|
158
756
|
'--row-meta-text': rowMeta,
|
|
159
757
|
// Glass: the specular hairline along a raised surface's top edge, and the
|
|
160
|
-
// frosted wash every outlined control takes on hover
|
|
758
|
+
// frosted wash every outlined control takes on hover, at least
|
|
759
|
+
// HOVER_FROM_REST from rest (white, or the text's tint on a white panel;
|
|
760
|
+
// see hoverShare); a pressed outlined control darkens instead.
|
|
161
761
|
'--glass-edge': look.glassEdge,
|
|
162
|
-
'--hover-wash':
|
|
163
|
-
|
|
164
|
-
'
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
|
|
762
|
+
'--hover-wash': translucent(hoverTone, hoverShare),
|
|
763
|
+
// A pressed outlined control: black where it darkens the ground enough
|
|
764
|
+
// and keeps the text, else the text's tint (see pressedWash).
|
|
765
|
+
'--pressed-wash': pressedWash,
|
|
766
|
+
// A well's inner top shade (a text field, a checkbox), black in every
|
|
767
|
+
// theme; never a state.
|
|
768
|
+
'--well-shade': translucent(BLACK, look.pressedBlack),
|
|
769
|
+
// A row under the pointer (a grid or listing that acts on click): the
|
|
770
|
+
// text's tint, darker on a light ground and lighter on a dark one,
|
|
771
|
+
// standing apart from every row ground, a zebra row included.
|
|
772
|
+
'--row-hover': translucent(palette.text, rowHoverShare),
|
|
773
|
+
// The accent's washes, each as strong as the text on it allows: a band
|
|
774
|
+
// or a marked column, and what stands out from a wash.
|
|
775
|
+
'--accent-wash': translucent(accent, washShare),
|
|
776
|
+
'--accent-wash-strong': translucent(accent, washStrongShare),
|
|
777
|
+
// A control lit by the accent wash, held (see washPressedShare).
|
|
778
|
+
'--accent-wash-pressed': accentWashPressed,
|
|
779
|
+
// Status marks (dots, icons, bars), each floored at 3:1 on the grounds
|
|
780
|
+
// a mark sits on; the danger red at 4.5:1 on a panel.
|
|
781
|
+
'--warning': warning,
|
|
782
|
+
'--success': success,
|
|
783
|
+
'--danger': danger,
|
|
784
|
+
// Status words, each floored at 4.5:1 on every word ground and on its
|
|
785
|
+
// own washes.
|
|
786
|
+
'--danger-text': tuned('--danger-text', statusText(danger, WASH.statusStrong)),
|
|
787
|
+
'--warning-text': tuned('--warning-text', statusText(warning)),
|
|
788
|
+
'--success-text': tuned('--success-text', statusText(success)),
|
|
789
|
+
// What stands out from a status wash (a badge, an edited cell's mark):
|
|
790
|
+
// each hue at most WASH.statusStrong, as strong as the text on it allows.
|
|
791
|
+
// The danger's is always WASH.statusStrong: it is a pressed destructive
|
|
792
|
+
// control and a danger badge, whose words are --danger-text (floored on
|
|
793
|
+
// it), so it keeps a full step from the hover's --danger-wash.
|
|
794
|
+
'--danger-wash-strong': translucent(danger, WASH.statusStrong),
|
|
795
|
+
'--warning-wash-strong': translucent(warning, statusStrong(warning)),
|
|
796
|
+
// A binary value in a grid cell: the palette's teal as a word, moved
|
|
797
|
+
// until it keeps 4.5:1 on every ground a cell takes.
|
|
798
|
+
'--cell-binary-text': legibleOn(palette.teal, [ground, panel, zebra, cursorRow, ...stateGrounds], TEXT_CONTRAST),
|
|
799
|
+
// Text on a solid status fill (a destructive key cap, a status badge).
|
|
800
|
+
'--on-danger': onDanger,
|
|
801
|
+
'--on-warning': onWarning,
|
|
802
|
+
'--on-success': onSuccess,
|
|
803
|
+
// A solid fill held down (a checked box or radio pressed), one clear
|
|
804
|
+
// step from its rest fill with its mark kept (see pressedFill).
|
|
805
|
+
'--accent-pressed': pressedFill(accent, onAccent),
|
|
806
|
+
'--danger-pressed': pressedFill(danger, onDanger),
|
|
807
|
+
'--warning-pressed': pressedFill(warning, onWarning),
|
|
808
|
+
// Elevation by layer, strength by appearance: a raised part (a segment's
|
|
809
|
+
// thumb, a knob, a lens), a popover (menus, tooltips, notices, the date
|
|
810
|
+
// panel, anything being dragged), and the modal layer (dialogs,
|
|
811
|
+
// palettes). Depth follows the stacking order.
|
|
812
|
+
'--shadow-raised': `0 1px 2px ${translucent(BLACK, shadow.raised)}`,
|
|
813
|
+
'--shadow-popover': `0 8px 24px ${translucent(BLACK, shadow.popover)}`,
|
|
814
|
+
'--shadow-modal': [
|
|
815
|
+
`0 24px 60px ${translucent(BLACK, shadow.modal)}`,
|
|
816
|
+
`0 2px 8px ${translucent(BLACK, shadow.modalContact)}`,
|
|
817
|
+
...(shadow.modalRing > 0 ? [`0 0 0 1px ${translucent(BLACK, shadow.modalRing)}`] : [])
|
|
818
|
+
].join(', '),
|
|
168
819
|
// Eight categorical hues by plain name, for marks that tell the items of
|
|
169
820
|
// a set apart (a group, a tag, a label). A group mark is never a status.
|
|
170
821
|
// Where any hue falls under 3:1 on a recessed surface (Latte's yellow,
|
|
@@ -181,33 +832,55 @@ function derivedTokens(palette, terminal, appearance, overrides, hues) {
|
|
|
181
832
|
'--group-dot-ring': Object.values(groups).some((hue) => contrast(hue, recessed) < MARK_CONTRAST)
|
|
182
833
|
? `inset 0 0 0 1px ${translucent(palette.text, 28)}`
|
|
183
834
|
: 'none',
|
|
835
|
+
// The chart series colours, in the order a chart assigns them
|
|
836
|
+
// (chartSeries): eight hues of the palette, pairwise distinct, each at
|
|
837
|
+
// 3:1 on a panel and the ground.
|
|
838
|
+
'--chart-1': series[0] ?? palette.blue,
|
|
839
|
+
'--chart-2': series[1] ?? palette.peach,
|
|
840
|
+
'--chart-3': series[2] ?? palette.green,
|
|
841
|
+
'--chart-4': series[3] ?? palette.mauve,
|
|
842
|
+
'--chart-5': series[4] ?? palette.teal,
|
|
843
|
+
'--chart-6': series[5] ?? palette.red,
|
|
844
|
+
'--chart-7': series[6] ?? palette.yellow,
|
|
845
|
+
'--chart-8': series[7] ?? palette.pink,
|
|
184
846
|
// A terminal, which a terminal engine reads as literal colours, so each
|
|
185
847
|
// is hex or rgb(): the theme's own terminal palette over its base, and
|
|
186
848
|
// the accent under the selection, which is drawn over the cell colours.
|
|
187
|
-
// The
|
|
849
|
+
// The 16 are the published colours: the renderer keeps each cell's text
|
|
850
|
+
// at 4.5:1 on that cell's own background, so ANSI black on a dark ground
|
|
851
|
+
// and ANSI white on a light one read as text while a program that paints
|
|
852
|
+
// a background in them gets the colour it asked for. The 256-colour cube
|
|
853
|
+
// and grey ramp derive from the 16.
|
|
188
854
|
'--terminal-bg': palette.base,
|
|
189
855
|
'--terminal-fg': palette.text,
|
|
190
|
-
'--terminal-cursor':
|
|
856
|
+
'--terminal-cursor': terminalCursor,
|
|
191
857
|
'--terminal-selection': translucent(accent, look.terminalSelection),
|
|
858
|
+
// The one ink of selected text, over whatever colour the cell had: the
|
|
859
|
+
// text moved until it keeps 4.5:1 on the selection over the terminal's
|
|
860
|
+
// ground, as a terminal's selection foreground does, so a dim or
|
|
861
|
+
// coloured word stays readable while selected.
|
|
862
|
+
'--terminal-selection-text': legibleOn(palette.text, [mix(accent, palette.base, look.terminalSelection)], TEXT_CONTRAST),
|
|
192
863
|
...Object.fromEntries(terminal.ansi.map((color, index) => [`--terminal-ansi-${index}`, color])),
|
|
193
864
|
// Syntax highlighting: Shiki's Catppuccin theme maps each token colour to
|
|
194
865
|
// its palette role, so a highlighter can follow these by the same names.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
'--syntax-
|
|
198
|
-
'--syntax-
|
|
199
|
-
'--syntax-
|
|
200
|
-
'--syntax-
|
|
201
|
-
'--syntax-
|
|
202
|
-
'--syntax-
|
|
203
|
-
'--syntax-
|
|
204
|
-
'--syntax-
|
|
205
|
-
'--syntax-
|
|
206
|
-
'--syntax-
|
|
207
|
-
'--syntax-
|
|
208
|
-
'--syntax-
|
|
209
|
-
'--syntax-
|
|
210
|
-
'--syntax-
|
|
866
|
+
// Highlighted code is read as text, so each role is moved only as far as
|
|
867
|
+
// it needs to keep 4.5:1 on the ground and a panel, where code is shown.
|
|
868
|
+
'--syntax-rosewater': legibleOn(palette.rosewater, [ground, panel], TEXT_CONTRAST),
|
|
869
|
+
'--syntax-flamingo': legibleOn(palette.flamingo, [ground, panel], TEXT_CONTRAST),
|
|
870
|
+
'--syntax-pink': legibleOn(palette.pink, [ground, panel], TEXT_CONTRAST),
|
|
871
|
+
'--syntax-mauve': legibleOn(palette.mauve, [ground, panel], TEXT_CONTRAST),
|
|
872
|
+
'--syntax-red': legibleOn(palette.red, [ground, panel], TEXT_CONTRAST),
|
|
873
|
+
'--syntax-maroon': legibleOn(palette.maroon, [ground, panel], TEXT_CONTRAST),
|
|
874
|
+
'--syntax-peach': legibleOn(palette.peach, [ground, panel], TEXT_CONTRAST),
|
|
875
|
+
'--syntax-yellow': legibleOn(palette.yellow, [ground, panel], TEXT_CONTRAST),
|
|
876
|
+
'--syntax-green': legibleOn(palette.green, [ground, panel], TEXT_CONTRAST),
|
|
877
|
+
'--syntax-teal': legibleOn(palette.teal, [ground, panel], TEXT_CONTRAST),
|
|
878
|
+
'--syntax-sky': legibleOn(palette.sky, [ground, panel], TEXT_CONTRAST),
|
|
879
|
+
'--syntax-sapphire': legibleOn(palette.sapphire, [ground, panel], TEXT_CONTRAST),
|
|
880
|
+
'--syntax-blue': legibleOn(palette.blue, [ground, panel], TEXT_CONTRAST),
|
|
881
|
+
'--syntax-lavender': legibleOn(palette.lavender, [ground, panel], TEXT_CONTRAST),
|
|
882
|
+
'--syntax-subtext0': legibleOn(palette.subtext0, [ground, panel], TEXT_CONTRAST),
|
|
883
|
+
'--syntax-overlay2': legibleOn(palette.overlay2, [ground, panel], TEXT_CONTRAST),
|
|
211
884
|
// A listing's ground (.listing-root): a white lift over a light panel
|
|
212
885
|
// with no second tint over the ground; nothing in a dark theme.
|
|
213
886
|
'--file-list-bg': look.fileListLift > 0 ? translucent(WHITE, look.fileListLift) : 'transparent'
|
|
@@ -219,9 +892,9 @@ export function themeTokens(theme) {
|
|
|
219
892
|
return { ...tokens, ...theme.overrides };
|
|
220
893
|
}
|
|
221
894
|
/**
|
|
222
|
-
* The colour tokens every theme shares: names for the grounds by role,
|
|
223
|
-
* of a theme's tokens
|
|
224
|
-
*
|
|
895
|
+
* The colour tokens every theme shares: names for the grounds by role, the
|
|
896
|
+
* washes and lines of each hue, and aliases of a theme's tokens by the role
|
|
897
|
+
* they play.
|
|
225
898
|
*/
|
|
226
899
|
export const FIXED_TOKENS = {
|
|
227
900
|
// Surfaces: the three grounds by role. The body paints the ground once, a
|
|
@@ -232,41 +905,82 @@ export const FIXED_TOKENS = {
|
|
|
232
905
|
'--surface': 'var(--bg-panel)',
|
|
233
906
|
'--surface-header': 'var(--bg-header)',
|
|
234
907
|
'--tonal': 'var(--cursor-row-bg)',
|
|
908
|
+
// A recessed surface (a tab behind the selected one): the panel at 45%
|
|
909
|
+
// over the ground under it. Words on it keep 4.5:1 and group marks ring
|
|
910
|
+
// themselves where they fall under 3:1 on it (--group-dot-ring).
|
|
911
|
+
'--surface-recessed': 'color-mix(in srgb, var(--surface) 45%, transparent)',
|
|
912
|
+
// A surface0 fill: a well, a hover fill, a tab's lens. Text on it is
|
|
913
|
+
// --text-on-surface.
|
|
914
|
+
'--fill': 'var(--cursor-bg)',
|
|
915
|
+
// The keyboard cursor row's fill, and the bar on its leading edge that
|
|
916
|
+
// marks it apart from any fill.
|
|
917
|
+
'--cursor-row': 'var(--cursor-row-bg)',
|
|
918
|
+
'--cursor-bar': 'var(--accent)',
|
|
919
|
+
// A selected row in a listing: the solid accent with on-accent text, and
|
|
920
|
+
// the cursor on it a step away from that text (--selection-cursor).
|
|
921
|
+
'--selected-bg': 'var(--accent)',
|
|
922
|
+
'--on-selected': 'var(--on-accent)',
|
|
923
|
+
'--selected-cursor-bg': 'var(--selection-cursor)',
|
|
924
|
+
// A marked row's 2 px bar on its leading edge, beside --marked-bg: the
|
|
925
|
+
// accent as text, which keeps 3:1 on the marked tint where the fill accent
|
|
926
|
+
// would not (Tokyo Night Day).
|
|
927
|
+
'--marked-bar': 'var(--accent-text)',
|
|
928
|
+
// The current item's text and its underline (a strip tab).
|
|
929
|
+
'--current-text': 'var(--text)',
|
|
930
|
+
'--current-mark': 'var(--accent)',
|
|
931
|
+
// A card's fill: the listing's lift over the panel.
|
|
932
|
+
'--card-bg': 'linear-gradient(var(--row-lift), var(--row-lift)) var(--surface)',
|
|
933
|
+
// A text field's placeholder, and a drawn scrollbar's thumb.
|
|
934
|
+
'--text-placeholder': 'var(--text-dim)',
|
|
935
|
+
'--scrollbar-thumb': 'var(--control-border)',
|
|
936
|
+
'--scrollbar-thumb-hover': 'var(--text-dim)',
|
|
937
|
+
// A fuzzy match's underline, which survives any row colour.
|
|
938
|
+
'--match-mark': 'var(--accent)',
|
|
939
|
+
// A listing's column strip and any band like it: the header bar at 40%
|
|
940
|
+
// over the panel.
|
|
941
|
+
'--strip': 'color-mix(in srgb, var(--bg-header) 40%, var(--bg-panel))',
|
|
942
|
+
// Every other row of a striped table: the text's faint tint.
|
|
943
|
+
'--row-zebra': `color-mix(in srgb, var(--text) ${ZEBRA_TINT}%, transparent)`,
|
|
944
|
+
// The darker foot of a lit key cap (a default or destructive key), laid
|
|
945
|
+
// over the cap's own fill so it darkens it in every theme.
|
|
946
|
+
'--key-foot-shade': translucent(BLACK, 30),
|
|
947
|
+
// Washes and lines of each hue (WASH), over whatever is under them. A wash
|
|
948
|
+
// tints a band or a row; the strong wash marks what stands out from a
|
|
949
|
+
// wash; a line draws a hue's rule or ring. The token rules floor the text
|
|
950
|
+
// drawn on each. The accent's two washes are set per theme, each as strong
|
|
951
|
+
// as the text on it allows.
|
|
952
|
+
'--danger-wash': `color-mix(in srgb, var(--danger) ${WASH.status}%, transparent)`,
|
|
953
|
+
'--warning-wash': `color-mix(in srgb, var(--warning) ${WASH.status}%, transparent)`,
|
|
954
|
+
'--success-wash': `color-mix(in srgb, var(--success) ${WASH.status}%, transparent)`,
|
|
955
|
+
'--accent-line': `color-mix(in srgb, var(--accent) ${WASH.line}%, transparent)`,
|
|
956
|
+
'--warning-line': `color-mix(in srgb, var(--warning) ${WASH.line}%, transparent)`,
|
|
957
|
+
'--border-faint': 'color-mix(in srgb, var(--border) 60%, transparent)',
|
|
958
|
+
// The wash under a modal overlay, and the stronger one under an overlay
|
|
959
|
+
// that must hide what is under it (a drop target).
|
|
960
|
+
'--scrim': 'color-mix(in srgb, var(--ground) 50%, transparent)',
|
|
961
|
+
'--scrim-strong': 'color-mix(in srgb, var(--ground) 80%, transparent)',
|
|
235
962
|
// The glass-edge hover every button shares: a frosted ring for outlined
|
|
236
963
|
// controls and a lit top edge for filled ones.
|
|
237
964
|
'--hover-frost': 'inset 0 1px 0 var(--glass-edge), inset 0 0 0 1px var(--border-strong)',
|
|
965
|
+
// The shared press of a quiet control: the pressed inset shadow and the
|
|
966
|
+
// inner hairline every press carries, laid over --pressed-wash. The
|
|
967
|
+
// hairline is 1px, as --hover-frost's ring is (the line scale's --line).
|
|
968
|
+
'--press-frost': 'var(--shadow-pressed), inset 0 0 0 1px var(--border-strong)',
|
|
238
969
|
'--hover-lit': `inset 0 1px 0 ${translucent(WHITE, 40)}, inset 0 -1px 0 ${translucent(BLACK, 12)}`,
|
|
239
|
-
// A
|
|
240
|
-
//
|
|
241
|
-
// and a primary fill lifts on hover.
|
|
242
|
-
'--selection-cursor': 'color-mix(in srgb, var(--accent) 80%, black)',
|
|
243
|
-
'--selection-hit': 'color-mix(in srgb, var(--accent) 70%, black)',
|
|
244
|
-
'--primary-hover': 'color-mix(in srgb, var(--primary) 88%, white)',
|
|
245
|
-
// A disabled control's opacity (DISABLED_OPACITY), the same in every theme.
|
|
970
|
+
// A disabled control's opacity (DISABLED_OPACITY), and a dragged item's
|
|
971
|
+
// (DRAGGING_OPACITY), the same in every theme.
|
|
246
972
|
'--disabled-opacity': `${DISABLED_OPACITY}`,
|
|
247
|
-
|
|
248
|
-
//
|
|
249
|
-
|
|
250
|
-
'--
|
|
251
|
-
'
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
'--
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
// is white on its track.
|
|
259
|
-
'--switch-knob': WHITE,
|
|
260
|
-
// The chart series colours, in the order a chart assigns them, from the
|
|
261
|
-
// syntax palette.
|
|
262
|
-
'--chart-1': 'var(--syntax-blue)',
|
|
263
|
-
'--chart-2': 'var(--syntax-peach)',
|
|
264
|
-
'--chart-3': 'var(--syntax-green)',
|
|
265
|
-
'--chart-4': 'var(--syntax-mauve)',
|
|
266
|
-
'--chart-5': 'var(--syntax-teal)',
|
|
267
|
-
'--chart-6': 'var(--syntax-red)',
|
|
268
|
-
'--chart-7': 'var(--syntax-yellow)',
|
|
269
|
-
'--chart-8': 'var(--syntax-pink)'
|
|
973
|
+
'--dragging-opacity': `${DRAGGING_OPACITY}`,
|
|
974
|
+
// A part set back while another is lit (DIMMED_OPACITY): the unlit slices
|
|
975
|
+
// of a pie while one is pointed at.
|
|
976
|
+
'--dimmed-opacity': `${DIMMED_OPACITY}`,
|
|
977
|
+
// The fill under a chart's area series (CHART_AREA_OPACITY): light enough
|
|
978
|
+
// that overlapping series stay close to their own hue, with the 2px line
|
|
979
|
+
// carrying the colour.
|
|
980
|
+
'--chart-area-opacity': `${CHART_AREA_OPACITY}`,
|
|
981
|
+
// A pressed control's inset shadow; every other shadow is a layer's
|
|
982
|
+
// (--shadow-raised, --shadow-popover, --shadow-modal), set per theme.
|
|
983
|
+
'--shadow-pressed': `inset 0 1px 2px ${translucent(BLACK, 18)}`
|
|
270
984
|
};
|
|
271
985
|
/**
|
|
272
986
|
* The tokens a theme's preview paints with (a theme picker's miniature
|
|
@@ -324,21 +1038,96 @@ function rule(selector, tokens, depth = 0) {
|
|
|
324
1038
|
}
|
|
325
1039
|
/**
|
|
326
1040
|
* The custom properties `@bigpixelrocket/uiok/styles.css` declares or reads beside the theme
|
|
327
|
-
* tokens: the
|
|
328
|
-
* declares or reads (the activity stripes' colour, a dialog's tone
|
|
329
|
-
* pinned top, a date picker fraction field's digit count, a tab
|
|
330
|
-
* edge fades
|
|
331
|
-
* token on `:root`
|
|
1041
|
+
* tokens: the scales of `src/tokens.css` on `:root`, and the hooks a component stylesheet
|
|
1042
|
+
* declares or reads (the activity stripes' colour, a dialog's tone, top
|
|
1043
|
+
* inset, and pinned top, a date picker fraction field's digit count, a tab
|
|
1044
|
+
* strip's edge fades, a field's label column and chevron, a range's fill, a
|
|
1045
|
+
* notice's tone, the scroll fade's edges), which an app token on `:root`
|
|
1046
|
+
* would otherwise reach.
|
|
332
1047
|
*/
|
|
333
1048
|
const BASE_TOKEN_NAMES = [
|
|
334
|
-
|
|
1049
|
+
// The scales of src/tokens.css: size, space, corner, line, timing,
|
|
1050
|
+
// height, layer, focus geometry, and the faces and frost.
|
|
335
1051
|
'--font-mono',
|
|
336
1052
|
'--font-ui',
|
|
1053
|
+
'--font-size-key',
|
|
1054
|
+
'--font-size-caption',
|
|
1055
|
+
'--font-size-small',
|
|
1056
|
+
'--font-size-body',
|
|
1057
|
+
'--font-size-heading',
|
|
1058
|
+
'--font-size-display',
|
|
1059
|
+
'--line-height-compact',
|
|
1060
|
+
'--line-height-body',
|
|
1061
|
+
'--line-height-prose',
|
|
1062
|
+
'--line-height-heading',
|
|
1063
|
+
'--font-weight-regular',
|
|
1064
|
+
'--font-weight-medium',
|
|
1065
|
+
'--font-weight-strong',
|
|
1066
|
+
'--tracking-caps',
|
|
1067
|
+
'--space-1',
|
|
1068
|
+
'--space-2',
|
|
1069
|
+
'--space-3',
|
|
1070
|
+
'--space-4',
|
|
1071
|
+
'--space-5',
|
|
1072
|
+
'--space-6',
|
|
1073
|
+
'--space-8',
|
|
1074
|
+
'--space-10',
|
|
1075
|
+
'--space-12',
|
|
1076
|
+
'--space-16',
|
|
1077
|
+
'--radius-xs',
|
|
1078
|
+
'--radius-sm',
|
|
1079
|
+
'--radius-md',
|
|
1080
|
+
'--radius-lg',
|
|
1081
|
+
'--radius-pill',
|
|
1082
|
+
'--line',
|
|
1083
|
+
'--line-strong',
|
|
1084
|
+
'--duration-fast',
|
|
1085
|
+
'--duration-base',
|
|
1086
|
+
'--duration-slow',
|
|
1087
|
+
'--duration-signal',
|
|
1088
|
+
'--duration-spin',
|
|
1089
|
+
'--ease-out',
|
|
1090
|
+
'--ease-in-out',
|
|
1091
|
+
'--control-height',
|
|
1092
|
+
'--control-height-sm',
|
|
1093
|
+
'--control-height-xs',
|
|
1094
|
+
'--row-height',
|
|
1095
|
+
'--row-height-dense',
|
|
1096
|
+
'--bar-height',
|
|
1097
|
+
'--bar-height-lg',
|
|
1098
|
+
'--hit-target',
|
|
1099
|
+
'--focus-ring-width',
|
|
1100
|
+
'--focus-offset',
|
|
1101
|
+
'--focus-offset-flush',
|
|
1102
|
+
'--focus-offset-inset',
|
|
1103
|
+
'--icon-sm',
|
|
1104
|
+
'--icon-md',
|
|
1105
|
+
'--icon-lg',
|
|
1106
|
+
'--icon-xl',
|
|
1107
|
+
'--dot',
|
|
1108
|
+
'--icon-column',
|
|
1109
|
+
'--z-below',
|
|
1110
|
+
'--z-raised',
|
|
1111
|
+
'--z-local-overlay',
|
|
1112
|
+
'--z-menu',
|
|
1113
|
+
'--z-drag',
|
|
337
1114
|
'--z-panel',
|
|
1115
|
+
'--z-overlay',
|
|
338
1116
|
'--z-dialog',
|
|
1117
|
+
'--z-dialog-popover',
|
|
339
1118
|
'--z-tooltip',
|
|
1119
|
+
'--frost',
|
|
1120
|
+
'--transition-control',
|
|
1121
|
+
// The scroll fade's edge size and its internal per-edge lengths.
|
|
1122
|
+
'--scroll-fade-size',
|
|
1123
|
+
'--scroll-fade-start',
|
|
1124
|
+
'--scroll-fade-end',
|
|
1125
|
+
'--scroll-fade-inline-start',
|
|
1126
|
+
'--scroll-fade-inline-end',
|
|
1127
|
+
// The hooks a component stylesheet declares or reads.
|
|
340
1128
|
'--stripe-ink',
|
|
341
1129
|
'--stripe-ground',
|
|
1130
|
+
'--stripe-band',
|
|
342
1131
|
'--dialog-tone',
|
|
343
1132
|
'--dialog-icon',
|
|
344
1133
|
'--dialog-top',
|
|
@@ -346,11 +1135,45 @@ const BASE_TOKEN_NAMES = [
|
|
|
346
1135
|
'--pane-path-height',
|
|
347
1136
|
'--pane-column-gap',
|
|
348
1137
|
'--pane-row-inset',
|
|
1138
|
+
'--pane-glyph-reach',
|
|
349
1139
|
'--pane-grid',
|
|
350
1140
|
'--date-picker-digits',
|
|
351
1141
|
'--page-tabs-fade-start',
|
|
352
1142
|
'--page-tabs-fade-end',
|
|
353
|
-
'--
|
|
1143
|
+
'--segmented-height',
|
|
1144
|
+
'--dialog-inset-top',
|
|
1145
|
+
'--field-label-width',
|
|
1146
|
+
'--field-chevron-end',
|
|
1147
|
+
'--field-stepper-width',
|
|
1148
|
+
'--field-tone-bar',
|
|
1149
|
+
'--range-fill',
|
|
1150
|
+
'--notice-tone',
|
|
1151
|
+
'--check-edge',
|
|
1152
|
+
'--terminal-bell-wash',
|
|
1153
|
+
'--terminal-bell-line',
|
|
1154
|
+
'--segmented-inset',
|
|
1155
|
+
'--pane-name-floor',
|
|
1156
|
+
'--pane-crumb-count',
|
|
1157
|
+
'--pane-crumb-room',
|
|
1158
|
+
'--pane-crumb-mark-room',
|
|
1159
|
+
'--pane-crumb-here-room',
|
|
1160
|
+
'--pane-crumb-fit',
|
|
1161
|
+
'--pane-pin-ground',
|
|
1162
|
+
'--pane-pin-edge',
|
|
1163
|
+
'--data-grid-editor-cell',
|
|
1164
|
+
'--row-fill',
|
|
1165
|
+
'--check-on',
|
|
1166
|
+
'--check-on-pressed',
|
|
1167
|
+
'--check-mark',
|
|
1168
|
+
'--row-bar',
|
|
1169
|
+
'--row-selected-text',
|
|
1170
|
+
'--row-selected-text-dim',
|
|
1171
|
+
'--pane-edge-shift',
|
|
1172
|
+
'--pane-pin-ring',
|
|
1173
|
+
'--update-note-rows',
|
|
1174
|
+
'--pager-height',
|
|
1175
|
+
'--menu-font-size',
|
|
1176
|
+
'--channel-tag-bg'
|
|
354
1177
|
];
|
|
355
1178
|
/** Every token name uiok defines: the fixed tokens, those a theme sets, and the stylesheet's own. */
|
|
356
1179
|
const UIOK_TOKEN_NAMES = new Set([
|