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:
@@ -12,8 +12,31 @@
|
||||
let { onOpen, searchRequest }: Props = $props();
|
||||
let query = $state("");
|
||||
let hits = $state<SearchHit[]>([]);
|
||||
let searched = $state("");
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
// Hits in groups by file, in the order of the first hit of each file.
|
||||
const groups = $derived.by(() => {
|
||||
const files = new Map<string, SearchHit[]>();
|
||||
for (const hit of hits) files.set(hit.rel_path, [...files.get(hit.rel_path) ?? [], hit]);
|
||||
return [...files].map(([path, items]) => ({ path, name: path.split("/").pop() ?? path, folder: path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "", items }));
|
||||
});
|
||||
|
||||
/** The parts of a hit line, with the parts that match the query marked. */
|
||||
function parts(text: string, term: string) {
|
||||
const lower = text.toLowerCase(), needle = term.toLowerCase();
|
||||
if (!needle) return [{ text, match: false }];
|
||||
const result: { text: string; match: boolean }[] = [];
|
||||
let from = 0;
|
||||
for (let index = lower.indexOf(needle); index >= 0; index = lower.indexOf(needle, index + needle.length)) {
|
||||
if (index > from) result.push({ text: text.slice(from, index), match: false });
|
||||
result.push({ text: text.slice(index, index + needle.length), match: true });
|
||||
from = index + needle.length;
|
||||
}
|
||||
if (from < text.length) result.push({ text: text.slice(from), match: false });
|
||||
return result;
|
||||
}
|
||||
|
||||
let generation = 0;
|
||||
$effect(() => { if (searchRequest) { query = searchRequest.text; void run(searchRequest.text); } });
|
||||
|
||||
@@ -28,6 +51,7 @@
|
||||
const results = await workspaceSearch(q);
|
||||
if (version !== generation) return;
|
||||
hits = results;
|
||||
searched = q;
|
||||
error = null;
|
||||
} catch (err) {
|
||||
if (version !== generation) return;
|
||||
@@ -51,24 +75,23 @@
|
||||
{#if error}
|
||||
<p class="error">{error}</p>
|
||||
{/if}
|
||||
<ul>
|
||||
{#each hits as hit (hit.rel_path + hit.line + hit.text)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() =>
|
||||
onOpen(
|
||||
{
|
||||
name: hit.rel_path.split("/").pop() ?? hit.rel_path,
|
||||
rel_path: hit.rel_path,
|
||||
kind: "file",
|
||||
},
|
||||
hit.line,
|
||||
)}
|
||||
>
|
||||
<span class="path">{hit.rel_path}:{hit.line}</span>
|
||||
<span class="text">{hit.text}</span>
|
||||
</button>
|
||||
{#if searched}
|
||||
<p class="summary" role="status">{hits.length === 1 ? $t("1 result") : $t("{count} results in {files} files", { count: hits.length, files: groups.length })}</p>
|
||||
{/if}
|
||||
<ul class="results">
|
||||
{#each groups as group (group.path)}
|
||||
<li class="file">
|
||||
<div class="file-name" title={group.path}><span class="name">{group.name}</span>{#if group.folder}<span class="folder">{group.folder}</span>{/if}<span class="count">{group.items.length}</span></div>
|
||||
<ul>
|
||||
{#each group.items as hit (hit.line + hit.text)}
|
||||
<li>
|
||||
<button type="button" onclick={() => onOpen({ name: group.name, rel_path: hit.rel_path, kind: "file" }, hit.line)}>
|
||||
<span class="line">{hit.line}</span>
|
||||
<span class="text">{#each parts(hit.text, searched) as part}{#if part.match}<mark>{part.text}</mark>{:else}{part.text}{/if}{/each}</span>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
@@ -110,37 +133,75 @@
|
||||
ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.results {
|
||||
padding: 0 0 12px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.summary {
|
||||
margin: 0 10px 6px;
|
||||
color: var(--rs-text-dim);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.file + .file { margin-top: 6px; }
|
||||
|
||||
.file-name {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
|
||||
.name { color: var(--rs-text-strong); font-weight: 600; white-space: nowrap; }
|
||||
.folder { min-width: 0; overflow: hidden; color: var(--rs-text-dim); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.count { margin-left: auto; padding: 0 6px; border-radius: 9px; background: var(--rs-bg-active); color: var(--rs-text); font-size: 11px; }
|
||||
|
||||
button {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-height: 24px;
|
||||
border-radius: var(--rs-control-radius);
|
||||
border: 0;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
padding: 6px 10px;
|
||||
padding: 3px 10px 3px 18px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: var(--rs-bg-active);
|
||||
}
|
||||
|
||||
.path {
|
||||
display: block;
|
||||
color: var(--rs-accent);
|
||||
font-size: 12px;
|
||||
.line {
|
||||
flex: 0 0 auto;
|
||||
min-width: 2ch;
|
||||
color: var(--rs-text-dim);
|
||||
font-size: 11px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.text {
|
||||
display: block;
|
||||
color: var(--rs-text-dim);
|
||||
min-width: 0;
|
||||
color: var(--rs-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* A match uses the search match fill of the theme, so the text keeps its contrast. */
|
||||
mark {
|
||||
border-radius: 2px;
|
||||
background: var(--rs-item-selection-bg);
|
||||
box-shadow: inset 0 -2px 0 var(--rs-accent);
|
||||
color: var(--rs-text-strong);
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 8px 10px;
|
||||
color: var(--rs-error);
|
||||
|
||||
Reference in New Issue
Block a user