Add interface languages and improve themes and workspace controls for 0.1.36
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { untrack } from "svelte";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import { attachTooltip } from "$lib/ui/tooltip";
|
||||
import ContextMenu from "$lib/layout/ContextMenu.svelte";
|
||||
import type { MenuItem } from "$lib/layout/menuTypes";
|
||||
import { installedPlugins, pluginTools, pluginNavigation, openPluginView, runPluginCommand } from "./external";
|
||||
@@ -9,7 +11,8 @@
|
||||
let position = $state<{ x: number; y: number } | null>(null);
|
||||
let error = $state("");
|
||||
let pointerWasOpen = false;
|
||||
const label = $derived(surface === "open" ? "Plug-in views" : "Commands");
|
||||
const label = $derived(surface === "open" ? $t("Plug-in views") : $t("Commands"));
|
||||
function tooltip(node: HTMLElement) { return { destroy: attachTooltip(node, () => compact ? label : "") }; }
|
||||
const tools = $derived($pluginTools.filter(tool => tool.surface === surface
|
||||
&& tool.owner !== "runestone.browser"
|
||||
&& !(surface === "open" && tool.kind === "view" && $pluginNavigation.some(item => item.owner === tool.owner && item.id === tool.id && item.placement === "sidebar"))));
|
||||
@@ -27,22 +30,19 @@
|
||||
</script>
|
||||
|
||||
{#if tools.length}
|
||||
<button class="access-button" class:compact bind:this={anchor} aria-label={label} aria-haspopup="menu" aria-expanded={position !== null} title={label}
|
||||
<button class="access-button" class:compact bind:this={anchor} use:tooltip aria-label={label} aria-haspopup="menu" aria-expanded={position !== null}
|
||||
onpointerdown={() => pointerWasOpen = position !== null}
|
||||
onclick={event => { const close = event.detail > 0 ? pointerWasOpen : position !== null; const bounds = anchor!.getBoundingClientRect(); position = close ? null : { x: bounds.left, y: bounds.bottom + 4 }; }}>
|
||||
<Icon icon={surface === "open" ? "puzzle" : "code"} />{#if !compact}<span>{label}</span>{/if}
|
||||
{#if compact}<span class="access-tooltip" role="tooltip">{label}</span>{/if}
|
||||
</button>
|
||||
{/if}
|
||||
{#if position && tools.length}<ContextMenu {...position} {items} {label} onClose={() => position = null} />{/if}
|
||||
{#if error}<p class="error" role="alert">{error}<button onclick={() => error = ""}>Dismiss</button></p>{/if}
|
||||
{#if error}<p class="error" role="alert">{error}<button onclick={() => error = ""}>{$t("Dismiss")}</button></p>{/if}
|
||||
|
||||
<style>
|
||||
.access-button { display: flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 32px; padding: 5px 8px; border: 0; border-radius: var(--rs-control-radius); background: transparent; color: var(--rs-text); }
|
||||
.access-button:hover, .access-button[aria-expanded="true"] { background: var(--rs-bg-active); }
|
||||
.access-button:focus-visible { outline: 2px solid var(--rs-accent); outline-offset: -2px; }
|
||||
.access-button.compact { position: relative; width: 28px; height: 28px; min-height: 28px; padding: 5px; }
|
||||
.access-tooltip { display: none; position: absolute; top: calc(100% + 6px); right: 0; padding: 5px 8px; border-radius: var(--rs-control-radius); background: var(--rs-bg-elevated); border: 1px solid var(--rs-border); z-index: 60; pointer-events: none; }
|
||||
.access-button:is(:hover, :focus-visible) .access-tooltip { display: block; }
|
||||
.error { position: fixed; top: 48px; right: 12px; z-index: 60; max-width: 420px; padding: 12px; background: var(--rs-bg); color: var(--rs-error); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user