Give way in narrow windows and use one icon for each action

Phase 5-6.

- Side panes give way when the window becomes narrow: the outline
  below 1100 pixels, the side pane below 800 pixels. They come back
  when the window grows. A pane that the user opens in a narrow window
  stays open, and the saved layout keeps the wide-window choice.
- One function has one icon. The SDK icon set gets duplicate, template,
  and tab. The reveal action has one label for each platform (Show in
  Explorer, Show in Finder, Show in file manager).
- The file menu follows one order: open, clipboard, organize, show and
  copy path, history, then Delete and Delete permanently in the error
  color after a separator. The tree copies paths through a Copy path
  submenu, as the tab menu does.
- The tree uses the shared chevron. Search hits come in groups by file,
  with counts and marked matches. Bookmarks show the name, the folder,
  and a remove button.
- All boolean settings use one switch design (src/lib/ui/switch.css).
  Browser settings apply at once, and the Save button is gone. The
  Settings window opens with the focus on its search.
- Targets of at least 24 pixels: the tab close button, outline rows,
  switches, and the settings search.
- Catalog rows in French, Japanese, and Simplified Chinese.
- Docs: UI-052, ui-design.md, and the user guide.

Tests: the new layout/panesAndSettings. Tests that closed or opened
panes by hand around narrow windows now rely on the new behavior, or
wait for the panes to give way before they reopen one. Tests that read
the old menu labels or the browser Save button use the new ones.
This commit is contained in:
Knotty Wyvern
2026-10-28 21:31:36 -07:00
parent b7a9784f55
commit 0fdc991b2e
46 changed files with 590 additions and 351 deletions
+88 -89
View File
@@ -1,89 +1,88 @@
<script lang="ts">
import { t } from "$lib/i18n";
import { onMount, onDestroy } from 'svelte';
import Icon from '$lib/ui/Icon.svelte';
import { showActionMenu } from '$lib/ui/managedActionMenu';
import WebData from './WebData.svelte';
import { state as browserState, request } from './client';
let selected = $state('user'), name = $state(''), message = $state('');
let search = $state('duckduckgo'), adblock = $state(true), internalLinks = $state(true), rules = $state('');
let homepage = $state(''), filterLists = $state(''), ready = $state(false), busy = $state(false);
const engines = [{ id: 'duckduckgo', name: 'DuckDuckGo' }, { id: 'google', name: 'Google' }, { id: 'bing', name: 'Bing' }];
let closePicker = () => {};
onDestroy(() => closePicker());
function picker(event: MouseEvent, profile = false) {
closePicker();
const anchor = event.currentTarget as HTMLButtonElement;
const bounds = anchor.getBoundingClientRect();
closePicker = showActionMenu({ x: bounds.left, y: bounds.bottom + 4, label: profile ? $t('Profile') : $t('Search engine'),
parent: anchor.closest('dialog') ?? undefined,
items: (profile ? $browserState?.profiles || [] : engines).map(choice => ({ label: choice.name,
radio: true, checked: choice.id === (profile ? selected : search),
run: () => { if (profile) selected = choice.id; else search = choice.id; } })) }).close;
}
onMount(() => { void request('state').then(value => {
selected = value.profiles[0].id; search = value.settings.search; adblock = value.settings.adblock;
internalLinks = value.settings.linkDestination === 'internal'; rules = value.settings.personalRules;
homepage = value.settings.homepage || ''; filterLists = (value.settings.filterLists || []).join('\n'); ready = true;
}).catch(error => message = String(error)); });
async function act(command: string, args: Record<string, unknown>) {
try { const next = await request(command, args); message = $t('Changes saved.'); return next; } catch (error) { message = String(error); return null; }
}
async function create(duplicate: boolean) {
if (!name.trim()) { message = $t('Enter a profile name.'); return; }
const result = await act(duplicate ? 'duplicateProfile' : 'createProfile', duplicate ? { profileId: selected, name } : { name });
if (result) { selected = result.profiles.at(-1)!.id; name = ''; }
}
async function save() {
busy = true; message = $t('Saving browser settings…');
try {
await act('settings', { search, adblock, linkDestination: internalLinks ? 'internal' : 'external', personalRules: rules,
homepage, filterLists: filterLists.split(/\r?\n/).map(value => value.trim()).filter(Boolean) });
} finally { busy = false; }
}
</script>
<div class="settings">
<h2>{$t("Browser")}</h2><p>{$t("Choose how you browse within RuneStone.")}</p>
<h3>{$t("General")}</h3>
<form onsubmit={event => { event.preventDefault(); if (ready && !busy) void save(); }}>
<fieldset disabled={!ready || busy}>
<div class="card">
<label class="row"><span>{$t("Open web links in RuneStone")}<small>{$t("Turn this off to use your system browser.")}</small></span><input class="switch" type="checkbox" role="switch" aria-label={$t("Open web links in RuneStone")} bind:checked={internalLinks}></label>
<label class="row"><span>{$t("Homepage")}<small>{$t("The page to open in each new browser tab. Leave blank for an empty page.")}</small></span><input class="address" type="url" aria-label={$t("Homepage")} placeholder="https://example.com" maxlength="8192" bind:value={homepage}></label>
<div class="row"><span>{$t("Search engine")}</span><button type="button" class="picker" aria-label={$t("Search engine")} aria-haspopup="menu" onclick={event => picker(event)}>{engines.find(engine => engine.id === search)?.name ?? 'DuckDuckGo'}<Icon icon="chevron-down" /></button></div>
<label class="row"><span>{$t("Block ads and trackers")}<small>{$t("Apply the filter lists and personal rules to all browser tabs.")}</small></span><input class="switch" type="checkbox" role="switch" aria-label={$t("Block ads and trackers")} bind:checked={adblock}></label>
<label class="row list-row"><span>{$t("Ad blocking lists")}<small>{$t("One HTTPS filter list URL per line, up to eight lists. New lists download when you save.")}</small></span><textarea aria-label={$t("Ad blocking lists")} rows="4" maxlength="66000" placeholder="https://easylist.to/easylist/easylist.txt" bind:value={filterLists}></textarea></label>
</div>
<label class="rules">{$t("Personal filter rules")}<small>{$t("Use one rule per line. Block a domain with ||ads.example.com^, allow it with @@||ads.example.com^, or hide an element with example.com##.advertisement. Save to apply the rules.")}</small><textarea rows="4" maxlength="100000" placeholder={'! Block an advertising domain\n||ads.example.com^\n! Hide an element on one site\nexample.com##.advertisement'} bind:value={rules}></textarea></label>
<button type="submit"><Icon icon="save" />{busy ? $t('Saving…') : $t('Save browser settings')}</button>
</fieldset>
</form>
<h3>{$t("Profiles")}</h3><p>{$t("New profiles start blank. Duplicate a profile to copy its stored browsing data and bookmarks.")}</p>
<div class="card profiles">
<div class="profile-choice"><span>{$t("Profile")}</span><button type="button" class="picker" aria-label={$t("Profile")} aria-haspopup="menu" disabled={!ready} onclick={event => picker(event, true)}>{$browserState?.profiles.find(profile => profile.id === selected)?.name ?? $t('Profile')}<Icon icon="chevron-down" /></button></div>
<label>{$t("New profile name")}<input bind:value={name} maxlength="60" placeholder={$t("Profile name")}></label>
<div class="actions"><button onclick={() => void create(false)}><Icon icon="plus" />{$t("New blank profile")}</button><button onclick={() => void create(true)}><Icon icon="copy" />{$t("Duplicate profile")}</button></div>
<p class="note">{$t("Duplication briefly restarts browser tabs. The copies remain separate. Agent permissions are not copied.")}</p>
</div>
<h3>{$t("Web data")}</h3><p>{$t("Clear data for the selected profile. Its browser tabs will close. Bookmarks remain.")}</p>
<div class="actions"><button onclick={() => void act('clearData', { profileId: selected, kind: 'cache' })}>{$t("Clear cache")}</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'cookies' })}>{$t("Clear cookies")}</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'history' })}>{$t("Clear history")}</button></div>
<p role="status">{message}</p>
{#if ready}<WebData profileId={selected} />{/if}
</div>
<style>
.settings{color:var(--rs-text);font-family:var(--rs-font-ui)}h2{margin:0;font-size:var(--rs-settings-heading-size);font-weight:500;color:var(--rs-text-strong)}h3{margin:var(--rs-settings-section-gap) 0 var(--rs-settings-gap);font-size:14px;font-weight:500}
p{color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.6}.card{padding:0 var(--rs-settings-row-padding);background:var(--rs-bg-elevated);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius)}
.row{display:flex;justify-content:space-between;align-items:center;gap:var(--rs-settings-gap);padding:var(--rs-settings-row-padding) 0}.row+.row{border-top:1px solid var(--rs-border)}
input,textarea,button{border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg);color:var(--rs-text);font:inherit;box-sizing:border-box;min-height:var(--rs-settings-control-height);padding:4px 8px}
button{display:inline-flex;align-items:center;gap:7px;background:var(--rs-bg-elevated);cursor:pointer}button:hover{background:var(--rs-bg-active)}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--rs-focus);outline-offset:1px}
.picker{justify-content:space-between;min-width:140px;max-width:100%;overflow-wrap:anywhere;text-align:left}
.rules{display:flex;flex-direction:column;gap:7px;margin:16px 0}.profiles{padding-top:16px;padding-bottom:8px}.profiles label,.profile-choice{display:flex;flex-direction:column;gap:7px;margin-bottom:14px}
.actions{display:flex;flex-wrap:wrap;gap:8px}.note{margin-bottom:0}
fieldset{border:0;margin:0;padding:0;min-width:0}small{display:block;color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.5;margin-top:5px}
.row>span{flex:1}.address,.list-row textarea{width:260px;max-width:48%;box-sizing:border-box}.list-row{align-items:flex-start}textarea{resize:vertical}
.switch{appearance:none;position:relative;flex:none;width:44px;height:26px;border:0;border-radius:999px;background:var(--rs-text-dim);padding:0;cursor:pointer;transition:background .15s}
.switch::before{content:'';position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:var(--rs-bg);box-shadow:0 1px 3px #0004;transition:transform .15s}
.switch:checked{background:var(--rs-accent)}.switch:checked::before{transform:translateX(18px)}:disabled{opacity:.6;cursor:wait}
@media(prefers-reduced-motion:reduce){.switch,.switch::before{transition:none}}
@media(max-width:600px){.row{flex-wrap:wrap}.address,.list-row textarea{width:100%;max-width:100%}}
</style>
<script lang="ts">
import { t } from "$lib/i18n";
import { onMount, onDestroy } from 'svelte';
import Icon from '$lib/ui/Icon.svelte';
import { showActionMenu } from '$lib/ui/managedActionMenu';
import WebData from './WebData.svelte';
import { state as browserState, request } from './client';
let selected = $state('user'), name = $state(''), message = $state('');
let search = $state('duckduckgo'), adblock = $state(true), internalLinks = $state(true), rules = $state('');
let homepage = $state(''), filterLists = $state(''), ready = $state(false), busy = $state(false);
const engines = [{ id: 'duckduckgo', name: 'DuckDuckGo' }, { id: 'google', name: 'Google' }, { id: 'bing', name: 'Bing' }];
let closePicker = () => {};
onDestroy(() => closePicker());
function picker(event: MouseEvent, profile = false) {
closePicker();
const anchor = event.currentTarget as HTMLButtonElement;
const bounds = anchor.getBoundingClientRect();
closePicker = showActionMenu({ x: bounds.left, y: bounds.bottom + 4, label: profile ? $t('Profile') : $t('Search engine'),
parent: anchor.closest('dialog') ?? undefined,
items: (profile ? $browserState?.profiles || [] : engines).map(choice => ({ label: choice.name,
radio: true, checked: choice.id === (profile ? selected : search),
run: () => { if (profile) selected = choice.id; else { search = choice.id; void save(); } } })) }).close;
}
onMount(() => { void request('state').then(value => {
selected = value.profiles[0].id; search = value.settings.search; adblock = value.settings.adblock;
internalLinks = value.settings.linkDestination === 'internal'; rules = value.settings.personalRules;
homepage = value.settings.homepage || ''; filterLists = (value.settings.filterLists || []).join('\n'); ready = true;
}).catch(error => message = String(error)); });
async function act(command: string, args: Record<string, unknown>) {
try { const next = await request(command, args); message = $t('Changes saved.'); return next; } catch (error) { message = String(error); return null; }
}
async function create(duplicate: boolean) {
if (!name.trim()) { message = $t('Enter a profile name.'); return; }
const result = await act(duplicate ? 'duplicateProfile' : 'createProfile', duplicate ? { profileId: selected, name } : { name });
if (result) { selected = result.profiles.at(-1)!.id; name = ''; }
}
// Settings apply at once: a switch or a choice on change, a text field when it loses focus.
// A change during a save starts one more save after it.
let pending = false;
async function save() {
if (!ready) return;
if (busy) { pending = true; return; }
busy = true; message = $t('Saving browser settings…');
try {
await act('settings', { search, adblock, linkDestination: internalLinks ? 'internal' : 'external', personalRules: rules,
homepage, filterLists: filterLists.split(/\r?\n/).map(value => value.trim()).filter(Boolean) });
} finally { busy = false; }
if (pending) { pending = false; void save(); }
}
</script>
<div class="settings">
<h2>{$t("Browser")}</h2><p>{$t("Choose how you browse within RuneStone.")}</p>
<h3>{$t("General")}</h3>
<fieldset disabled={!ready} onchange={() => void save()}>
<div class="card">
<label class="row"><span>{$t("Open web links in RuneStone")}<small>{$t("Turn this off to use your system browser.")}</small></span><input class="rs-switch" type="checkbox" role="switch" aria-label={$t("Open web links in RuneStone")} bind:checked={internalLinks}></label>
<label class="row"><span>{$t("Homepage")}<small>{$t("The page to open in each new browser tab. Leave blank for an empty page.")}</small></span><input class="address" type="url" aria-label={$t("Homepage")} placeholder="https://example.com" maxlength="8192" bind:value={homepage}></label>
<div class="row"><span>{$t("Search engine")}</span><button type="button" class="picker" aria-label={$t("Search engine")} aria-haspopup="menu" onclick={event => picker(event)}>{engines.find(engine => engine.id === search)?.name ?? 'DuckDuckGo'}<Icon icon="chevron-down" /></button></div>
<label class="row"><span>{$t("Block ads and trackers")}<small>{$t("Apply the filter lists and personal rules to all browser tabs.")}</small></span><input class="rs-switch" type="checkbox" role="switch" aria-label={$t("Block ads and trackers")} bind:checked={adblock}></label>
<label class="row list-row"><span>{$t("Ad blocking lists")}<small>{$t("One HTTPS filter list URL per line, up to eight lists. New lists download when you leave the field.")}</small></span><textarea aria-label={$t("Ad blocking lists")} rows="4" maxlength="66000" placeholder="https://easylist.to/easylist/easylist.txt" bind:value={filterLists}></textarea></label>
</div>
<label class="rules">{$t("Personal filter rules")}<small>{$t("Use one rule per line. Block a domain with ||ads.example.com^, allow it with @@||ads.example.com^, or hide an element with example.com##.advertisement. Save to apply the rules.")}</small><textarea rows="4" maxlength="100000" placeholder={'! Block an advertising domain\n||ads.example.com^\n! Hide an element on one site\nexample.com##.advertisement'} bind:value={rules}></textarea></label>
</fieldset>
<h3>{$t("Profiles")}</h3><p>{$t("New profiles start blank. Duplicate a profile to copy its stored browsing data and bookmarks.")}</p>
<div class="card profiles">
<div class="profile-choice"><span>{$t("Profile")}</span><button type="button" class="picker" aria-label={$t("Profile")} aria-haspopup="menu" disabled={!ready} onclick={event => picker(event, true)}>{$browserState?.profiles.find(profile => profile.id === selected)?.name ?? $t('Profile')}<Icon icon="chevron-down" /></button></div>
<label>{$t("New profile name")}<input bind:value={name} maxlength="60" placeholder={$t("Profile name")}></label>
<div class="actions"><button onclick={() => void create(false)}><Icon icon="plus" />{$t("New blank profile")}</button><button onclick={() => void create(true)}><Icon icon="duplicate" />{$t("Duplicate profile")}</button></div>
<p class="note">{$t("Duplication briefly restarts browser tabs. The copies remain separate. Agent permissions are not copied.")}</p>
</div>
<h3>{$t("Web data")}</h3><p>{$t("Clear data for the selected profile. Its browser tabs will close. Bookmarks remain.")}</p>
<div class="actions"><button onclick={() => void act('clearData', { profileId: selected, kind: 'cache' })}>{$t("Clear cache")}</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'cookies' })}>{$t("Clear cookies")}</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'history' })}>{$t("Clear history")}</button></div>
<p role="status">{message}</p>
{#if ready}<WebData profileId={selected} />{/if}
</div>
<style>
.settings{color:var(--rs-text);font-family:var(--rs-font-ui)}h2{margin:0;font-size:var(--rs-settings-heading-size);font-weight:500;color:var(--rs-text-strong)}h3{margin:var(--rs-settings-section-gap) 0 var(--rs-settings-gap);font-size:14px;font-weight:500}
p{color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.6}.card{padding:0 var(--rs-settings-row-padding);background:var(--rs-bg-elevated);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius)}
.row{display:flex;justify-content:space-between;align-items:center;gap:var(--rs-settings-gap);padding:var(--rs-settings-row-padding) 0}.row+.row{border-top:1px solid var(--rs-border)}
input:not(.rs-switch),textarea,button{border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg);color:var(--rs-text);font:inherit;box-sizing:border-box;min-height:var(--rs-settings-control-height);padding:4px 8px}
button{display:inline-flex;align-items:center;gap:7px;background:var(--rs-bg-elevated);cursor:pointer}button:hover{background:var(--rs-bg-active)}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--rs-focus);outline-offset:1px}
.picker{justify-content:space-between;min-width:140px;max-width:100%;overflow-wrap:anywhere;text-align:left}
.rules{display:flex;flex-direction:column;gap:7px;margin:16px 0}.profiles{padding-top:16px;padding-bottom:8px}.profiles label,.profile-choice{display:flex;flex-direction:column;gap:7px;margin-bottom:14px}
.actions{display:flex;flex-wrap:wrap;gap:8px}.note{margin-bottom:0}
fieldset{border:0;margin:0;padding:0;min-width:0}small{display:block;color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.5;margin-top:5px}
.row>span{flex:1}.address,.list-row textarea{width:260px;max-width:48%;box-sizing:border-box}.list-row{align-items:flex-start}textarea{resize:vertical}␍
@media(max-width:600px){.row{flex-wrap:wrap}.address,.list-row textarea{width:100%;max-width:100%}}
</style>