Add interface languages and improve themes and workspace controls for 0.1.36
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { t, locale, LANGUAGES, setLocale } from "$lib/i18n";
|
||||
import { showActionMenu } from "$lib/ui/managedActionMenu";
|
||||
import { onDestroy } from "svelte";
|
||||
import PluginManager from "$lib/plugins/PluginManager.svelte";
|
||||
import AppearanceSettings from "$lib/theme/AppearanceSettings.svelte";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
@@ -20,13 +23,23 @@
|
||||
onSave: (value: AppSettings) => void;
|
||||
onClose: () => void;
|
||||
} = $props();
|
||||
let closeLanguage = () => {};
|
||||
onDestroy(() => closeLanguage());
|
||||
function languagePicker(event: MouseEvent) {
|
||||
closeLanguage();
|
||||
const anchor = event.currentTarget as HTMLButtonElement;
|
||||
const bounds = anchor.getBoundingClientRect();
|
||||
closeLanguage = showActionMenu({ x: bounds.left, y: bounds.bottom + 4, label: $t("Language"), parent: dialog,
|
||||
items: LANGUAGES.map(item => ({ label: item.name, radio: true, checked: $locale === item.id,
|
||||
run: () => { try { setLocale(item.id); error = ""; message = $t("Changes saved."); } catch { error = $t("Could not save language settings."); } } })) }).close;
|
||||
}
|
||||
type Section = string;
|
||||
const sections: { id: Section; label: string; icon: IconName; keywords: string }[] = [
|
||||
{ id: "about", label: "Help and about", icon: "help", keywords: "help about version shortcuts keyboard guide" },
|
||||
{ id: "general", label: "General", icon: "settings", keywords: "auto-save autosave save interval seconds files" },
|
||||
{ id: "appearance", label: "Appearance", icon: "sun", keywords: "theme colors light dark Claude Sakura Harvest Moon Crimson Pilot Silver Serpent" },
|
||||
{ id: "plugins", label: "Plug-ins", icon: "puzzle", keywords: "plugins extensions community" },
|
||||
];
|
||||
const sections: { id: Section; label: string; icon: IconName; keywords: string }[] = $derived([
|
||||
{ id: "about", label: $t("Help and about"), icon: "help", keywords: "help about version shortcuts keyboard guide" },
|
||||
{ id: "general", label: $t("General"), icon: "settings", keywords: "auto-save autosave save interval seconds files language français 日本語 简体中文" },
|
||||
{ id: "appearance", label: $t("Appearance"), icon: "sun", keywords: "theme colors light dark Claude Sakura Harvest Moon Crimson Pilot Silver Serpent" },
|
||||
{ id: "plugins", label: $t("Plug-ins"), icon: "puzzle", keywords: "plugins extensions community" },
|
||||
]);
|
||||
let section = $state<Section>(untrack(() => help ? "about" : "general"));
|
||||
let query = $state("");
|
||||
let seconds = $state<number | undefined>(untrack(() => settings.autosaveSeconds));
|
||||
@@ -39,7 +52,7 @@
|
||||
label: tool.title, icon: "settings" as const,
|
||||
keywords: `${$installedPlugins.plugins.find(row => row.manifest.id === tool.owner)?.manifest.name ?? tool.owner} settings configuration`,
|
||||
})));
|
||||
const matches = $derived([...sections, ...(browserEnabled ? [{ id: "browser" as const, label: "Browser", icon: "globe" as const, keywords: "browser profiles search cookies cache web privacy" }] : []), ...pluginSections].filter(item => `${item.label} ${item.keywords}`.toLowerCase().includes(query.trim().toLowerCase())));
|
||||
const matches = $derived([...sections, ...(browserEnabled ? [{ id: "browser" as const, label: $t("Browser"), icon: "globe" as const, keywords: "browser profiles search cookies cache web privacy" }] : []), ...pluginSections].filter(item => `${item.label} ${item.keywords}`.toLowerCase().includes(query.trim().toLowerCase())));
|
||||
const selected = $derived(matches.find(item => item.id === section) ?? matches[0]);
|
||||
const selectedPlugin = $derived(pluginSections.find(item => item.id === selected?.id));
|
||||
|
||||
@@ -52,13 +65,13 @@
|
||||
|
||||
function apply(value: AppSettings) {
|
||||
error = "";
|
||||
try { onSave(value); message = "Changes saved."; }
|
||||
catch { error = "Could not save these settings. Your previous settings still apply. Try again."; message = ""; }
|
||||
try { onSave(value); message = $t("Changes saved."); }
|
||||
catch { error = $t("Could not save these settings. Your previous settings still apply. Try again."); message = ""; }
|
||||
}
|
||||
|
||||
function changeInterval() {
|
||||
if (!validAutosaveSeconds(seconds)) {
|
||||
error = "Choose a whole number from 1 to 300 seconds.";
|
||||
error = $t("Choose a whole number from 1 to 300 seconds.");
|
||||
message = "";
|
||||
return;
|
||||
}
|
||||
@@ -80,52 +93,54 @@
|
||||
|
||||
<dialog bind:this={dialog} class:help class:standalone aria-labelledby="settings-title" onkeydown={trapFocus} oncancel={event => { if (event.target === dialog) { event.preventDefault(); onClose(); } }}>
|
||||
<header class:window-header={!!windowControls} data-tauri-drag-region={windowControls ? true : undefined}>
|
||||
<h1 id="settings-title" data-tauri-drag-region={windowControls ? true : undefined}>{help ? "Help and about" : "Settings"}</h1>
|
||||
<h1 id="settings-title" data-tauri-drag-region={windowControls ? true : undefined}>{help ? $t("Help and about") : $t("Settings")}</h1>
|
||||
{#if windowControls}
|
||||
{@render windowControls()}
|
||||
{:else}
|
||||
<IconButton icon="close" label={help ? "Close help" : "Close settings"} onclick={onClose} />
|
||||
<IconButton icon="close" label={help ? $t("Close help") : $t("Close settings")} onclick={onClose} />
|
||||
{/if}
|
||||
</header>
|
||||
<div class="body">
|
||||
{#if !help}
|
||||
<aside>
|
||||
<label class="search"><Icon icon="search" /><input aria-label="Search settings" placeholder="Search settings…" bind:value={query} /></label>
|
||||
<p class="nav-heading">Preferences</p>
|
||||
<nav aria-label="Settings categories">
|
||||
<label class="search"><Icon icon="search" /><input aria-label={$t("Search settings")} placeholder={$t("Search settings…")} bind:value={query} /></label>
|
||||
<p class="nav-heading">{$t("Preferences")}</p>
|
||||
<nav aria-label={$t("Settings categories")}>
|
||||
{#each matches as item}
|
||||
<button class:active={selected?.id === item.id} aria-current={selected?.id === item.id ? "page" : undefined} onclick={() => select(item.id)}><Icon icon={item.icon} />{item.label}</button>
|
||||
{/each}
|
||||
</nav>
|
||||
<p class="scope">For all workspaces on this device.</p>
|
||||
<p class="scope">{$t("For all workspaces on this device.")}</p>
|
||||
</aside>
|
||||
{/if}
|
||||
<div class="content">
|
||||
{#if windowError}<p class="error" role="alert">{windowError}</p>{/if}
|
||||
{#if !selected}
|
||||
<h2>No settings found</h2>
|
||||
<p>Try “save”, “plug-ins”, or “help”.</p>
|
||||
<button class="text-button" onclick={() => query = ""}>Clear search</button>
|
||||
<h2>{$t("No settings found")}</h2>
|
||||
<p>{$t("Try “save”, “plug-ins”, or “help”.")}</p>
|
||||
<button class="text-button" onclick={() => query = ""}>{$t("Clear search")}</button>
|
||||
{:else if selected.id === "general"}
|
||||
<h2>General</h2>
|
||||
<p class="intro">Choose how RuneStone saves your work.</p>
|
||||
<h3>Files</h3>
|
||||
<h2>{$t("General")}</h2>
|
||||
<p class="intro">{$t("Choose how RuneStone saves your work.")}</p>
|
||||
<h3>{$t('Language')}</h3>
|
||||
<div class="card"><div class="setting-row language-row"><div><label for="language-picker">{$t('Display language')}</label><p>{$t('Choose the language for RuneStone controls.')}</p></div><button id="language-picker" class="text-button language-picker" aria-haspopup="menu" onclick={languagePicker}><Icon icon="globe" />{LANGUAGES.find(item => item.id === $locale)?.name}<Icon icon="chevron-down" /></button></div></div>
|
||||
<h3>{$t("Files")}</h3>
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><label for="show-internal-folder">Show .runestone folder</label><p id="internal-folder-description">Show workspace settings and plugin data in the file tree.</p></div>
|
||||
<div><label for="show-internal-folder">{$t("Show .runestone folder")}</label><p id="internal-folder-description">{$t("Show workspace settings and plugin data in the file tree.")}</p></div>
|
||||
<input id="show-internal-folder" class="switch" type="checkbox" role="switch" aria-describedby="internal-folder-description" checked={settings.showInternalFolder} onchange={event => apply({ ...settings, showInternalFolder: event.currentTarget.checked })} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><label for="autosave-enabled">Auto-save</label><p id="autosave-description">Save changed notes and scripts, including background tabs.</p></div>
|
||||
<div><label for="autosave-enabled">{$t("Auto-save")}</label><p id="autosave-description">{$t("Save changed notes and scripts, including background tabs.")}</p></div>
|
||||
<input id="autosave-enabled" class="switch" type="checkbox" role="switch" aria-describedby="autosave-description" checked={settings.autosaveEnabled} onchange={event => { apply({ ...settings, autosaveEnabled: event.currentTarget.checked }); event.currentTarget.checked = settings.autosaveEnabled; }} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><label for="autosave-seconds">Auto-save interval</label><p id="interval-description">Time between saves, even while you type. Choose 1–300 seconds.</p></div>
|
||||
<div class="interval"><input id="autosave-seconds" type="number" min={MIN_AUTOSAVE_SECONDS} max={MAX_AUTOSAVE_SECONDS} step="1" required disabled={!settings.autosaveEnabled} aria-describedby="interval-description" aria-invalid={!!error} bind:value={seconds} onchange={changeInterval} /><span>seconds</span></div>
|
||||
<div><label for="autosave-seconds">{$t("Auto-save interval")}</label><p id="interval-description">{$t("Time between saves, even while you type. Choose 1–300 seconds.")}</p></div>
|
||||
<div class="interval"><input id="autosave-seconds" type="number" min={MIN_AUTOSAVE_SECONDS} max={MAX_AUTOSAVE_SECONDS} step="1" required disabled={!settings.autosaveEnabled} aria-describedby="interval-description" aria-invalid={!!error} bind:value={seconds} onchange={changeInterval} /><span>{$t("seconds")}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="note">{settings.autosaveEnabled ? "Only changed files are saved." : "Auto-save is off. Use Ctrl+S to save your changes."} Disk conflicts keep your edits for review.</p>
|
||||
<div class="section-footer"><button class="text-button" onclick={() => { seconds = DEFAULT_SETTINGS.autosaveSeconds; apply({ ...DEFAULT_SETTINGS }); }}>Restore defaults</button><span>Default: every 5 seconds</span></div>
|
||||
<p class="note">{settings.autosaveEnabled ? $t("Only changed files are saved.") : $t("Auto-save is off. Use Ctrl+S to save your changes.")} {$t("Disk conflicts keep your edits for review.")}</p>
|
||||
<div class="section-footer"><button class="text-button" onclick={() => { seconds = DEFAULT_SETTINGS.autosaveSeconds; apply({ ...DEFAULT_SETTINGS }); }}>{$t("Restore defaults")}</button><span>{$t("Default: every 5 seconds")}</span></div>
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
<p class="saved" role="status">{message}</p>
|
||||
{:else if selected.id === "appearance"}
|
||||
@@ -137,13 +152,13 @@
|
||||
{:else if selectedPlugin}
|
||||
{#key selectedPlugin.id}<PluginSettings owner={selectedPlugin.owner} id={selectedPlugin.view} />{/key}
|
||||
{:else}
|
||||
<div class="brand"><img src="/runestone.svg" alt="" width="88" height="88" /><h2>RuneStone</h2><p>Version {version}</p></div>
|
||||
<div class="brand"><img src="/runestone.svg" alt="" width="88" height="88" /><h2>RuneStone</h2><p>{$t("Version {version}", { version })}</p></div>
|
||||
<div class="card help-card">
|
||||
<details><summary><Icon icon="book-open" /> Get started</summary><div class="help-copy"><p>Use the folder button to open a workspace or create one. Your notes and scripts stay as ordinary files on disk.</p><p>Use the + beside the tabs for a new tab. Press Ctrl+N to create a file, or Ctrl+P to find one.</p><p>Press Ctrl+E to switch between writing and source editing. Use the terminal button to work with a shell beside your files.</p></div></details>
|
||||
<details><summary><Icon icon="save" /> Save your work</summary><div class="help-copy"><p>Auto-save saves changed files at the interval in Settings → General. Ctrl+S saves the active file immediately.</p><p>If another app changes a file, RuneStone keeps your edits and offers both versions for review.</p></div></details>
|
||||
<details><summary><Icon icon="code" /> Keyboard shortcuts</summary><dl><div><dt>Open a workspace</dt><dd><kbd>Ctrl+O</kbd></dd></div><div><dt>Find a file</dt><dd><kbd>Ctrl+P</kbd></dd></div><div><dt>Save the active file</dt><dd><kbd>Ctrl+S</kbd></dd></div><div><dt>Search the workspace</dt><dd><kbd>Ctrl+Shift+F</kbd></dd></div><div><dt>Open settings</dt><dd><kbd>Ctrl+,</kbd></dd></div><div><dt>Help and about</dt><dd><kbd>F1</kbd></dd></div></dl></details>
|
||||
<details><summary><Icon icon="book-open" /> {$t("Get started")}</summary><div class="help-copy"><p>{$t("Use the folder button to open a workspace or create one. Your notes and scripts stay as ordinary files on disk.")}</p><p>{$t("Use the + beside the tabs for a new tab. Press Ctrl+N to create a file, or Ctrl+P to find one.")}</p><p>{$t("Press Ctrl+E to switch between writing and source editing. Use the terminal button to work with a shell beside your files.")}</p></div></details>
|
||||
<details><summary><Icon icon="save" /> {$t("Save your work")}</summary><div class="help-copy"><p>{$t("Auto-save saves changed files at the interval in Settings → General. Ctrl+S saves the active file immediately.")}</p><p>{$t("If another app changes a file, RuneStone keeps your edits and offers both versions for review.")}</p></div></details>
|
||||
<details><summary><Icon icon="code" /> {$t("Keyboard shortcuts")}</summary><dl><div><dt>{$t("Open a workspace")}</dt><dd><kbd>Ctrl+O</kbd></dd></div><div><dt>{$t("Find a file")}</dt><dd><kbd>Ctrl+P</kbd></dd></div><div><dt>{$t("Save the active file")}</dt><dd><kbd>Ctrl+S</kbd></dd></div><div><dt>{$t("Search the workspace")}</dt><dd><kbd>Ctrl+Shift+F</kbd></dd></div><div><dt>{$t("Open settings")}</dt><dd><kbd>Ctrl+,</kbd></dd></div><div><dt>{$t("Help and about")}</dt><dd><kbd>F1</kbd></dd></div></dl></details>
|
||||
</div>
|
||||
<p class="about-note">RuneStone is under development. Maintained by kwyvern-gh.</p>
|
||||
<p class="about-note">{$t("RuneStone is under development. Maintained by kwyvern-gh.")}</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -179,6 +194,8 @@
|
||||
.setting-row + .setting-row { border-top: 1px solid var(--rs-border); }
|
||||
.setting-row label { font-weight: 500; }
|
||||
.setting-row p { margin: 3px 0 0; font-size: var(--rs-settings-description-size); }
|
||||
.language-row { flex-wrap: wrap; }
|
||||
.language-picker { display:flex; align-items:center; gap:var(--rs-settings-gap); max-width:100%; }
|
||||
.switch { appearance: none; width: 38px; height: 22px; flex: 0 0 38px; margin: 0; border-radius: 20px; background: var(--rs-bg-active); border: 1px solid var(--rs-text-dim); cursor: pointer; }
|
||||
.switch::before { content: ""; display: block; width: 16px; height: 16px; margin: 2px; background: var(--rs-text); border-radius: 50%; transition: transform .12s; }
|
||||
.switch:checked { background: var(--rs-accent); border-color: var(--rs-accent); }
|
||||
|
||||
Reference in New Issue
Block a user