mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-17 15:24:19 +00:00
feat(studio): panel tabs read as one designed control
Dockview's tab strip uses one pill treatment, with a reserved close target and colours only from theme tokens. A paper host overrides those same token names.
This commit is contained in:
@@ -2,15 +2,16 @@
|
||||
|
||||
.hf-dock {
|
||||
--dv-group-view-background-color: var(--color-panel-bg);
|
||||
--dv-tabs-and-actions-container-background-color: var(--color-panel-surface);
|
||||
--dv-activegroup-visiblepanel-tab-background-color: var(--color-panel-bg);
|
||||
--dv-activegroup-hiddenpanel-tab-background-color: var(--color-panel-surface);
|
||||
--dv-inactivegroup-visiblepanel-tab-background-color: var(--color-panel-bg);
|
||||
--dv-inactivegroup-hiddenpanel-tab-background-color: var(--color-panel-surface);
|
||||
--dv-activegroup-visiblepanel-tab-color: var(--color-panel-text-1);
|
||||
--dv-activegroup-hiddenpanel-tab-color: var(--color-panel-text-3);
|
||||
--dv-tabs-and-actions-container-background-color: var(--panel-strip-bg);
|
||||
--dv-tabs-and-actions-container-height: 36px;
|
||||
--dv-activegroup-visiblepanel-tab-background-color: var(--panel-tab-bg-active);
|
||||
--dv-activegroup-hiddenpanel-tab-background-color: transparent;
|
||||
--dv-inactivegroup-visiblepanel-tab-background-color: var(--panel-tab-bg-active-muted);
|
||||
--dv-inactivegroup-hiddenpanel-tab-background-color: transparent;
|
||||
--dv-activegroup-visiblepanel-tab-color: var(--panel-tab-text-active);
|
||||
--dv-activegroup-hiddenpanel-tab-color: var(--panel-tab-text);
|
||||
--dv-inactivegroup-visiblepanel-tab-color: var(--color-panel-text-2);
|
||||
--dv-inactivegroup-hiddenpanel-tab-color: var(--color-panel-text-4);
|
||||
--dv-inactivegroup-hiddenpanel-tab-color: var(--panel-tab-text);
|
||||
--dv-tab-divider-color: var(--color-panel-border);
|
||||
--dv-separator-border: var(--color-panel-border);
|
||||
--dv-paneview-header-border-color: var(--color-panel-border);
|
||||
@@ -18,11 +19,153 @@
|
||||
--dv-active-sash-color: var(--color-panel-accent);
|
||||
--dv-drag-over-background-color: color-mix(in srgb, var(--color-panel-accent) 12%, transparent);
|
||||
--dv-drag-over-border-color: var(--color-panel-accent);
|
||||
--dv-tab-font-size: 11px;
|
||||
--dv-tabs-and-actions-container-font-size: 11px;
|
||||
--dv-tab-font-size: 12px;
|
||||
--dv-tabs-and-actions-container-font-size: 12px;
|
||||
--dv-tab-margin: 0;
|
||||
}
|
||||
|
||||
.hf-dock .dv-sash:focus-visible {
|
||||
background-color: var(--dv-active-sash-color);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.hf-dock .dv-tabs-and-actions-container {
|
||||
align-items: center;
|
||||
height: 36px;
|
||||
padding: 4px 6px;
|
||||
background-color: var(--panel-strip-bg);
|
||||
border-bottom: 1px solid var(--panel-strip-border);
|
||||
}
|
||||
|
||||
.hf-dock .dv-tabs-container {
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
/* Dockview draws a 1px rule from --dv-tab-divider-color on every tab but the
|
||||
first. The token also strokes menus, so the rule is removed here only. */
|
||||
.hf-dock .dv-tabs-container .dv-tab::before {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.hf-dock .dv-tab {
|
||||
height: 28px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.01em;
|
||||
line-height: 1;
|
||||
transition:
|
||||
background-color 120ms ease-out,
|
||||
color 120ms ease-out;
|
||||
}
|
||||
|
||||
/* A lone preview or timeline tab is a pill, not a bar stretched across the header. */
|
||||
.hf-dock .dv-tabs-and-actions-container.dv-single-tab.dv-full-width-single-tab .dv-tabs-container .dv-tab {
|
||||
flex-grow: 0;
|
||||
width: auto;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.hf-dock .dv-tab:has(.dv-default-tab-action) {
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
.hf-dock .dv-groupview.dv-active-group > .dv-tabs-and-actions-container .dv-tabs-container > .dv-tab.dv-inactive-tab:hover,
|
||||
.hf-dock .dv-groupview.dv-inactive-group > .dv-tabs-and-actions-container .dv-tabs-container > .dv-tab.dv-inactive-tab:hover {
|
||||
background-color: var(--panel-tab-bg-hover);
|
||||
color: var(--color-panel-text-2);
|
||||
}
|
||||
|
||||
.hf-dock .dv-groupview.dv-active-group > .dv-tabs-and-actions-container .dv-tabs-container > .dv-tab.dv-active-tab {
|
||||
background-image: linear-gradient(var(--panel-tab-indicator), var(--panel-tab-indicator));
|
||||
background-repeat: no-repeat;
|
||||
background-position: center bottom;
|
||||
background-size: 16px 2px;
|
||||
}
|
||||
|
||||
.hf-dock .dv-groupview.dv-inactive-group > .dv-tabs-and-actions-container .dv-tabs-container > .dv-tab.dv-active-tab {
|
||||
background-image: linear-gradient(
|
||||
color-mix(in srgb, var(--panel-tab-indicator) 50%, transparent),
|
||||
color-mix(in srgb, var(--panel-tab-indicator) 50%, transparent)
|
||||
);
|
||||
background-repeat: no-repeat;
|
||||
background-position: center bottom;
|
||||
background-size: 16px 2px;
|
||||
}
|
||||
|
||||
/* Dockview's own focus ring is `outline: 1px solid var(--dv-tab-divider-color) !important`. */
|
||||
.hf-dock .dv-tab:focus-visible::after,
|
||||
.hf-dock .dv-tab:has(:focus-visible)::after {
|
||||
outline: 1.5px solid var(--panel-tab-ring) !important;
|
||||
outline-offset: -1.5px;
|
||||
}
|
||||
|
||||
.hf-dock .dv-tab .dv-default-tab {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.hf-dock .dv-tab .dv-default-tab .dv-default-tab-content {
|
||||
flex-grow: 0;
|
||||
min-width: 0;
|
||||
max-width: 140px;
|
||||
margin-right: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.hf-dock .dv-tab .dv-default-tab .dv-default-tab-action {
|
||||
position: relative;
|
||||
visibility: visible;
|
||||
opacity: 0;
|
||||
flex: 0 0 20px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.hf-dock .dv-tab:hover .dv-default-tab .dv-default-tab-action,
|
||||
.hf-dock .dv-tab:focus-within .dv-default-tab .dv-default-tab-action,
|
||||
.hf-dock .dv-tab.dv-active-tab .dv-default-tab .dv-default-tab-action {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.hf-dock .dv-tab .dv-default-tab .dv-default-tab-action:hover {
|
||||
opacity: 1;
|
||||
border-radius: 6px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
@media (hover: none) {
|
||||
.hf-dock .dv-tab .dv-default-tab .dv-default-tab-action {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
/* Filled 11px glyph, replaced by a 12px stroke centered in the 20px target. */
|
||||
.hf-dock .dv-default-tab-action .dv-svg {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hf-dock .dv-default-tab-action::before,
|
||||
.hf-dock .dv-default-tab-action::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 4px;
|
||||
top: 9.25px;
|
||||
width: 12px;
|
||||
height: 1.5px;
|
||||
border-radius: 1px;
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
.hf-dock .dv-default-tab-action::before {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.hf-dock .dv-default-tab-action::after {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
@@ -163,4 +163,21 @@ describe("dock tab strips", () => {
|
||||
press(tabs[3] as HTMLElement, "Home");
|
||||
expect(api.getPanel("design")?.group.activePanel?.id).toBe("design");
|
||||
});
|
||||
|
||||
it("names each closable tab's close control after that panel", () => {
|
||||
const tabs = tabsOf("design");
|
||||
const labels = tabs.map((tab) =>
|
||||
tab.querySelector(".dv-default-tab-action")?.getAttribute("aria-label"),
|
||||
);
|
||||
expect(labels).toEqual(["Close Design", "Close Layers", "Close Renders", "Close Variables"]);
|
||||
expect(tabs[0]?.getAttribute("aria-selected")).toBe("true");
|
||||
});
|
||||
|
||||
it("renames the close control when the panel title changes", () => {
|
||||
api.getPanel("renders")?.api.setTitle("Renders (2)");
|
||||
const renders = tabsOf("design").find((tab) => tab.dataset.tabPanelId === "renders");
|
||||
expect(renders?.querySelector(".dv-default-tab-action")?.getAttribute("aria-label")).toBe(
|
||||
"Close Renders (2)",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -74,16 +74,49 @@ function onTabKeyDown(event: KeyboardEvent, tab: HTMLElement, api: DockviewApi)
|
||||
target.focus();
|
||||
}
|
||||
|
||||
/** Dockview's default close control says "Close tab". Name the panel. */
|
||||
function labelCloseButtons(root: HTMLElement) {
|
||||
for (const button of root.querySelectorAll<HTMLButtonElement>(".dv-default-tab-action")) {
|
||||
const title = button
|
||||
.closest(".dv-default-tab")
|
||||
?.querySelector(".dv-default-tab-content")
|
||||
?.textContent?.trim();
|
||||
if (!title) continue;
|
||||
const label = `Close ${title}`;
|
||||
if (button.getAttribute("aria-label") !== label) button.setAttribute("aria-label", label);
|
||||
}
|
||||
}
|
||||
|
||||
/** Keyboard and ARIA support dockview 8.3 lacks for sashes and tab arrows. Returns a disposer. */
|
||||
export function installDockAccessibility(api: DockviewApi, root: HTMLElement): () => void {
|
||||
const decorate = () => decorateSashes(root);
|
||||
decorate();
|
||||
const titleDisposers = new Map<string, { dispose: () => void }>();
|
||||
const watchTitles = () => {
|
||||
const live = new Set(api.panels.map((panel) => panel.id));
|
||||
for (const [id, disposer] of titleDisposers) {
|
||||
if (live.has(id)) continue;
|
||||
disposer.dispose();
|
||||
titleDisposers.delete(id);
|
||||
}
|
||||
for (const panel of api.panels) {
|
||||
if (titleDisposers.has(panel.id)) continue;
|
||||
titleDisposers.set(
|
||||
panel.id,
|
||||
panel.api.onDidTitleChange(() => labelCloseButtons(root)),
|
||||
);
|
||||
}
|
||||
};
|
||||
const decorate = () => {
|
||||
decorateSashes(root);
|
||||
labelCloseButtons(root);
|
||||
watchTitles();
|
||||
};
|
||||
const subscriptions = [
|
||||
api.onDidLayoutChange(decorate),
|
||||
api.onDidLayoutFromJSON(decorate),
|
||||
api.onDidAddPanel(decorate),
|
||||
api.onDidRemovePanel(decorate),
|
||||
];
|
||||
decorate();
|
||||
// Capture phase so the tab handler runs before dockview's own focus-only arrows.
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (!(event.target instanceof HTMLElement)) return;
|
||||
@@ -94,5 +127,7 @@ export function installDockAccessibility(api: DockviewApi, root: HTMLElement): (
|
||||
return () => {
|
||||
root.removeEventListener("keydown", onKeyDown, true);
|
||||
for (const subscription of subscriptions) subscription.dispose();
|
||||
for (const disposer of titleDisposers.values()) disposer.dispose();
|
||||
titleDisposers.clear();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const dockCss = readFileSync(path.join(import.meta.dirname, "dock.css"), "utf8");
|
||||
const themeCss = readFileSync(path.join(import.meta.dirname, "../../styles/theme.css"), "utf8");
|
||||
|
||||
describe("panel tab contract", () => {
|
||||
it("paints selection, hover and focus from the panel-tab tokens", () => {
|
||||
expect(dockCss).toContain(
|
||||
"--dv-activegroup-visiblepanel-tab-background-color: var(--panel-tab-bg-active)",
|
||||
);
|
||||
expect(dockCss).toContain("background-color: var(--panel-tab-bg-hover)");
|
||||
expect(dockCss).toContain("outline: 1.5px solid var(--panel-tab-ring)");
|
||||
expect(dockCss).toContain("background-size: 16px 2px");
|
||||
expect(dockCss).not.toMatch(/#[0-9a-f]{3,8}|rgba?\(/i);
|
||||
});
|
||||
|
||||
it("keeps one dark value per tab token and documents the paper host override", () => {
|
||||
expect(themeCss).toContain("--panel-tab-bg-active: rgba(255, 255, 255, 0.08)");
|
||||
expect(themeCss).toContain("--panel-tab-bg-active-muted: rgba(255, 255, 255, 0.04)");
|
||||
expect(themeCss).toContain("active rgba(0, 0, 0, 0.06)");
|
||||
expect(themeCss).toContain("hover rgba(0, 0, 0, 0.035)");
|
||||
expect(themeCss).not.toContain("[data-theme");
|
||||
expect(themeCss).not.toContain("[data-chrome");
|
||||
});
|
||||
});
|
||||
@@ -248,6 +248,19 @@
|
||||
--color-panel-media: var(--color-media);
|
||||
--color-panel-container: var(--color-container);
|
||||
|
||||
/* panel tabs. Dark values. A paper host overrides these same names:
|
||||
strip #f5f5f4, border #18181b14, active rgba(0, 0, 0, 0.06),
|
||||
muted rgba(0, 0, 0, 0.03), hover rgba(0, 0, 0, 0.035), text #18181b / #71717a. */
|
||||
--panel-strip-bg: var(--color-panel-surface);
|
||||
--panel-strip-border: var(--color-panel-border);
|
||||
--panel-tab-bg-active: rgba(255, 255, 255, 0.08);
|
||||
--panel-tab-bg-active-muted: rgba(255, 255, 255, 0.04);
|
||||
--panel-tab-bg-hover: rgba(255, 255, 255, 0.04);
|
||||
--panel-tab-text-active: var(--color-text-1);
|
||||
--panel-tab-text: var(--color-text-3);
|
||||
--panel-tab-indicator: var(--color-accent);
|
||||
--panel-tab-ring: var(--color-accent);
|
||||
|
||||
/* Names Studio's markup invented that no config ever defined, so the classes
|
||||
* compiled to nothing. Aliased to the token that was meant, rather than
|
||||
* given values of their own, so there is still one source per decision.
|
||||
|
||||
Reference in New Issue
Block a user