Update editor, themes, menus, backgrounds, and release tooling

This commit is contained in:
Knotty Wyvern
2026-10-14 16:19:51 -07:00
parent f6eaa52949
commit edef2520af
113 changed files with 5722 additions and 386 deletions
+29 -10
View File
@@ -6,7 +6,7 @@
import Icon from '$lib/ui/Icon.svelte';
import { showActionMenu } from '$lib/ui/managedActionMenu';
import { saveBackgroundImage, removeBackgroundImage } from './backgroundImages';
import { APPEARANCE_KEY, DEFAULT_APPEARANCE, BACKGROUND_POSITIONS, BACKGROUND_SIZES, parseAppearance, normalizeAppearance, saveAppearance, exportAppearanceTheme, type Appearance, type ThemeName } from './appearance';
import { APPEARANCE_KEY, DEFAULT_APPEARANCE, BUILTIN_THEMES, themeModes, BACKGROUND_POSITIONS, BACKGROUND_SIZES, parseAppearance, normalizeAppearance, saveAppearance, exportAppearanceTheme, type Appearance, type ThemeName } from './appearance';
let appearance = $state<Appearance>({ ...DEFAULT_APPEARANCE });
let error = $state('');
let status = $state('');
@@ -16,16 +16,18 @@
let installed = $state<CustomTheme[]>([]);
let themeInput: HTMLInputElement;
let closePicker = () => {};
const themes = $derived([{ id: 'default', name: 'RuneStone' }, { id: 'claude', name: 'Claude' }, { id: 'sakura', name: 'Sakura' }, ...installed.map(theme => ({ id: `custom:${theme.id}`, name: theme.name }))]);
const themes = $derived([...BUILTIN_THEMES, ...installed.map(theme => ({ id: `custom:${theme.id}` as ThemeName, name: theme.name }))].flatMap(theme =>
themeModes(theme.id).map(mode => ({
theme: theme.id, mode, name: themeModes(theme.id).length === 1 ? theme.name : `${theme.name} ${mode === 'light' ? 'Light' : 'Dark'}`,
}))));
onDestroy(() => closePicker());
function picker(event: MouseEvent, mode = false) {
function picker(event: MouseEvent) {
closePicker();
const anchor = event.currentTarget as HTMLButtonElement;
const bounds = anchor.getBoundingClientRect();
const choices = mode ? [{ id: 'light', name: 'Light' }, { id: 'dark', name: 'Dark' }] : themes;
closePicker = showActionMenu({ x: bounds.left, y: bounds.bottom + 4, label: mode ? 'Appearance' : 'Color theme', parent: anchor.closest('dialog') ?? undefined,
items: choices.map(choice => ({ label: choice.name, radio: true, checked: choice.id === (mode ? appearance.mode : appearance.theme),
run: () => change(mode ? { ...appearance, mode: choice.id as 'light' | 'dark' } : { ...appearance, theme: choice.id as ThemeName }) })) }).close;
closePicker = showActionMenu({ x: bounds.left, y: bounds.bottom + 4, label: 'Color theme', parent: anchor.closest('dialog') ?? undefined,
items: themes.map(choice => ({ label: choice.name, radio: true, checked: choice.theme === appearance.theme && choice.mode === appearance.mode,
run: () => change({ ...appearance, theme: choice.theme, mode: choice.mode }) })) }).close;
}
const positionLabels = ['Center', 'Top left', 'Top center', 'Top right', 'Center left', 'Center right', 'Bottom left', 'Bottom center', 'Bottom right'];
const sizeLabels = ['Fill', 'Fit', 'Actual size'];
@@ -105,10 +107,13 @@
}
</script>
<h2>Appearance</h2>
<p>Choose a color theme and a light or dark appearance.</p>
<p>Choose a color theme variant.</p>
<div class="card">
<div class="setting-row"><span>Color theme</span><button class="picker" aria-label="Color theme" aria-haspopup="menu" onclick={event => picker(event)}>{themes.find(theme => theme.id === appearance.theme)?.name ?? 'RuneStone'}<Icon icon="chevron-down" /></button></div>
<div class="setting-row"><span>Appearance</span><button class="picker" aria-label="Appearance" aria-haspopup="menu" disabled={appearance.theme === 'sakura'} onclick={event => picker(event, true)}>{appearance.mode === 'light' ? 'Light' : 'Dark'}<Icon icon="chevron-down" /></button></div>
<div class="setting-row"><span>Color theme</span><button class="picker" aria-label="Color theme" aria-haspopup="menu" onclick={event => picker(event)}>{themes.find(theme => theme.theme === appearance.theme && theme.mode === appearance.mode)?.name ?? 'RuneStone Dark'}<Icon icon="chevron-down" /></button></div>
</div>
<div class="theme-preview" role="img" aria-label="Color theme preview">
<div class="preview-sidebar" aria-hidden="true"><span></span><span></span><span></span></div>
<div class="preview-document" aria-hidden="true"><strong>RuneStone</strong><span class="preview-prose">A place for your ideas.</span><span class="preview-selection">Selected text</span><span class="preview-link">Link</span><code class="preview-code"><span class="preview-keyword">const</span> name = <span class="preview-string">"RuneStone"</span>;<br /><span class="preview-function">show</span>(name, <span class="preview-number">42</span>);</code></div>
</div>
<div class="theme-actions">
<input bind:this={themeInput} type="file" accept=".json,application/json" aria-label="Theme JSON file" hidden onchange={event => { void importTheme(event.currentTarget.files?.[0]); }} />
@@ -149,6 +154,20 @@
.picker{display:flex;align-items:center;gap:8px;min-height:var(--rs-settings-control-height);max-width:100%;padding:4px 8px;background:var(--rs-bg);color:var(--rs-text);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius)}
.picker :global(svg){width:14px;height:14px;flex-shrink:0}
.picker:focus-visible{outline:2px solid var(--rs-accent);outline-offset:2px}
.theme-preview{display:flex;gap:var(--rs-settings-gap);margin-top:var(--rs-settings-gap);padding:var(--rs-settings-row-padding);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg);min-height:100px}
.preview-sidebar{display:flex;flex-direction:column;gap:var(--rs-settings-gap);width:22%;padding:var(--rs-settings-row-padding);background:var(--rs-bg-elevated);border-radius:var(--rs-control-radius)}
.preview-sidebar span{height:6px;background:var(--rs-text-dim);opacity:.5;border-radius:var(--rs-control-radius)}
.preview-sidebar span:first-child{height:20px;background:var(--rs-bg-active);opacity:1}
.preview-document{display:flex;align-items:flex-start;flex-direction:column;gap:var(--rs-settings-gap);flex:1;min-width:0;padding:4px}
.preview-document strong{color:var(--rs-text-strong);font-family:var(--rs-font-heading)}
.preview-prose{font-family:var(--rs-font-prose);color:var(--rs-text)}
.preview-selection{background:var(--rs-selection);color:var(--rs-text);padding:2px 4px;border-radius:var(--rs-item-selection-radius)}
.preview-link{color:var(--rs-accent);font-size:var(--rs-settings-description-size)}
.preview-code{font-family:var(--rs-font-mono);font-size:var(--rs-settings-description-size);line-height:1.6;overflow-wrap:anywhere;white-space:normal}
.preview-keyword{color:var(--rs-syntax-keyword)}
.preview-string{color:var(--rs-syntax-string,var(--rs-ok))}
.preview-function{color:var(--rs-syntax-function,var(--rs-accent-2))}
.preview-number{color:var(--rs-syntax-number,var(--rs-special))}
.overlay-controls{display:flex;align-items:center;flex-wrap:wrap;gap:var(--rs-settings-gap);max-width:100%}
.overlay-controls input[type=range]{width:160px;max-width:100%;min-width:0}
.overlay-value{padding:0;gap:4px;flex-wrap:nowrap}
+41 -10
View File
@@ -1,15 +1,27 @@
import { customThemes, type CustomTheme } from './customThemes.ts';
import { readBackgroundImage } from './backgroundImages.ts';
import { characterTheme, characterSyntax, SYNTAX_ROLES } from './characterThemes.ts';
export const APPEARANCE_KEY = 'runestone.appearance';
export const THEMES = ['default', 'claude', 'sakura'] as const;
export const THEMES = ['default', 'claude', 'sakura', 'harvest-moon', 'crimson-pilot', 'silver-serpent'] as const;
export const BUILTIN_THEMES = [
{ id: 'default', name: 'RuneStone' }, { id: 'claude', name: 'Claude' }, { id: 'sakura', name: 'Sakura' },
{ id: 'harvest-moon', name: 'Harvest Moon' }, { id: 'crimson-pilot', name: 'Crimson Pilot' }, { id: 'silver-serpent', name: 'Silver Serpent' },
] as const;
// Preserve selections saved before the public palette IDs changed.
const LEGACY_THEME_IDS: Record<string, typeof THEMES[number]> = { holo: 'harvest-moon', asuka: 'crimson-pilot', malfoid: 'silver-serpent' };
export function themeModes(theme: string): readonly ('light' | 'dark')[] {
const character = characterTheme(theme);
return character ? [character.mode] : theme === 'sakura' ? ['light'] : ['light', 'dark'];
}
export type ThemeName = typeof THEMES[number] | `custom:${string}`;
export const BACKGROUND_POSITIONS = ['center', 'top left', 'top', 'top right', 'left', 'right', 'bottom left', 'bottom', 'bottom right'] as const;
export const BACKGROUND_SIZES = ['cover', 'contain', 'auto'] as const;
export type Appearance = { theme: ThemeName; mode: 'light' | 'dark'; newTabBackground?: { image?: string; imageId?: string; overlay?: number; position?: typeof BACKGROUND_POSITIONS[number]; size?: typeof BACKGROUND_SIZES[number] } };
export const DEFAULT_APPEARANCE: Appearance = { theme: 'default', mode: 'dark' };
export function normalizeAppearance(value: { theme?: unknown; mode?: unknown; newTabBackground?: unknown } | null): Appearance {
const theme: ThemeName = typeof value?.theme === 'string' && (/^custom:[a-z][a-z0-9-]{0,63}$/.test(value.theme) || (THEMES as readonly string[]).includes(value.theme)) ? value.theme as ThemeName : 'default';
const result: Appearance = { theme, mode: theme === 'sakura' || value?.mode === 'light' ? 'light' : 'dark' };
const savedTheme = typeof value?.theme === 'string' && Object.hasOwn(LEGACY_THEME_IDS, value.theme) ? LEGACY_THEME_IDS[value.theme] : value?.theme;
const theme: ThemeName = typeof savedTheme === 'string' && (/^custom:[a-z][a-z0-9-]{0,63}$/.test(savedTheme) || (THEMES as readonly string[]).includes(savedTheme)) ? savedTheme as ThemeName : 'default';
const result: Appearance = { theme, mode: characterTheme(theme)?.mode ?? (theme === 'sakura' || value?.mode === 'light' ? 'light' : 'dark') };
const background = value?.newTabBackground;
if (background && typeof background === 'object') {
const source = background as { image?: unknown; imageId?: unknown; overlay?: unknown; position?: unknown; size?: unknown };
@@ -41,24 +53,38 @@ const palettes = {
sakura: {
light: ['#fefcfc','#fefcfc','#dbeacb','#f8dbe6','#687788','#513346','#321c2a','#98556c','#ffc9dc'],
},
};
function builtinPalette(theme: ThemeName) {
if (theme === 'sakura') return { light: palettes.sakura.light, dark: palettes.sakura.light };
const character = characterTheme(theme);
if (character) return { light: character.surfaces, dark: character.surfaces };
return palettes[theme === 'claude' ? 'claude' : 'default'];
}
export function exportAppearanceTheme(theme: ThemeName): CustomTheme {
const custom = customThemes().find(item => `custom:${item.id}` === theme);
if (custom) return custom;
const palette = theme === 'sakura' ? { light: palettes.sakura.light, dark: palettes.sakura.light }
: palettes[theme === 'claude' ? 'claude' : 'default'];
const palette = builtinPalette(theme);
const syntax = characterSyntax(theme);
const extra = characterTheme(theme) ? { ...syntax, 'accent-2': characterTheme(theme)!.secondary } : {};
return { schema: 1, id: 'my-theme', name: 'My theme',
light: Object.fromEntries(keys.map((key, index) => [key, palette.light[index]])),
dark: Object.fromEntries(keys.map((key, index) => [key, palette.dark[index]])) };
light: { ...Object.fromEntries(keys.map((key, index) => [key, palette.light[index]])), ...extra },
dark: { ...Object.fromEntries(keys.map((key, index) => [key, palette.dark[index]])), ...extra } };
}
const backgroundUrls = new WeakMap<HTMLElement, { image: string; url: string }>();
const backgroundRequests = new WeakMap<HTMLElement, string | undefined>();
function applyBackgroundSurfaces(root: HTMLElement, hasImage: boolean) {
root.style.setProperty('--rs-workarea-sidebar-bg', hasImage ? 'var(--rs-image-sidebar-bg)' : 'var(--rs-bg-elevated)');
root.style.setProperty('--rs-workarea-editor-bg', hasImage ? 'var(--rs-image-editor-bg)' : 'var(--rs-bg)');
root.style.setProperty('--rs-workarea-surface-opacity', hasImage ? '82%' : '100%');
root.style.setProperty('--rs-workarea-plugin-bg', hasImage ? 'transparent' : 'var(--rs-bg)');
}
async function applySavedBackground(root: HTMLElement, background?: Appearance['newTabBackground']) {
const id = background?.imageId;
backgroundRequests.set(root, id);
if (!id) { applyBackgroundImage(root, background?.image); return; }
const previous = backgroundUrls.get(root);
if (previous?.image === id) { root.style.setProperty('--rs-new-tab-image', `url("${previous.url}")`); return; }
if (previous?.image === id) { root.style.setProperty('--rs-new-tab-image', `url("${previous.url}")`); applyBackgroundSurfaces(root, true); return; }
applyBackgroundImage(root);
try {
const file = await readBackgroundImage(id);
@@ -67,6 +93,7 @@ async function applySavedBackground(root: HTMLElement, background?: Appearance['
const old = backgroundUrls.get(root);
backgroundUrls.set(root, { image: id, url });
root.style.setProperty('--rs-new-tab-image', `url("${url}")`);
applyBackgroundSurfaces(root, true);
if (old) URL.revokeObjectURL(old.url);
} catch { /* Keep the theme usable if image storage is unavailable. */ }
}
@@ -74,6 +101,7 @@ function applyBackgroundImage(root: HTMLElement, image?: string) {
const previous = backgroundUrls.get(root);
if (image && previous?.image === image) {
root.style.setProperty('--rs-new-tab-image', `url("${previous.url}")`);
applyBackgroundSurfaces(root, true);
return;
}
let url: string | undefined;
@@ -86,6 +114,7 @@ function applyBackgroundImage(root: HTMLElement, image?: string) {
}
// Large data URLs exceed Chromium's CSS variable limit. Keep only a short blob URL in CSS.
root.style.setProperty('--rs-new-tab-image', url ? `url("${url}")` : 'none');
applyBackgroundSurfaces(root, !!url);
if (image && url) backgroundUrls.set(root, { image, url });
else backgroundUrls.delete(root);
if (previous) URL.revokeObjectURL(previous.url);
@@ -103,9 +132,9 @@ export function applyAppearance(value: Appearance, root = document.documentEleme
root.dataset.theme = mode;
root.dataset.palette = theme;
root.style.colorScheme = mode;
const palette = theme === 'sakura' ? palettes.sakura.light : palettes[theme === 'claude' ? 'claude' : 'default'][mode];
const palette = builtinPalette(theme)[mode];
keys.forEach((key, index) => root.style.setProperty(`--rs-${key}`, palette[index]));
root.style.setProperty('--rs-accent-2', theme === 'claude' ? '#6a9bcc' : theme === 'sakura' ? '#607fa9' : 'var(--rs-accent)');
root.style.setProperty('--rs-accent-2', characterTheme(theme)?.secondary ?? (theme === 'claude' ? '#6a9bcc' : theme === 'sakura' ? '#607fa9' : 'var(--rs-accent)'));
root.style.setProperty('--rs-accent-dim', 'color-mix(in srgb, var(--rs-accent) 80%, var(--rs-bg))');
root.style.setProperty('--rs-accent-deep', 'color-mix(in srgb, var(--rs-accent) 60%, var(--rs-bg))');
const semantic = mode === 'light' ? ['#b42323', '#8a5700', '#806600', '#287b29', '#7740a5']
@@ -113,10 +142,12 @@ export function applyAppearance(value: Appearance, root = document.documentEleme
if (theme === 'claude') { semantic[3] = '#788c5d'; semantic[4] = '#6a9bcc'; }
if (theme === 'sakura') { semantic[3] = '#618c71'; semantic[4] = '#cb6b91'; }
['error', 'warn-hot', 'warn', 'ok', 'special'].forEach((key, index) => root.style.setProperty(`--rs-${key}`, semantic[index]));
SYNTAX_ROLES.forEach(role => root.style.removeProperty(`--rs-syntax-${role}`));
const syntax = theme === 'sakura'
? ['#cb6b91', '#98556c', '#618c71', '#69a2bd', '#607fa9', '#687788']
: ['var(--rs-special)', 'var(--rs-accent)', 'var(--rs-text)', 'var(--rs-accent-2)', 'var(--rs-accent-2)', 'var(--rs-text-dim)'];
['parameter', 'keyword', 'local', 'static', 'instance', 'global'].forEach((key, index) => root.style.setProperty(`--rs-syntax-${key}`, syntax[index]));
for (const [key, color] of Object.entries(characterSyntax(theme))) root.style.setProperty(`--rs-${key}`, color);
root.style.setProperty('--rs-danger', 'var(--rs-error)');
const custom = theme.startsWith('custom:') ? customThemes().find(item => item.id === theme.slice(7)) : undefined;
if (custom) for (const [key, color] of Object.entries(custom[mode])) root.style.setProperty(`--rs-${key}`, color);
+36
View File
@@ -0,0 +1,36 @@
import type { ThemeColors } from './customThemes.ts';
export const SYNTAX_ROLES = ['parameter', 'keyword', 'local', 'static', 'instance', 'global', 'string', 'number', 'comment', 'type', 'function'] as const;
type CharacterTheme = { mode: 'light' | 'dark'; surfaces: string[]; syntax: string[]; secondary: string };
export const CHARACTER_THEMES = {
'harvest-moon': {
mode: 'dark',
// Current Holo fan art: copper hair, brown tail, cream fur, and red eyes/apple.
// Amber carries active and selected states. Green scenery is outside this palette.
surfaces: ['#251b17', '#382820', '#40291c', '#ae744a', '#d3aa8b', '#eee3d1', '#fff4df', '#ffb52e', '#482714'],
secondary: '#ff6740',
syntax: ['#ffcc66', '#ff6740', '#eee3d1', '#ffe7b3', '#e5ae7e', '#ff8d55', '#ffc45b', '#ffffff', '#d3aa8b', '#ffe19a', '#ffb52e'],
},
'crimson-pilot': {
mode: 'dark',
surfaces: ['#210b10', '#341018', '#461620', '#d93840', '#e0b48e', '#f4ece1', '#ffffff', '#ff5b50', '#122b45'],
secondary: '#ff9b18',
syntax: ['#ffad32', '#ff5b50', '#f4ece1', '#b6dfff', '#efb278', '#83dc52', '#ffe066', '#ff8a3d', '#e0b48e', '#64c9ff', '#559fff'],
},
'silver-serpent': {
mode: 'dark',
surfaces: ['#151c1b', '#1d3029', '#223a32', '#528f74', '#bec8ce', '#e3e7eb', '#fff5d5', '#36e395', '#13533a'],
secondary: '#c5d5e2',
syntax: ['#f5d58c', '#36e395', '#e3e7eb', '#b8cbdd', '#f4c6ae', '#edc45f', '#a7e7c4', '#ffb79b', '#bec8ce', '#ffffff', '#61dfbb'],
},
} satisfies Record<string, CharacterTheme>;
export function characterTheme(theme: string): CharacterTheme | undefined {
return CHARACTER_THEMES[theme as keyof typeof CHARACTER_THEMES];
}
export function characterSyntax(theme: string): ThemeColors {
const palette = characterTheme(theme);
return palette ? Object.fromEntries(SYNTAX_ROLES.map((role, index) => [`syntax-${role}`, palette.syntax[index]])) : {};
}
+1 -1
View File
@@ -1,5 +1,5 @@
export const CUSTOM_THEMES_KEY = "runestone.custom-themes";
export const COLOR_TOKENS = ["bg", "bg-elevated", "bg-active", "border", "text", "text-dim", "text-strong", "accent", "accent-2", "selection", "error", "warn", "warn-hot", "ok", "special"] as const;
export const COLOR_TOKENS = ["bg", "bg-elevated", "bg-active", "border", "text", "text-dim", "text-strong", "accent", "accent-2", "selection", "error", "warn", "warn-hot", "ok", "special", "syntax-parameter", "syntax-keyword", "syntax-local", "syntax-static", "syntax-instance", "syntax-global", "syntax-string", "syntax-number", "syntax-comment", "syntax-type", "syntax-function"] as const;
export type ThemeColors = Partial<Record<typeof COLOR_TOKENS[number], string>>;
export type CustomTheme = { schema: 1; id: string; name: string; light: ThemeColors; dark: ThemeColors };
+38 -3
View File
@@ -1,5 +1,20 @@
:root {
--rs-selection-text: var(--rs-text);
--rs-tooltip-padding: 6px 10px;
--rs-tooltip-bg: var(--rs-bg-active);
--rs-tooltip-text: var(--rs-text-strong);
--rs-tooltip-shadow: 0 4px 16px #0005;
--rs-tooltip-font-size: 12px;
--rs-control-radius: 5px;
--rs-image-control-bg: color-mix(in srgb, var(--rs-bg) 82%, transparent);
--rs-image-control-hover-bg: color-mix(in srgb, var(--rs-bg-active) 92%, transparent);
--rs-image-sidebar-bg: color-mix(in srgb, var(--rs-bg-elevated) 82%, transparent);
--rs-image-editor-bg: color-mix(in srgb, var(--rs-bg) 90%, transparent);
--rs-code-block-bg: color-mix(in srgb, var(--rs-bg-elevated) 82%, transparent);
--rs-workarea-sidebar-bg: var(--rs-bg-elevated);
--rs-workarea-editor-bg: var(--rs-bg);
--rs-workarea-surface-opacity: 100%;
--rs-workarea-plugin-bg: var(--rs-bg);
--rs-titlebar-height: 36px;
--rs-settings-row-padding: 10px;
--rs-settings-control-height: 28px;
@@ -9,12 +24,14 @@
--rs-settings-section-gap: 16px;
--rs-menu-width: 248px;
--rs-menu-padding: 5px;
--rs-menu-row-height: 30px;
--rs-menu-row-padding: 4px 10px;
--rs-menu-row-height: 24px;
--rs-menu-row-padding: 2px 10px;
--rs-menu-icon-size: 14px;
--rs-menu-icon-gap: 8px;
--rs-menu-font-size: 13px;
--rs-menu-border: transparent;
--rs-menu-bg: color-mix(in srgb, var(--rs-bg-elevated) 82%, transparent);
--rs-menu-active-bg: color-mix(in srgb, var(--rs-bg-active) 82%, transparent);
--rs-menu-shadow: 0 8px 30px #0006;
--rs-item-selection-radius: var(--rs-control-radius);
--rs-item-selection-bg: color-mix(in srgb, var(--rs-accent) 20%, transparent);
@@ -85,6 +102,24 @@
--rs-font-heading: "Poppins", Arial, sans-serif;
}
[data-palette="sakura"] {
[data-palette="sakura"], [data-palette="harvest-moon"], [data-palette="crimson-pilot"], [data-palette="silver-serpent"] {
--rs-item-selection-bg: var(--rs-selection);
}
[data-palette="harvest-moon"] {
--rs-font-ui: Candara, "Trebuchet MS", "Segoe UI", sans-serif;
--rs-font-prose: Constantia, Georgia, "Times New Roman", serif;
--rs-font-heading: var(--rs-font-prose);
}
[data-palette="crimson-pilot"] {
--rs-font-ui: Bahnschrift, "Trebuchet MS", Arial, sans-serif;
--rs-font-prose: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
--rs-font-heading: var(--rs-font-ui);
}
[data-palette="silver-serpent"] {
--rs-font-ui: Corbel, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
--rs-font-prose: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
--rs-font-heading: var(--rs-font-prose);
}