With a background image, menus use the surface transparency of Appearance (82% by default) instead of at least 92%, and they keep the blur. Hovered rows and controls in the work area, hovered menu rows, and the workspace button use the new --rs-hover-bg token. With an image, it is a 6% veil of the strong text color. The image stays visible, and the hover shows over light and dark image areas. Without an image, nothing changes. Silver Serpent dim text is now #c2c6cc. It keeps 4.5:1 contrast on a hovered row over a white image. UI-061 replaces the image rule of UI-043. Card 05b9bfa1.
80 lines
4.0 KiB
Svelte
80 lines
4.0 KiB
Svelte
<script lang="ts">
|
|
import { t } from "$lib/i18n";
|
|
import Icon from "$lib/ui/Icon.svelte";
|
|
import IconButton from "$lib/ui/IconButton.svelte";
|
|
import { attachTooltip } from "$lib/ui/tooltip";
|
|
import type { Backlink } from "$lib/workspace/noteIndex";
|
|
|
|
type Props = {
|
|
entries: Backlink[];
|
|
busy?: boolean;
|
|
error?: string | null;
|
|
onOpen: (entry: Backlink) => void;
|
|
onRebuild?: () => void;
|
|
};
|
|
let { entries, busy = false, error = null, onOpen, onRebuild }: Props = $props();
|
|
let expanded = $state(true);
|
|
const contentId = $props.id();
|
|
function collapseTooltip(node: HTMLElement) {
|
|
return { destroy: attachTooltip(node, () => $t(expanded ? "Collapse backlinks" : "Expand backlinks")) };
|
|
}
|
|
</script>
|
|
|
|
<section class="backlinks" aria-label={$t("Backlinks")} aria-busy={busy}>
|
|
<div class="heading">
|
|
<button class="toggle" type="button" aria-expanded={expanded} aria-controls={contentId} use:collapseTooltip onclick={() => expanded = !expanded}>
|
|
<span class:collapsed={!expanded}><Icon icon="chevron-down" /></span>
|
|
<Icon icon="link" />
|
|
<span>{$t("Backlinks")}</span>
|
|
<span class="count">{entries.length}</span>
|
|
</button>
|
|
{#if onRebuild}
|
|
<IconButton icon="refresh" label={$t("Rebuild note index")} disabled={busy} onclick={onRebuild} />
|
|
{/if}
|
|
</div>
|
|
<div id={contentId} class="content" hidden={!expanded}>
|
|
{#if error}
|
|
<p class="error" role="status">{error}</p>
|
|
{/if}
|
|
{#if busy}
|
|
<p class="placeholder" role="status">{$t("Reading workspace links…")}</p>
|
|
{:else if entries.length === 0}
|
|
<p class="placeholder">{$t("No other notes link to this file.")}</p>
|
|
{/if}
|
|
{#if entries.length > 0}
|
|
<ul>
|
|
{#each entries as entry (entry.sourcePath + ":" + entry.from)}
|
|
<li>
|
|
<button class="source" type="button" aria-label={$t("Open {path}, line {line}", { path: entry.sourcePath, line: entry.line })} onclick={() => onOpen(entry)}>
|
|
<span class="source-title"><Icon icon="text" /><span>{entry.sourcePath}</span><span class="line">{entry.line}</span></span>
|
|
<span class="excerpt">{entry.text}</span>
|
|
</button>
|
|
</li>
|
|
{/each}
|
|
</ul>
|
|
{/if}
|
|
</div>
|
|
</section>
|
|
|
|
<style>
|
|
.backlinks { min-height: 0; border-top: 1px solid var(--rs-border); display: flex; flex-direction: column; }
|
|
.heading { display: flex; align-items: center; gap: 2px; padding: 2px 6px; }
|
|
.toggle { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; min-height: 28px; padding: 2px 4px; border: 0; border-radius: var(--rs-control-radius); background: transparent; color: var(--rs-text); text-align: left; font: inherit; }
|
|
.toggle > span:first-child { display: flex; }
|
|
.collapsed { transform: rotate(-90deg); }
|
|
.count { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--rs-text-dim); }
|
|
.content { min-height: 0; overflow: auto; }
|
|
.content[hidden] { display: none; }
|
|
ul { list-style: none; padding: 2px 6px 6px; margin: 0; }
|
|
.source { width: 100%; display: block; padding: 6px; border: 0; border-radius: var(--rs-control-radius); background: transparent; color: var(--rs-text); text-align: left; font: inherit; }
|
|
.source-title { display: flex; align-items: center; gap: 6px; color: var(--rs-link); }
|
|
.source-title > span:first-of-type { min-width: 0; overflow-wrap: anywhere; }
|
|
.line { margin-left: auto; color: var(--rs-text-dim); font-variant-numeric: tabular-nums; }
|
|
.excerpt { display: -webkit-box; line-clamp: 2; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; font-size: 12px; overflow-wrap: anywhere; }
|
|
.toggle:hover, .source:hover { background: var(--rs-hover-bg); }
|
|
.toggle:focus-visible, .source:focus-visible { outline: 2px solid var(--rs-focus); outline-offset: -2px; }
|
|
.placeholder, .error { margin: 8px 12px; font-size: 12px; overflow-wrap: anywhere; }
|
|
.placeholder { color: var(--rs-text-dim); }
|
|
.error { color: var(--rs-error); }
|
|
</style>
|