diff --git a/dashboard/web/components/Copy.css b/dashboard/web/components/Copy.css new file mode 100644 index 0000000000000000000000000000000000000000..4187cf5c79bd09ba2c9028ae5c7286ff578e2a23 --- /dev/null +++ b/dashboard/web/components/Copy.css @@ -0,0 +1,25 @@ +.copy-field > .copy, .copy-field.masked { + display: flex; + align-items: center; + gap: 10px; + width: 100%; + min-height: 34px; + padding: 6px 10px; + border: 2px solid var(--line); + border-radius: var(--radius); + background: var(--well); + color: var(--text); + font: 12.5px/1.45 var(--mono); + text-align: left; + white-space: normal; + cursor: copy; + transition: border-color 150ms, background-color 150ms; +} +.copy-field { flex: 1; min-width: 0; } +.copy-field .value { flex: 1; min-width: 0; overflow-wrap: anywhere; } +.copy-field .icon { flex: none; color: var(--muted); transition: color 150ms; } +.copy-field > .copy:hover { border-color: var(--axis); background: var(--accent-wash); } +.copy-field > .copy:hover .icon { color: var(--accent); } +.copy-field.masked { box-sizing: border-box; cursor: default; color: var(--muted); letter-spacing: 0.1em; overflow: hidden; } +.copy-field.masked .value { overflow-wrap: normal; white-space: nowrap; } + diff --git a/dashboard/web/components/Copy.tsx b/dashboard/web/components/Copy.tsx index 06db34cd813557c7d19e40341cc539a6c75750fa..03daf3c18a58bc5a277e88fc29a7c5e69b500d67 100644 --- a/dashboard/web/components/Copy.tsx +++ b/dashboard/web/components/Copy.tsx @@ -1,4 +1,10 @@ import { createSignal, type JSX } from "solid-js"; +import CopyIcon from "lucide-solid/icons/copy"; +import "./Copy.css"; + +export function CopyField(props: { value: string; label: string }) { + return
{props.value}
; +} /** * Text that copies `value` on click; the tooltip turns into the result. Shows `value` unless given children, and @@ -12,7 +18,7 @@ export function Copy(props: { value: string; label?: string; children?: JSX.Elem .then(() => setResult("copied"), () => setResult("Couldn't copy. Select the text instead")); return ( <> - diff --git a/dashboard/web/components/VMMenu.tsx b/dashboard/web/components/VMMenu.tsx index 86c193ac53569484936cce0b51619adbb8a665c7..9c293a51f37568a3070b1d83a15ad3c57dea4f9c 100644 --- a/dashboard/web/components/VMMenu.tsx +++ b/dashboard/web/components/VMMenu.tsx @@ -1,14 +1,14 @@ import { type JSX, onCleanup, onMount } from "solid-js"; import ChevronDown from "lucide-solid/icons/chevron-down"; -export function VMMenu(props: { label: string; children: JSX.Element }) { +export function VMMenu(props: { label: string; children: JSX.Element; onClose?: () => void }) { let menu!: HTMLDetailsElement; const outside = (event: PointerEvent) => { if (event.target instanceof Node && !menu.contains(event.target)) menu.open = false; }; onMount(() => document.addEventListener("pointerdown", outside)); onCleanup(() => document.removeEventListener("pointerdown", outside)); - return
{ + return
{ if (!menu.open) props.onClose?.(); }} onKeyDown={(event) => { if (event.key === "Escape") { menu.open = false; menu.querySelector("summary")?.focus(); @@ -17,7 +17,8 @@ export function VMMenu(props: { label: string; children: JSX.Element }) { }}> {props.label}
{ - if (event.target instanceof HTMLElement && event.target.closest("button")) menu.open = false; + const button = event.target instanceof Element ? event.target.closest("button") : null; + if (button?.parentElement === event.currentTarget) menu.open = false; }}>{props.children}
; } diff --git a/dashboard/web/pages/AI.tsx b/dashboard/web/pages/AI.tsx index 81f1d082f522645232e65c78e0d7cae5eda49564..310d4d3ba2ec52a02f902c6bf5a14fccca1cd364 100644 --- a/dashboard/web/pages/AI.tsx +++ b/dashboard/web/pages/AI.tsx @@ -1,19 +1,14 @@ import { parseResponse } from "hono/client"; -import CopyIcon from "lucide-solid/icons/copy"; import Download from "lucide-solid/icons/download"; import EyeOff from "lucide-solid/icons/eye-off"; import KeyRound from "lucide-solid/icons/key-round"; import { createResource, createSignal, For, Show } from "solid-js"; import { api, reason } from "../api.ts"; -import { Copy } from "../components/Copy.tsx"; +import { CopyField } from "../components/Copy.tsx"; import { Loaded } from "../components/Loaded.tsx"; import claude from "../../src/claude.svg?raw"; import openai from "../../src/openai.svg?raw"; -export function CopyField(props: { value: string; label: string }) { - return
{props.value}
; -} - export function ClientMark(props: { name: string }) { const logo = () => /claude/i.test(props.name) ? claude : /codex|openai|chatgpt/i.test(props.name) ? openai : ""; return