Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user