@adea-ai/ui 0.154.1 → 0.155.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/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.js +23 -1
- package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.d.ts +10 -2
- package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.js +35 -7
- package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-types.d.ts +6 -0
- package/dist/components/composites/appearance-editor/appearance-types.d.ts.map +1 -1
- package/dist/components/composites/tree/index.d.ts +1 -1
- package/dist/components/composites/tree/index.d.ts.map +1 -1
- package/dist/components/composites/tree/index.js +1 -1
- package/dist/components/composites/tree/tree.d.ts +31 -1
- package/dist/components/composites/tree/tree.d.ts.map +1 -1
- package/dist/components/composites/tree/tree.js +76 -1
- package/dist/components/composites/tree/tree.js.map +1 -1
- package/dist/components/theme/theme-document.d.ts +14 -1
- package/dist/components/theme/theme-document.d.ts.map +1 -1
- package/dist/components/theme/theme-document.js +19 -2
- package/dist/components/theme/theme-document.js.map +1 -1
- package/dist/components/theme/theme-persistence.d.ts.map +1 -1
- package/dist/components/theme/theme-persistence.js +1 -0
- package/dist/components/theme/theme-persistence.js.map +1 -1
- package/dist/components/theme/theme-provider-value.d.ts.map +1 -1
- package/dist/components/theme/theme-provider-value.js +2 -1
- package/dist/components/theme/theme-provider-value.js.map +1 -1
- package/dist/components/theme/theme-state.d.ts +20 -0
- package/dist/components/theme/theme-state.d.ts.map +1 -1
- package/dist/components/theme/theme-state.js +9 -1
- package/dist/components/theme/theme-state.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/theme-engine.d.ts +2 -1
- package/dist/lib/theme-engine.d.ts.map +1 -1
- package/dist/lib/theme-engine.js +2 -1
- package/dist/lib/theme-engine.js.map +1 -1
- package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +11 -1
- package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +27 -6
- package/dist/r/src/components/composites/appearance-editor/appearance-types.ts +6 -0
- package/dist/r/src/components/composites/tree/index.ts +3 -0
- package/dist/r/src/components/composites/tree/tree.tsx +82 -0
- package/dist/r/src/components/theme/theme-document.ts +36 -1
- package/dist/r/src/components/theme/theme-persistence.ts +4 -0
- package/dist/r/src/components/theme/theme-provider-value.ts +2 -0
- package/dist/r/src/components/theme/theme-state.ts +26 -0
- package/dist/r/src/lib/theme-engine.ts +3 -2
- package/package.json +1 -1
- package/src/components/composites/appearance-editor/appearance-editor.tsx +11 -1
- package/src/components/composites/appearance-editor/appearance-rows.tsx +27 -6
- package/src/components/composites/appearance-editor/appearance-types.ts +6 -0
- package/src/components/composites/tree/index.ts +3 -0
- package/src/components/composites/tree/tree.tsx +82 -0
- package/src/components/theme/theme-document.ts +36 -1
- package/src/components/theme/theme-persistence.ts +4 -0
- package/src/components/theme/theme-provider-value.ts +2 -0
- package/src/components/theme/theme-state.ts +26 -0
- package/src/lib/theme-engine.ts +3 -2
|
@@ -651,6 +651,85 @@ export function TreeRowActions(props: ComponentProps<'span'> & { pinned?: boolea
|
|
|
651
651
|
)
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
export type TreeStickyHeaderProps = {
|
|
655
|
+
/** The first row in view; its expanded ancestors pin above it. Null pins nothing. */
|
|
656
|
+
topId: string | null
|
|
657
|
+
/** A pinned folder's content: the same icon and name its row shows. */
|
|
658
|
+
label: (id: string) => JSX.Element
|
|
659
|
+
/** A pinned folder was pressed; a file explorer scrolls its row into view. */
|
|
660
|
+
onSelect?: (id: string) => void
|
|
661
|
+
/** The most ancestors pinned at once; the deepest ones win. Defaults to 5. */
|
|
662
|
+
maxRows?: number
|
|
663
|
+
class?: string
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* TreeStickyHeader.
|
|
668
|
+
*
|
|
669
|
+
* Pins the folders above the first row in view to the top of a scrolling tree, so a reader deep
|
|
670
|
+
* in a long folder still sees where they are (Zed's sticky scroll, VS Code's sticky tree). Put it
|
|
671
|
+
* first inside `Tree`, whose root is the scroll container. It takes no layout space: the pinned
|
|
672
|
+
* rows float over the rows beneath, so the host's row window math is unchanged.
|
|
673
|
+
*
|
|
674
|
+
* The pinned rows repeat rows the tree already exposes, so they are hidden from assistive
|
|
675
|
+
* technology and kept out of the tab order; they are a pointer shortcut only. The host decides
|
|
676
|
+
* which row is first in view (it owns the row window), and should pass the row under the pinned
|
|
677
|
+
* stack rather than the one at the very top, see `treeStickyAncestors`.
|
|
678
|
+
*/
|
|
679
|
+
export function TreeStickyHeader(props: TreeStickyHeaderProps) {
|
|
680
|
+
const tree = useTreeContext()
|
|
681
|
+
const ancestors = createMemo(() =>
|
|
682
|
+
treeStickyAncestors(tree.index(), props.topId).slice(-(props.maxRows ?? 5))
|
|
683
|
+
)
|
|
684
|
+
return (
|
|
685
|
+
<div data-slot="tree-sticky-header" class={cn('sticky top-0 z-10 h-0', props.class)}>
|
|
686
|
+
<Show when={ancestors().length > 0}>
|
|
687
|
+
<div aria-hidden="true" class="border-b border-border bg-background">
|
|
688
|
+
<For each={ancestors()}>
|
|
689
|
+
{(item) => (
|
|
690
|
+
<button
|
|
691
|
+
type="button"
|
|
692
|
+
tabIndex={-1}
|
|
693
|
+
data-tree-sticky-id={item.id}
|
|
694
|
+
class="flex min-h-row-sm w-full min-w-0 items-center gap-1.5 pe-1.5 text-left text-sm outline-none hover:bg-surface-hover"
|
|
695
|
+
style={{ 'padding-inline-start': `${rowInset(item.level)}px` }}
|
|
696
|
+
// A press must not focus this aria-hidden shortcut: focus would leave the
|
|
697
|
+
// tree, its recovery state would clear and Arrow keys would stop working.
|
|
698
|
+
onMouseDown={handleMarkerMouseDown}
|
|
699
|
+
onClick={() => props.onSelect?.(item.id)}
|
|
700
|
+
>
|
|
701
|
+
<span class="flex size-3.5 shrink-0 items-center justify-center text-muted-foreground">
|
|
702
|
+
<ChevronRight aria-hidden="true" class="size-3.5 rotate-90" />
|
|
703
|
+
</span>
|
|
704
|
+
{props.label(item.id)}
|
|
705
|
+
</button>
|
|
706
|
+
)}
|
|
707
|
+
</For>
|
|
708
|
+
</div>
|
|
709
|
+
</Show>
|
|
710
|
+
</div>
|
|
711
|
+
)
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* The expanded folders above `id`, outermost first. A host finds the row under the pinned stack
|
|
716
|
+
* by asking again for the row at `scrollTop + ancestors × rowHeight` until the answer settles.
|
|
717
|
+
*/
|
|
718
|
+
export function treeStickyAncestors(
|
|
719
|
+
index: Pick<TreeNavigationIndex, 'byId'>,
|
|
720
|
+
id: string | null
|
|
721
|
+
): TreeItemDescriptor[] {
|
|
722
|
+
const chain: TreeItemDescriptor[] = []
|
|
723
|
+
let parentId = id === null ? null : (index.byId.get(id)?.parentId ?? null)
|
|
724
|
+
while (parentId !== null) {
|
|
725
|
+
const parent = index.byId.get(parentId)
|
|
726
|
+
if (!parent) break
|
|
727
|
+
chain.push(parent)
|
|
728
|
+
parentId = parent.parentId
|
|
729
|
+
}
|
|
730
|
+
return chain.toReversed()
|
|
731
|
+
}
|
|
732
|
+
|
|
654
733
|
// Pressing the chevron must not move focus to its row: a mousedown on a
|
|
655
734
|
// non-focusable child would otherwise focus the row, making it the roving stop
|
|
656
735
|
// (and notifying `onActiveIdChange`) for what is a disclosure toggle, not a
|
|
@@ -673,6 +752,9 @@ const GUIDE_CENTER = 7
|
|
|
673
752
|
|
|
674
753
|
function isActionTarget(target: EventTarget | null, currentTarget: HTMLElement): boolean {
|
|
675
754
|
if (!(target instanceof Element) || target === currentTarget) return false
|
|
755
|
+
// Solid delivers an event from a portalled child (a row's menu) to the component that hosts
|
|
756
|
+
// the portal, so a click on a menu item would otherwise also activate the row behind it.
|
|
757
|
+
if (!currentTarget.contains(target)) return true
|
|
676
758
|
return Boolean(
|
|
677
759
|
target.closest(
|
|
678
760
|
'a, button, input, textarea, select, [contenteditable="true"], [role="button"], [data-tree-keyboard-stop]'
|
|
@@ -33,6 +33,12 @@ export type ThemeDocumentState = {
|
|
|
33
33
|
* Absent, the terminal follows the interface theme.
|
|
34
34
|
*/
|
|
35
35
|
terminalVariant?: ThemeVariant
|
|
36
|
+
/**
|
|
37
|
+
* The variant whose syntax palette, and the canvas it was measured on, is pinned
|
|
38
|
+
* over the interface variant's `--editor-*` ramp. Absent, code follows the
|
|
39
|
+
* interface theme and no `--editor-background` family is written.
|
|
40
|
+
*/
|
|
41
|
+
codeVariant?: ThemeVariant
|
|
36
42
|
/**
|
|
37
43
|
* The resolved surface axis. Absent, the axis is off: no attribute and no
|
|
38
44
|
* `--surface-alpha` is written, and any this writer wrote before is removed.
|
|
@@ -96,9 +102,33 @@ function stylesheetOverrides(
|
|
|
96
102
|
)
|
|
97
103
|
}
|
|
98
104
|
|
|
105
|
+
/**
|
|
106
|
+
* The properties a pinned code theme writes: its `--editor-*` syntax ramp under the
|
|
107
|
+
* host's projection, and the four canvas roles that ramp was measured against. Code
|
|
108
|
+
* surfaces read the canvas as `var(--editor-background, var(--background))`, so the
|
|
109
|
+
* interface canvas is the fallback whenever nothing is pinned.
|
|
110
|
+
*/
|
|
111
|
+
export function codeCssVariables(
|
|
112
|
+
engine: ThemeEngine,
|
|
113
|
+
variant: ThemeVariant,
|
|
114
|
+
editorRoles?: EditorRolesMode
|
|
115
|
+
): Record<string, string> {
|
|
116
|
+
const all = engine.themeCssVariables(variant, { editor: editorRoles })
|
|
117
|
+
const properties: Record<string, string> = {}
|
|
118
|
+
for (const [name, value] of Object.entries(all)) {
|
|
119
|
+
if (name.startsWith('--editor-')) properties[name] = value
|
|
120
|
+
}
|
|
121
|
+
properties['--editor-background'] = all['--background'] ?? variant.colors.background
|
|
122
|
+
properties['--editor-foreground'] = all['--foreground'] ?? variant.colors.foreground
|
|
123
|
+
properties['--editor-muted-foreground'] =
|
|
124
|
+
all['--muted-foreground'] ?? variant.colors.mutedForeground
|
|
125
|
+
properties['--editor-border'] = all['--border'] ?? variant.colors.border
|
|
126
|
+
return properties
|
|
127
|
+
}
|
|
128
|
+
|
|
99
129
|
/**
|
|
100
130
|
* The custom properties a state paints: the variant's roles, an optional projection
|
|
101
|
-
* from the raw host map, the accent, the pinned terminal
|
|
131
|
+
* from the raw host map, the accent, the pinned terminal and code palettes, the surface alpha,
|
|
102
132
|
* then `transformTokens`.
|
|
103
133
|
*
|
|
104
134
|
* The accent is applied *here* rather than left to the `[data-accent]` blocks in
|
|
@@ -140,6 +170,11 @@ export function themeDocumentTokens(
|
|
|
140
170
|
// inline declaration). Dropping the pin needs no removal of its own: the ramp is
|
|
141
171
|
// then rewritten by the variant, or swept back to the stylesheet.
|
|
142
172
|
if (state.terminalVariant) Object.assign(properties, terminalCssVariables(state.terminalVariant))
|
|
173
|
+
// The same rule for code: the pinned ramp wins over the interface variant's, and its
|
|
174
|
+
// canvas comes with it. Unpinning drops the canvas properties from this pass, so the
|
|
175
|
+
// previous-set sweep removes them and code falls back to the interface canvas.
|
|
176
|
+
if (state.codeVariant)
|
|
177
|
+
Object.assign(properties, codeCssVariables(engine, state.codeVariant, options.editorRoles))
|
|
143
178
|
if (state.surface) properties['--surface-alpha'] = surfaceAlpha[state.surface.surface]
|
|
144
179
|
return {
|
|
145
180
|
tokens: options.transformTokens ? options.transformTokens(properties) : properties,
|
|
@@ -77,6 +77,10 @@ function readSelection(storageKey: string): ThemeSelection {
|
|
|
77
77
|
typeof stored.terminalThemeId === 'string' && stored.terminalThemeId.trim() !== ''
|
|
78
78
|
? stored.terminalThemeId
|
|
79
79
|
: undefined,
|
|
80
|
+
codeThemeId:
|
|
81
|
+
typeof stored.codeThemeId === 'string' && stored.codeThemeId.trim() !== ''
|
|
82
|
+
? stored.codeThemeId
|
|
83
|
+
: undefined,
|
|
80
84
|
surface: normalizeSurface(stored.surface),
|
|
81
85
|
reduceTransparency:
|
|
82
86
|
typeof stored.reduceTransparency === 'boolean' ? stored.reduceTransparency : undefined,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
initialThemeSelection,
|
|
29
29
|
mergeRegistry,
|
|
30
30
|
mergeThemeSelection,
|
|
31
|
+
resolveCodeVariant,
|
|
31
32
|
resolveTerminalVariant,
|
|
32
33
|
resolveThemeState,
|
|
33
34
|
zoomedFontSettings,
|
|
@@ -359,6 +360,7 @@ export function createThemeContextValue(
|
|
|
359
360
|
appearance: display.appearance,
|
|
360
361
|
variant: display.variant,
|
|
361
362
|
terminalVariant: resolveTerminalVariant(shownSelection().terminalThemeId, registry()),
|
|
363
|
+
codeVariant: resolveCodeVariant(shownSelection().codeThemeId, registry()),
|
|
362
364
|
surface: axisOn() ? surfaceStateOf(shownSelection()) : undefined,
|
|
363
365
|
}
|
|
364
366
|
const projectionOptions = local.tokenProjection
|
|
@@ -75,6 +75,20 @@ export type ThemeSelection = {
|
|
|
75
75
|
* Optional and not defaulted: see {@link defaultThemeSelection}.
|
|
76
76
|
*/
|
|
77
77
|
terminalThemeId?: string
|
|
78
|
+
/**
|
|
79
|
+
* Code (an editor, a diff, a file view) either follows the interface theme
|
|
80
|
+
* (`theme`, or absent) or is pinned to another theme's syntax palette by that
|
|
81
|
+
* theme's id. The pin writes the theme's `--editor-*` ramp over the interface
|
|
82
|
+
* variant's, with the canvas it was measured on (`--editor-background`,
|
|
83
|
+
* `--editor-foreground`, `--editor-muted-foreground`, `--editor-border`), so a
|
|
84
|
+
* light interface can carry a dark code surface and keep its contrast.
|
|
85
|
+
*
|
|
86
|
+
* An id the registry does not hold paints the interface palette and stays in the
|
|
87
|
+
* selection, the same rule as {@link ThemeSelection.terminalThemeId}.
|
|
88
|
+
*
|
|
89
|
+
* Optional and not defaulted: see {@link defaultThemeSelection}.
|
|
90
|
+
*/
|
|
91
|
+
codeThemeId?: string
|
|
78
92
|
/**
|
|
79
93
|
* How opaque elevated panels are. Written to `<html>` only when the provider's
|
|
80
94
|
* `surface` prop is on or this is set; absent, a host paints no surface axis at
|
|
@@ -311,6 +325,18 @@ export function resolveTerminalVariant(
|
|
|
311
325
|
return registry.find((candidate) => candidate.id === terminalThemeId)
|
|
312
326
|
}
|
|
313
327
|
|
|
328
|
+
/**
|
|
329
|
+
* The variant whose syntax palette is pinned, or `undefined` when code follows the
|
|
330
|
+
* interface theme. The same rule as {@link resolveTerminalVariant}: `theme`, an
|
|
331
|
+
* absent id and an id the registry does not hold all mean the interface palette.
|
|
332
|
+
*/
|
|
333
|
+
export function resolveCodeVariant(
|
|
334
|
+
codeThemeId: string | undefined,
|
|
335
|
+
registry: readonly ThemeVariant[]
|
|
336
|
+
): ThemeVariant | undefined {
|
|
337
|
+
return resolveTerminalVariant(codeThemeId, registry)
|
|
338
|
+
}
|
|
339
|
+
|
|
314
340
|
/**
|
|
315
341
|
* The font settings a zoom chord asks for: one pixel up or down on every axis, or
|
|
316
342
|
* the defaults for `reset`.
|
|
@@ -91,17 +91,18 @@ export function pairNeedsData(pair: ThemePair): boolean {
|
|
|
91
91
|
/**
|
|
92
92
|
* Whether answering for this selection needs the catalogue.
|
|
93
93
|
*
|
|
94
|
-
* True when the variant being shown, the pinned terminal theme, or (for a
|
|
94
|
+
* True when the variant being shown, the pinned terminal or code theme, or (for a
|
|
95
95
|
* theme-derived `ansi-*` accent) either theme of the pair is a catalogue theme other
|
|
96
96
|
* than the two defaults. Everything else, the default pair, a host's own variants,
|
|
97
97
|
* every preset and custom accent, the light engine answers from shipped data.
|
|
98
98
|
*/
|
|
99
99
|
export function needsCatalogue(
|
|
100
|
-
selection: ThemePair & { accent: string; terminalThemeId?: string },
|
|
100
|
+
selection: ThemePair & { accent: string; terminalThemeId?: string; codeThemeId?: string },
|
|
101
101
|
appearance: ThemeAppearance
|
|
102
102
|
): boolean {
|
|
103
103
|
const shown = appearance === 'dark' ? selection.darkThemeId : selection.lightThemeId
|
|
104
104
|
if (needsData(shown)) return true
|
|
105
105
|
if (selection.terminalThemeId !== undefined && needsData(selection.terminalThemeId)) return true
|
|
106
|
+
if (selection.codeThemeId !== undefined && needsData(selection.codeThemeId)) return true
|
|
106
107
|
return isThemeAccentId(selection.accent) && pairNeedsData(selection)
|
|
107
108
|
}
|
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
} from '../../ui/sheet'
|
|
60
60
|
import type { AppearanceEditorProps, AppearancePopoverProps } from './appearance-types'
|
|
61
61
|
import { ModeChoices, AccentChoices, GlassChoices, isCustomAccent } from './appearance-choices'
|
|
62
|
-
import { SettingsRow, TerminalRow, ThemeRow } from './appearance-rows'
|
|
62
|
+
import { CodeRow, SettingsRow, TerminalRow, ThemeRow } from './appearance-rows'
|
|
63
63
|
import { fastIcon } from '#lib/fast-icon'
|
|
64
64
|
|
|
65
65
|
// lucide icons drawn from a cloned template (see fastIcon).
|
|
@@ -138,6 +138,16 @@ export function AppearanceEditor(props: AppearanceEditorProps) {
|
|
|
138
138
|
onSelect={(terminalThemeId) => props.onChange({ terminalThemeId })}
|
|
139
139
|
/>
|
|
140
140
|
</Show>
|
|
141
|
+
{/* The same switch for code: the row exists only when the host stores it. */}
|
|
142
|
+
<Show when={props.draft.codeThemeId !== undefined}>
|
|
143
|
+
<CodeRow
|
|
144
|
+
selectedId={props.draft.codeThemeId ?? THEME_DEFAULT_ID}
|
|
145
|
+
preview={props.resolvedAppearance === 'dark' ? props.darkTheme : props.lightTheme}
|
|
146
|
+
themes={props.themes}
|
|
147
|
+
disabled={props.saving}
|
|
148
|
+
onSelect={(codeThemeId) => props.onChange({ codeThemeId })}
|
|
149
|
+
/>
|
|
150
|
+
</Show>
|
|
141
151
|
<SettingsRow title="Accent" icon={<SlidersHorizontal />} description={accentDescription()}>
|
|
142
152
|
<AccentChoices {...props} />
|
|
143
153
|
</SettingsRow>
|
|
@@ -30,6 +30,7 @@ import type { AdeaTheme, AdeaThemeRecord } from '@adea-ai/themes'
|
|
|
30
30
|
import { For, Show, createMemo, createSignal, onCleanup, type JSX } from 'solid-js'
|
|
31
31
|
import {
|
|
32
32
|
ChevronDown as LucideChevronDown,
|
|
33
|
+
Code as LucideCode,
|
|
33
34
|
Moon as LucideMoon,
|
|
34
35
|
SquareTerminal as LucideSquareTerminal,
|
|
35
36
|
Sun as LucideSun,
|
|
@@ -50,6 +51,7 @@ import { fastIcon } from '#lib/fast-icon'
|
|
|
50
51
|
|
|
51
52
|
// lucide icons drawn from a cloned template (see fastIcon).
|
|
52
53
|
const ChevronDown = fastIcon(LucideChevronDown)
|
|
54
|
+
const Code = fastIcon(LucideCode)
|
|
53
55
|
const Moon = fastIcon(LucideMoon)
|
|
54
56
|
const SquareTerminal = fastIcon(LucideSquareTerminal)
|
|
55
57
|
const Sun = fastIcon(LucideSun)
|
|
@@ -353,14 +355,33 @@ export function ThemeRow(props: {
|
|
|
353
355
|
* preview; every catalogue record follows, both appearances, because the
|
|
354
356
|
* terminal paints one fixed ANSI palette rather than an appearance axis.
|
|
355
357
|
*/
|
|
356
|
-
export function TerminalRow(props: {
|
|
358
|
+
export function TerminalRow(props: PinnedThemeRowProps) {
|
|
359
|
+
return (
|
|
360
|
+
<PinnedThemeRow {...props} title="Terminal" subject="The terminal" icon={<SquareTerminal />} />
|
|
361
|
+
)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* The code palette (editor, diff and file views), chosen the same way as the
|
|
366
|
+
* terminal: `'theme'` follows the interface theme, any catalogue record pins
|
|
367
|
+
* that theme's syntax colours and the canvas they were measured on.
|
|
368
|
+
*/
|
|
369
|
+
export function CodeRow(props: PinnedThemeRowProps) {
|
|
370
|
+
return <PinnedThemeRow {...props} title="Code" subject="Code" icon={<Code />} />
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
type PinnedThemeRowProps = {
|
|
357
374
|
selectedId: string
|
|
358
375
|
/** Resolved interface theme: the `theme` option's palette and the fallback. */
|
|
359
376
|
preview: AdeaTheme
|
|
360
377
|
themes: readonly AdeaThemeRecord[]
|
|
361
378
|
disabled?: boolean
|
|
362
379
|
onSelect: (id: string) => void
|
|
363
|
-
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function PinnedThemeRow(
|
|
383
|
+
props: PinnedThemeRowProps & { title: string; subject: string; icon: JSX.Element }
|
|
384
|
+
) {
|
|
364
385
|
const options = createMemo<ThemeOption[]>(() => [
|
|
365
386
|
{
|
|
366
387
|
id: THEME_DEFAULT_ID,
|
|
@@ -382,13 +403,13 @@ export function TerminalRow(props: {
|
|
|
382
403
|
const description = () => {
|
|
383
404
|
const option = selectedOption()
|
|
384
405
|
return option && option.id !== THEME_DEFAULT_ID
|
|
385
|
-
?
|
|
386
|
-
:
|
|
406
|
+
? `${props.subject} follows ${option.name}.`
|
|
407
|
+
: `${props.subject} follows the interface theme.`
|
|
387
408
|
}
|
|
388
409
|
return (
|
|
389
|
-
<SettingsRow title=
|
|
410
|
+
<SettingsRow title={props.title} icon={props.icon} description={description()}>
|
|
390
411
|
<ThemeSelectMenu
|
|
391
|
-
label=
|
|
412
|
+
label={props.title}
|
|
392
413
|
selectedId={props.selectedId}
|
|
393
414
|
triggerPreview={selectedOption()?.preview ?? props.preview}
|
|
394
415
|
options={options()}
|
|
@@ -13,6 +13,12 @@ export type AppearanceDraft = Readonly<{
|
|
|
13
13
|
* presence, not a second prop that could disagree with the draft.
|
|
14
14
|
*/
|
|
15
15
|
terminalThemeId?: string
|
|
16
|
+
/**
|
|
17
|
+
* The code palette (editor, diff, file views), on the same rule as
|
|
18
|
+
* `terminalThemeId`: `'theme'` follows the interface theme, a theme id pins
|
|
19
|
+
* that theme's syntax colours and canvas. Optional; absent renders no row.
|
|
20
|
+
*/
|
|
21
|
+
codeThemeId?: string
|
|
16
22
|
/** Theme default, a canonical preset id, or the host's custom accent draft. */
|
|
17
23
|
accent: string
|
|
18
24
|
/**
|
|
@@ -651,6 +651,85 @@ export function TreeRowActions(props: ComponentProps<'span'> & { pinned?: boolea
|
|
|
651
651
|
)
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
export type TreeStickyHeaderProps = {
|
|
655
|
+
/** The first row in view; its expanded ancestors pin above it. Null pins nothing. */
|
|
656
|
+
topId: string | null
|
|
657
|
+
/** A pinned folder's content: the same icon and name its row shows. */
|
|
658
|
+
label: (id: string) => JSX.Element
|
|
659
|
+
/** A pinned folder was pressed; a file explorer scrolls its row into view. */
|
|
660
|
+
onSelect?: (id: string) => void
|
|
661
|
+
/** The most ancestors pinned at once; the deepest ones win. Defaults to 5. */
|
|
662
|
+
maxRows?: number
|
|
663
|
+
class?: string
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* TreeStickyHeader.
|
|
668
|
+
*
|
|
669
|
+
* Pins the folders above the first row in view to the top of a scrolling tree, so a reader deep
|
|
670
|
+
* in a long folder still sees where they are (Zed's sticky scroll, VS Code's sticky tree). Put it
|
|
671
|
+
* first inside `Tree`, whose root is the scroll container. It takes no layout space: the pinned
|
|
672
|
+
* rows float over the rows beneath, so the host's row window math is unchanged.
|
|
673
|
+
*
|
|
674
|
+
* The pinned rows repeat rows the tree already exposes, so they are hidden from assistive
|
|
675
|
+
* technology and kept out of the tab order; they are a pointer shortcut only. The host decides
|
|
676
|
+
* which row is first in view (it owns the row window), and should pass the row under the pinned
|
|
677
|
+
* stack rather than the one at the very top, see `treeStickyAncestors`.
|
|
678
|
+
*/
|
|
679
|
+
export function TreeStickyHeader(props: TreeStickyHeaderProps) {
|
|
680
|
+
const tree = useTreeContext()
|
|
681
|
+
const ancestors = createMemo(() =>
|
|
682
|
+
treeStickyAncestors(tree.index(), props.topId).slice(-(props.maxRows ?? 5))
|
|
683
|
+
)
|
|
684
|
+
return (
|
|
685
|
+
<div data-slot="tree-sticky-header" class={cn('sticky top-0 z-10 h-0', props.class)}>
|
|
686
|
+
<Show when={ancestors().length > 0}>
|
|
687
|
+
<div aria-hidden="true" class="border-b border-border bg-background">
|
|
688
|
+
<For each={ancestors()}>
|
|
689
|
+
{(item) => (
|
|
690
|
+
<button
|
|
691
|
+
type="button"
|
|
692
|
+
tabIndex={-1}
|
|
693
|
+
data-tree-sticky-id={item.id}
|
|
694
|
+
class="flex min-h-row-sm w-full min-w-0 items-center gap-1.5 pe-1.5 text-left text-sm outline-none hover:bg-surface-hover"
|
|
695
|
+
style={{ 'padding-inline-start': `${rowInset(item.level)}px` }}
|
|
696
|
+
// A press must not focus this aria-hidden shortcut: focus would leave the
|
|
697
|
+
// tree, its recovery state would clear and Arrow keys would stop working.
|
|
698
|
+
onMouseDown={handleMarkerMouseDown}
|
|
699
|
+
onClick={() => props.onSelect?.(item.id)}
|
|
700
|
+
>
|
|
701
|
+
<span class="flex size-3.5 shrink-0 items-center justify-center text-muted-foreground">
|
|
702
|
+
<ChevronRight aria-hidden="true" class="size-3.5 rotate-90" />
|
|
703
|
+
</span>
|
|
704
|
+
{props.label(item.id)}
|
|
705
|
+
</button>
|
|
706
|
+
)}
|
|
707
|
+
</For>
|
|
708
|
+
</div>
|
|
709
|
+
</Show>
|
|
710
|
+
</div>
|
|
711
|
+
)
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* The expanded folders above `id`, outermost first. A host finds the row under the pinned stack
|
|
716
|
+
* by asking again for the row at `scrollTop + ancestors × rowHeight` until the answer settles.
|
|
717
|
+
*/
|
|
718
|
+
export function treeStickyAncestors(
|
|
719
|
+
index: Pick<TreeNavigationIndex, 'byId'>,
|
|
720
|
+
id: string | null
|
|
721
|
+
): TreeItemDescriptor[] {
|
|
722
|
+
const chain: TreeItemDescriptor[] = []
|
|
723
|
+
let parentId = id === null ? null : (index.byId.get(id)?.parentId ?? null)
|
|
724
|
+
while (parentId !== null) {
|
|
725
|
+
const parent = index.byId.get(parentId)
|
|
726
|
+
if (!parent) break
|
|
727
|
+
chain.push(parent)
|
|
728
|
+
parentId = parent.parentId
|
|
729
|
+
}
|
|
730
|
+
return chain.toReversed()
|
|
731
|
+
}
|
|
732
|
+
|
|
654
733
|
// Pressing the chevron must not move focus to its row: a mousedown on a
|
|
655
734
|
// non-focusable child would otherwise focus the row, making it the roving stop
|
|
656
735
|
// (and notifying `onActiveIdChange`) for what is a disclosure toggle, not a
|
|
@@ -673,6 +752,9 @@ const GUIDE_CENTER = 7
|
|
|
673
752
|
|
|
674
753
|
function isActionTarget(target: EventTarget | null, currentTarget: HTMLElement): boolean {
|
|
675
754
|
if (!(target instanceof Element) || target === currentTarget) return false
|
|
755
|
+
// Solid delivers an event from a portalled child (a row's menu) to the component that hosts
|
|
756
|
+
// the portal, so a click on a menu item would otherwise also activate the row behind it.
|
|
757
|
+
if (!currentTarget.contains(target)) return true
|
|
676
758
|
return Boolean(
|
|
677
759
|
target.closest(
|
|
678
760
|
'a, button, input, textarea, select, [contenteditable="true"], [role="button"], [data-tree-keyboard-stop]'
|
|
@@ -33,6 +33,12 @@ export type ThemeDocumentState = {
|
|
|
33
33
|
* Absent, the terminal follows the interface theme.
|
|
34
34
|
*/
|
|
35
35
|
terminalVariant?: ThemeVariant
|
|
36
|
+
/**
|
|
37
|
+
* The variant whose syntax palette, and the canvas it was measured on, is pinned
|
|
38
|
+
* over the interface variant's `--editor-*` ramp. Absent, code follows the
|
|
39
|
+
* interface theme and no `--editor-background` family is written.
|
|
40
|
+
*/
|
|
41
|
+
codeVariant?: ThemeVariant
|
|
36
42
|
/**
|
|
37
43
|
* The resolved surface axis. Absent, the axis is off: no attribute and no
|
|
38
44
|
* `--surface-alpha` is written, and any this writer wrote before is removed.
|
|
@@ -96,9 +102,33 @@ function stylesheetOverrides(
|
|
|
96
102
|
)
|
|
97
103
|
}
|
|
98
104
|
|
|
105
|
+
/**
|
|
106
|
+
* The properties a pinned code theme writes: its `--editor-*` syntax ramp under the
|
|
107
|
+
* host's projection, and the four canvas roles that ramp was measured against. Code
|
|
108
|
+
* surfaces read the canvas as `var(--editor-background, var(--background))`, so the
|
|
109
|
+
* interface canvas is the fallback whenever nothing is pinned.
|
|
110
|
+
*/
|
|
111
|
+
export function codeCssVariables(
|
|
112
|
+
engine: ThemeEngine,
|
|
113
|
+
variant: ThemeVariant,
|
|
114
|
+
editorRoles?: EditorRolesMode
|
|
115
|
+
): Record<string, string> {
|
|
116
|
+
const all = engine.themeCssVariables(variant, { editor: editorRoles })
|
|
117
|
+
const properties: Record<string, string> = {}
|
|
118
|
+
for (const [name, value] of Object.entries(all)) {
|
|
119
|
+
if (name.startsWith('--editor-')) properties[name] = value
|
|
120
|
+
}
|
|
121
|
+
properties['--editor-background'] = all['--background'] ?? variant.colors.background
|
|
122
|
+
properties['--editor-foreground'] = all['--foreground'] ?? variant.colors.foreground
|
|
123
|
+
properties['--editor-muted-foreground'] =
|
|
124
|
+
all['--muted-foreground'] ?? variant.colors.mutedForeground
|
|
125
|
+
properties['--editor-border'] = all['--border'] ?? variant.colors.border
|
|
126
|
+
return properties
|
|
127
|
+
}
|
|
128
|
+
|
|
99
129
|
/**
|
|
100
130
|
* The custom properties a state paints: the variant's roles, an optional projection
|
|
101
|
-
* from the raw host map, the accent, the pinned terminal
|
|
131
|
+
* from the raw host map, the accent, the pinned terminal and code palettes, the surface alpha,
|
|
102
132
|
* then `transformTokens`.
|
|
103
133
|
*
|
|
104
134
|
* The accent is applied *here* rather than left to the `[data-accent]` blocks in
|
|
@@ -140,6 +170,11 @@ export function themeDocumentTokens(
|
|
|
140
170
|
// inline declaration). Dropping the pin needs no removal of its own: the ramp is
|
|
141
171
|
// then rewritten by the variant, or swept back to the stylesheet.
|
|
142
172
|
if (state.terminalVariant) Object.assign(properties, terminalCssVariables(state.terminalVariant))
|
|
173
|
+
// The same rule for code: the pinned ramp wins over the interface variant's, and its
|
|
174
|
+
// canvas comes with it. Unpinning drops the canvas properties from this pass, so the
|
|
175
|
+
// previous-set sweep removes them and code falls back to the interface canvas.
|
|
176
|
+
if (state.codeVariant)
|
|
177
|
+
Object.assign(properties, codeCssVariables(engine, state.codeVariant, options.editorRoles))
|
|
143
178
|
if (state.surface) properties['--surface-alpha'] = surfaceAlpha[state.surface.surface]
|
|
144
179
|
return {
|
|
145
180
|
tokens: options.transformTokens ? options.transformTokens(properties) : properties,
|
|
@@ -77,6 +77,10 @@ function readSelection(storageKey: string): ThemeSelection {
|
|
|
77
77
|
typeof stored.terminalThemeId === 'string' && stored.terminalThemeId.trim() !== ''
|
|
78
78
|
? stored.terminalThemeId
|
|
79
79
|
: undefined,
|
|
80
|
+
codeThemeId:
|
|
81
|
+
typeof stored.codeThemeId === 'string' && stored.codeThemeId.trim() !== ''
|
|
82
|
+
? stored.codeThemeId
|
|
83
|
+
: undefined,
|
|
80
84
|
surface: normalizeSurface(stored.surface),
|
|
81
85
|
reduceTransparency:
|
|
82
86
|
typeof stored.reduceTransparency === 'boolean' ? stored.reduceTransparency : undefined,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
initialThemeSelection,
|
|
29
29
|
mergeRegistry,
|
|
30
30
|
mergeThemeSelection,
|
|
31
|
+
resolveCodeVariant,
|
|
31
32
|
resolveTerminalVariant,
|
|
32
33
|
resolveThemeState,
|
|
33
34
|
zoomedFontSettings,
|
|
@@ -359,6 +360,7 @@ export function createThemeContextValue(
|
|
|
359
360
|
appearance: display.appearance,
|
|
360
361
|
variant: display.variant,
|
|
361
362
|
terminalVariant: resolveTerminalVariant(shownSelection().terminalThemeId, registry()),
|
|
363
|
+
codeVariant: resolveCodeVariant(shownSelection().codeThemeId, registry()),
|
|
362
364
|
surface: axisOn() ? surfaceStateOf(shownSelection()) : undefined,
|
|
363
365
|
}
|
|
364
366
|
const projectionOptions = local.tokenProjection
|
|
@@ -75,6 +75,20 @@ export type ThemeSelection = {
|
|
|
75
75
|
* Optional and not defaulted: see {@link defaultThemeSelection}.
|
|
76
76
|
*/
|
|
77
77
|
terminalThemeId?: string
|
|
78
|
+
/**
|
|
79
|
+
* Code (an editor, a diff, a file view) either follows the interface theme
|
|
80
|
+
* (`theme`, or absent) or is pinned to another theme's syntax palette by that
|
|
81
|
+
* theme's id. The pin writes the theme's `--editor-*` ramp over the interface
|
|
82
|
+
* variant's, with the canvas it was measured on (`--editor-background`,
|
|
83
|
+
* `--editor-foreground`, `--editor-muted-foreground`, `--editor-border`), so a
|
|
84
|
+
* light interface can carry a dark code surface and keep its contrast.
|
|
85
|
+
*
|
|
86
|
+
* An id the registry does not hold paints the interface palette and stays in the
|
|
87
|
+
* selection, the same rule as {@link ThemeSelection.terminalThemeId}.
|
|
88
|
+
*
|
|
89
|
+
* Optional and not defaulted: see {@link defaultThemeSelection}.
|
|
90
|
+
*/
|
|
91
|
+
codeThemeId?: string
|
|
78
92
|
/**
|
|
79
93
|
* How opaque elevated panels are. Written to `<html>` only when the provider's
|
|
80
94
|
* `surface` prop is on or this is set; absent, a host paints no surface axis at
|
|
@@ -311,6 +325,18 @@ export function resolveTerminalVariant(
|
|
|
311
325
|
return registry.find((candidate) => candidate.id === terminalThemeId)
|
|
312
326
|
}
|
|
313
327
|
|
|
328
|
+
/**
|
|
329
|
+
* The variant whose syntax palette is pinned, or `undefined` when code follows the
|
|
330
|
+
* interface theme. The same rule as {@link resolveTerminalVariant}: `theme`, an
|
|
331
|
+
* absent id and an id the registry does not hold all mean the interface palette.
|
|
332
|
+
*/
|
|
333
|
+
export function resolveCodeVariant(
|
|
334
|
+
codeThemeId: string | undefined,
|
|
335
|
+
registry: readonly ThemeVariant[]
|
|
336
|
+
): ThemeVariant | undefined {
|
|
337
|
+
return resolveTerminalVariant(codeThemeId, registry)
|
|
338
|
+
}
|
|
339
|
+
|
|
314
340
|
/**
|
|
315
341
|
* The font settings a zoom chord asks for: one pixel up or down on every axis, or
|
|
316
342
|
* the defaults for `reset`.
|
package/src/lib/theme-engine.ts
CHANGED
|
@@ -91,17 +91,18 @@ export function pairNeedsData(pair: ThemePair): boolean {
|
|
|
91
91
|
/**
|
|
92
92
|
* Whether answering for this selection needs the catalogue.
|
|
93
93
|
*
|
|
94
|
-
* True when the variant being shown, the pinned terminal theme, or (for a
|
|
94
|
+
* True when the variant being shown, the pinned terminal or code theme, or (for a
|
|
95
95
|
* theme-derived `ansi-*` accent) either theme of the pair is a catalogue theme other
|
|
96
96
|
* than the two defaults. Everything else, the default pair, a host's own variants,
|
|
97
97
|
* every preset and custom accent, the light engine answers from shipped data.
|
|
98
98
|
*/
|
|
99
99
|
export function needsCatalogue(
|
|
100
|
-
selection: ThemePair & { accent: string; terminalThemeId?: string },
|
|
100
|
+
selection: ThemePair & { accent: string; terminalThemeId?: string; codeThemeId?: string },
|
|
101
101
|
appearance: ThemeAppearance
|
|
102
102
|
): boolean {
|
|
103
103
|
const shown = appearance === 'dark' ? selection.darkThemeId : selection.lightThemeId
|
|
104
104
|
if (needsData(shown)) return true
|
|
105
105
|
if (selection.terminalThemeId !== undefined && needsData(selection.terminalThemeId)) return true
|
|
106
|
+
if (selection.codeThemeId !== undefined && needsData(selection.codeThemeId)) return true
|
|
106
107
|
return isThemeAccentId(selection.accent) && pairNeedsData(selection)
|
|
107
108
|
}
|