Update editor, workspace, Git services, appearance, and project guides

This commit is contained in:
Knotty Wyvern
2026-10-11 09:41:16 -07:00
parent a8b1defb9d
commit 909894b9c8
153 changed files with 7967 additions and 775 deletions
+73
View File
@@ -0,0 +1,73 @@
<script lang="ts">
import { onMount } from 'svelte';
import { customThemes, installTheme, parseCustomTheme, removeTheme, type CustomTheme } from './customThemes';
import IconButton from '$lib/ui/IconButton.svelte';
import { APPEARANCE_KEY, DEFAULT_APPEARANCE, parseAppearance, normalizeAppearance, saveAppearance, type Appearance, type ThemeName } from './appearance';
let appearance = $state<Appearance>({ ...DEFAULT_APPEARANCE });
let error = $state('');
let installed = $state<CustomTheme[]>([]);
let themeInput: HTMLInputElement;
onMount(() => {
const read = () => { try { installed = customThemes(); appearance = parseAppearance(localStorage.getItem(APPEARANCE_KEY)); } catch { error = 'Could not read appearance settings.'; } };
read(); window.addEventListener('storage', read); window.addEventListener('focus', read);
return () => { window.removeEventListener('storage', read); window.removeEventListener('focus', read); };
});
function change(next: Appearance) {
try { saveAppearance(next); appearance = normalizeAppearance(next); error = ''; }
catch { error = 'Could not save appearance settings.'; }
}
async function importTheme(file?: File) {
if (!file) return;
try {
if (file.size > 65536) throw new Error('Choose a theme smaller than 64 KiB.');
const theme = parseCustomTheme(JSON.parse(await file.text()));
installTheme(theme); installed = customThemes();
change({ ...appearance, theme: `custom:${theme.id}` });
} catch (reason) { error = String(reason); }
finally { themeInput.value = ''; }
}
function exportTemplate() {
const palette = (mode: 'light' | 'dark') => ({ bg: mode === 'dark' ? '#141414' : '#ffffff', text: mode === 'dark' ? '#e6e6e6' : '#202020', accent: mode === 'dark' ? '#82aaff' : '#315fb3' });
const selected = installed.find(item => `custom:${item.id}` === appearance.theme);
const source = selected ?? { schema: 1, id: 'my-theme', name: 'My theme', light: palette('light'), dark: palette('dark') };
const url = URL.createObjectURL(new Blob([JSON.stringify(source, null, 2) + '\n'], { type: 'application/json' }));
const link = document.createElement('a'); link.href = url; link.download = source.id + '.json'; link.click();
setTimeout(() => URL.revokeObjectURL(url), 1000);
}
</script>
<h2>Appearance</h2>
<p>Choose a color theme and a light or dark appearance.</p>
<div class="card">
<label><span>Color theme</span><select aria-label="Color theme" value={appearance.theme} onchange={event => change({ ...appearance, theme: event.currentTarget.value as ThemeName })}>
<option value="default">RuneStone</option><option value="claude">Claude</option><option value="sakura">Sakura</option>
{#each installed as theme}<option value={`custom:${theme.id}`}>{theme.name}</option>{/each}
</select></label>
<label><span>Appearance</span><select aria-label="Appearance" disabled={appearance.theme === 'sakura'} value={appearance.mode} onchange={event => change({ ...appearance, mode: event.currentTarget.value as 'light' | 'dark' })}>
<option value="light">Light</option><option value="dark">Dark</option>
</select></label>
</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]); }} />
<button onclick={() => themeInput.click()}>Install theme</button>
<button onclick={exportTemplate}>Export theme template</button>
{#if appearance.theme.startsWith('custom:')}<IconButton icon="trash" label="Remove custom theme" onclick={() => {
try { removeTheme(appearance.theme.slice(7)); installed = customThemes(); change({ ...appearance, theme: 'default' }); }
catch { error = 'Could not remove this theme.'; }
}} />{/if}
</div>
<p>Edit the exported JSON colors, then choose Install theme. Each theme has light and dark colors.</p>
{#if appearance.theme === 'sakura'}<p>Sakura uses a light appearance.</p>{/if}
{#if error}<p role="alert">{error}</p>{/if}
<style>
h2{margin:0;font-size:var(--rs-settings-heading-size);color:var(--rs-text-strong)}
p{color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.5}
.card{padding:0 var(--rs-settings-row-padding);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg-elevated)}
label{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:var(--rs-settings-gap);padding:var(--rs-settings-row-padding) 0}
label+label{border-top:1px solid var(--rs-border)}
select{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)}
select:focus-visible{outline:2px solid var(--rs-accent);outline-offset:2px}
[role=alert]{color:var(--rs-error)}
.theme-actions{display:flex;gap:var(--rs-settings-gap);flex-wrap:wrap;margin-top:var(--rs-settings-gap)}
.theme-actions button{min-height:var(--rs-settings-control-height);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg-elevated);color:var(--rs-text);padding:4px 8px}
</style>
+25
View File
@@ -0,0 +1,25 @@
<script lang="ts">
import { onMount } from 'svelte';
import { APPEARANCE_KEY, applyAppearance, parseAppearance } from './appearance';
import { CUSTOM_THEMES_KEY } from './customThemes';
onMount(() => {
const read = () => {
try {
const raw = localStorage.getItem(APPEARANCE_KEY);
const appearance = parseAppearance(raw);
const canonical = JSON.stringify(appearance);
if (raw !== null && raw !== canonical) localStorage.setItem(APPEARANCE_KEY, canonical);
applyAppearance(appearance);
}
catch { /* Keep the current appearance if storage is unavailable. */ }
};
const sync = (event: StorageEvent) => { if (event.key === APPEARANCE_KEY || event.key === CUSTOM_THEMES_KEY || event.key === null) read(); };
read();
window.addEventListener('storage', sync);
window.addEventListener('focus', read);
return () => { window.removeEventListener('storage', sync); window.removeEventListener('focus', read); };
});
</script>
+60
View File
@@ -0,0 +1,60 @@
import { customThemes } from './customThemes.ts';
export const APPEARANCE_KEY = 'runestone.appearance';
export const THEMES = ['default', 'claude', 'sakura'] as const;
export type ThemeName = typeof THEMES[number] | `custom:${string}`;
export type Appearance = { theme: ThemeName; mode: 'light' | 'dark' };
export const DEFAULT_APPEARANCE: Appearance = { theme: 'default', mode: 'dark' };
export function normalizeAppearance(value: { theme?: unknown; mode?: 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';
return { theme, mode: theme === 'sakura' || value?.mode === 'light' ? 'light' : 'dark' };
}
export function parseAppearance(raw: string | null): Appearance {
try { return normalizeAppearance(JSON.parse(raw || 'null')); }
catch { return { ...DEFAULT_APPEARANCE }; }
}
const keys = ['bg', 'bg-elevated', 'bg-active', 'border', 'text-dim', 'text', 'text-strong', 'accent', 'selection'] as const;
const palettes = {
default: {
dark: ['#141414','#1c1c1c','#2a2a2a','#2e2e2e','#9a9a9a','#e6e6e6','#f3f3f3','#82aaff','#264f78'],
light: ['#f3f3f3','#ffffff','#e8e8e8','#d4d4d4','#626262','#1e1e1e','#111111','#315fb3','#add6ff'],
},
// Anthropic brand guidelines: https://github.com/anthropics/skills/blob/main/skills/brand-guidelines/SKILL.md
claude: {
dark: ['#141413','#20201e','#32322e','#5a5952','#b0aea5','#faf9f5','#faf9f5','#d97757','#674435'],
light: ['#faf9f5','#faf9f5','#e8e6dc','#b0aea5','#67665f','#141413','#141413','#d97757','#e8e6dc'],
},
// Palette from pm-image:7968b79c-9d80-40a5-9e9a-696c26aacfb9. Sakura supports light mode only.
sakura: {
light: ['#fefcfc','#fefcfc','#dbeacb','#f8dbe6','#687788','#513346','#321c2a','#98556c','#ffc9dc'],
},
};
export function applyAppearance(value: Appearance, root = document.documentElement) {
const { theme, mode } = normalizeAppearance(value);
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];
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-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']
: ['#f44747', '#d68a00', '#cca700', '#89d185', '#c792ea'];
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]));
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]));
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);
window.dispatchEvent(new CustomEvent('runestone-theme-changed'));
}
export function saveAppearance(value: Appearance) {
const appearance = normalizeAppearance(value);
localStorage.setItem(APPEARANCE_KEY, JSON.stringify(appearance));
applyAppearance(appearance);
}
+40
View File
@@ -0,0 +1,40 @@
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 type ThemeColors = Partial<Record<typeof COLOR_TOKENS[number], string>>;
export type CustomTheme = { schema: 1; id: string; name: string; light: ThemeColors; dark: ThemeColors };
export function parseCustomTheme(input: unknown): CustomTheme {
if (!input || typeof input !== "object") throw new Error("Choose a RuneStone theme JSON file.");
const value = input as Record<string, unknown>;
if (value.schema !== 1 || typeof value.id !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(value.id)
|| typeof value.name !== "string" || !value.name.trim() || value.name.length > 80) throw new Error("The theme needs schema 1, an ID, and a name.");
const colors = (mode: string): ThemeColors => {
const source = value[mode];
if (!source || typeof source !== "object" || Array.isArray(source)) throw new Error(`The theme needs ${mode} colors.`);
const result: ThemeColors = {};
for (const [key, color] of Object.entries(source)) {
if (!(COLOR_TOKENS as readonly string[]).includes(key)) throw new Error(`Unknown theme color: ${key}`);
if (typeof color !== "string" || !/^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color)) throw new Error(`Use a hexadecimal color for ${key}.`);
result[key as keyof ThemeColors] = color;
}
if (!result.bg || !result.text || !result.accent) throw new Error(`The ${mode} palette needs bg, text, and accent.`);
return result;
};
return { schema: 1, id: value.id, name: value.name.trim(), light: colors("light"), dark: colors("dark") };
}
export function customThemes(): CustomTheme[] {
try {
const stored = JSON.parse(localStorage.getItem(CUSTOM_THEMES_KEY) || "[]");
return Array.isArray(stored) ? stored.flatMap(value => { try { return [parseCustomTheme(value)]; } catch { return []; } }) : [];
} catch { return []; }
}
export function installTheme(theme: CustomTheme): void {
const list = customThemes().filter(item => item.id !== theme.id);
localStorage.setItem(CUSTOM_THEMES_KEY, JSON.stringify([...list, parseCustomTheme(theme)]));
}
export function removeTheme(id: string): void {
localStorage.setItem(CUSTOM_THEMES_KEY, JSON.stringify(customThemes().filter(item => item.id !== id)));
}
+34 -8
View File
@@ -1,11 +1,19 @@
:root {
--rs-control-radius: 5px;
--rs-menu-width: 264px;
--rs-titlebar-height: 36px;
--rs-settings-row-padding: 10px;
--rs-settings-control-height: 28px;
--rs-settings-heading-size: 18px;
--rs-settings-description-size: 12px;
--rs-settings-gap: 8px;
--rs-settings-section-gap: 16px;
--rs-menu-width: 248px;
--rs-menu-padding: 5px;
--rs-menu-row-height: 30px;
--rs-menu-row-padding: 6px 10px;
--rs-menu-icon-size: 17px;
--rs-menu-icon-gap: 10px;
--rs-menu-row-height: 26px;
--rs-menu-row-padding: 3px 8px;
--rs-menu-icon-size: 14px;
--rs-menu-icon-gap: 8px;
--rs-menu-font-size: 12px;
--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);
@@ -30,9 +38,17 @@
--rs-font-ui: "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
--rs-font-prose: "Segoe UI Variable Display", "Segoe UI", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
--rs-font-mono: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, ui-monospace, monospace;
--rs-prose-size: 16px;
--rs-prose-line: 1.65;
--rs-font-heading: var(--rs-font-prose);
--rs-font-mono: "Cascadia Mono", "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, ui-monospace, monospace;
--rs-code-font-weight: 300;
--rs-code-font-size: 13px;
--rs-code-line-height: 21px;
--rs-font-weight: 400;
--rs-heading-weight: 500;
--rs-table-cell-padding: 4px 10px;
--rs-table-line-height: 1.5;
--rs-prose-size: 15px;
--rs-prose-line: 1.6;
--rs-code-size: 13px;
--rs-h1-size: 1.6em;
--rs-h2-size: 1.4em;
@@ -61,3 +77,13 @@
--rs-selection: #add6ff;
--rs-line-highlight: #0000000d;
}
[data-palette="claude"] {
--rs-font-ui: "Lora", Georgia, serif;
--rs-font-prose: "Lora", Georgia, serif;
--rs-font-heading: "Poppins", Arial, sans-serif;
}
[data-palette="sakura"] {
--rs-item-selection-bg: var(--rs-selection);
}