Skip to content

refactor(core): centralize dock layout tunables into constants#401

Merged
antfu merged 3 commits into
mainfrom
feat/dock-layout-constants
Jul 13, 2026
Merged

refactor(core): centralize dock layout tunables into constants#401
antfu merged 3 commits into
mainfrom
feat/dock-layout-constants

Conversation

@antfubot

@antfubot antfubot commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

What

Makes the floating dock bar's (Dock.vue) padding, margin, sizing, positioning, snapping and its overlap with the panel/iframe all driven by a single, documented list of constants instead of magic numbers scattered across the template, script and stylesheet.

New module — components/dock/dock-layout.ts

A DockLayout interface + DEFAULT_DOCK_LAYOUT collects every spatial tunable:

  • barHeight, barMinWidth, minimizedSize — bar dimensions
  • glowSize, glowBlur — ambient glow
  • maxVisibleItems — inline item capacity before overflow
  • viewportMargin — gap between the bar/panel and the viewport edge
  • panelOverlapFactor — how much of the dock bar's thickness overlaps the panel/iframe (0.5 = the previous "half" behaviour; lower slides the panel clear of the bar so the content underneath stays readable)
  • edgeSnapPercent, centerSnapPercent, edgeZoneHeight — drag snapping / edge detection

Alongside pure helpers extracted from the previously-inline logic: resolveDockLayout, dockLayoutCssVars, resolveViewportMargins, snapDockPercent, resolveDockEdge, and resolveDockAnchor.

Component changes

  • Dock.vue — consumes the constants/helpers; gains an optional layout?: Partial<DockLayout> prop; bar dimensions flow out as CSS custom properties. The drag/anchor logic collapses from ~60 lines of inline trig + switch statements into helper calls.
  • DockPanel.vue — shares resolveDockAnchor (previously duplicated verbatim), and applies panelOverlapFactor: the panel's docked edge, previously pinned to the dock's center (a fixed 50% overlap via /2), is now offset by dockThickness * (0.5 - factor), with the size cap adjusted so the far edge stays put.
  • DockEmbedded.vue — optional layout prop forwarded to the float-mode bar + panel.
  • style.css — dimension utilities swapped for var(--vite-devtools-dock-*, fallback) so they track the constants. .generated/css.ts is the regenerated bundle.

Storybook

Dock.stories.ts story args now are the DockLayout — every tunable is a live range control. Added cases: TallBar, CompactBar, RoomyViewportMargin, LowerCapacity, HigherCapacity, LargeGlow. DockEmbedded.stories.ts adds FloatReducedOverlap (panelOverlapFactor: 0.2) to show the reduced dock↔iframe overlap next to the default FloatOpen.

Verification

pnpm build, pnpm typecheck, pnpm test (200 passing), pnpm lint, and storybook build all pass. Defaults match the previous hardcoded values, so there is no behaviour change out of the box; the overlap reduction was also verified visually in Storybook.


This PR was created with the help of an agent.

Extract the floating dock bar's spatial magic numbers (bar height, item
capacity, viewport margin, glow, drag snapping, edge detection) into a
single documented DockLayout module, and derive the bar dimensions from
CSS custom properties. Reuse the shared anchor-position helper across
Dock and DockPanel, and expose every tunable as a live Storybook control.
@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vitejs/devtools@401
npm i https://pkg.pr.new/@vitejs/devtools-kit@401
npm i https://pkg.pr.new/@vitejs/devtools-rolldown@401

commit: c81a487

antfubot and others added 2 commits July 13, 2026 05:43
Add a `panelOverlapFactor` layout constant (default 0.5, matching the
previous behaviour) controlling how much of the dock bar's thickness
overlaps the panel. Lowering it slides the panel clear of the bar so the
iframe underneath stays readable. Threaded through DockEmbedded → Dock →
DockPanel, with Storybook coverage.
@antfu antfu merged commit c6864c6 into main Jul 13, 2026
8 checks passed
@antfu antfu deleted the feat/dock-layout-constants branch July 13, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants