Skip to content

AI-native design editor. Open-source Figma alternative.

refactor(app): consolidate property panel primitives

Danila Poyarkovdabeb3e92cdd
diff --git a/packages/docs/development/ui-parity-plan.md b/packages/docs/development/ui-parity-plan.md
new file mode 100644
index 000000000..09534af1b
--- /dev/null
+++ b/packages/docs/development/ui-parity-plan.md
@@ -0,0 +1,298 @@
+# UI parity and hardening plan
+
+OpenPencil's headless editor architecture is moving in the right direction: the Vue SDK exposes renderless primitives and composables, while the app shell owns product-specific presentation. The current app UI is still MVP-grade. This plan turns the existing shell into a Figma-grade, maintainable interface without weakening the headless SDK boundary.
+
+## Goals
+
+- Preserve the headless SDK model: controls and editor logic live in `packages/vue/src/**`; the app shell renders opinionated OpenPencil UI in `src/components/**`.
+- Replace ad-hoc panel markup with reusable UI primitives so future feature work is fast and consistent.
+- Make large documents feel production-grade, especially the Layers panel.
+- Close high-impact Figma panel gaps: mixed values, constraints, stroke caps/joins, corner smoothing, shared styles, component properties, and richer typography.
+- Add guardrails so UI quality does not regress.
+
+## Current assessment
+
+### Strong foundation
+
+- `packages/vue/src/primitives/**` already follows a useful renderless-root pattern similar to Reka UI.
+- `packages/vue/src/controls/**` keeps much property editing logic outside app components.
+- App components use `data-test-id` consistently enough to support reliable regression tests.
+- The menu and command registry direction is healthy and should remain the canonical source for shortcuts and command behavior.
+
+### Main gaps
+
+- `src/components/ui/**` is mostly class factories, not a complete UI kit. App sections repeatedly hand-build icon buttons, panel rows, toggle groups, and section headers.
+- Several templates call `use*UI()` helpers inline, which recomputes variants during render and spreads design-system knowledge into many files.
+- Some components still use raw inline SVG icons, which creates inconsistent visual language and violates the project convention.
+- `PropertyListRoot` erases item types, causing casts and non-null assertions in property sections.
+- `LayerTreeRoot` rebuilds and remounts the whole tree on every scene mutation via `sceneVersion` and `treeKey`, which will not scale to real `.fig` documents.
+- Multi-select mixed values are not a first-class editing state across the panel.
+- Important Figma-like controls are missing or incomplete in the UI even when the scene graph or renderer already supports the data.
+
+## Phase 1: Build the panel UI kit
+
+**Purpose:** Create shared components for the repeated panel patterns before adding new features.
+
+### Files to add or refactor
+
+- `src/components/ui/IconButton.vue`
+- `src/components/ui/SegmentedControl.vue`
+- `src/components/ui/PanelSection.vue`
+- `src/components/ui/PanelRow.vue`
+- `src/components/ui/panel.ts` for slot variants and shared panel class composition
+- Optional icon namespace under `src/components/icons/` or an Iconify custom collection for OpenPencil-specific micro-icons
+
+### Work items
+
+1. Add `IconButton.vue` that owns tooltip wrapping, icon rendering, size variants, pressed/active state, disabled state, and test-id forwarding.
+2. Add `SegmentedControl.vue` for small enumerations currently rendered as repeated toggle buttons or dropdowns.
+3. Add `PanelSection.vue` for the standard section wrapper, label, optional add button, optional collapse toggle, and action slot.
+4. Add `PanelRow.vue` for fixed-density property rows and common two-column input layout.
+5. Replace repeated button markup in:
+ - `src/components/properties/PositionSection.vue`
+ - `src/components/properties/StrokeSection.vue`
+ - `src/components/properties/EffectsSection.vue`
+ - `src/components/properties/ExportSection.vue`
+ - `src/components/properties/FillSection.vue`
+ - `src/components/properties/AppearanceSection.vue`
+ - `src/components/AssetsPanel.vue`
+ - `src/components/AppMenu.vue`
+6. Replace raw inline SVGs in app templates with icon components.
+7. Hoist all `use*UI()` calls out of templates into `<script setup>` constants/computed values, or hide them inside the new UI components.
+
+### Acceptance criteria
+
+- `rg 'use\w+UI\(' src/components --glob '*.vue'` has no matches inside template blocks.
+- `rg '<svg' src/components --glob '*.vue'` returns zero, except for explicitly approved third-party content rendering.
+- Position, Stroke, Effects, Export, Fill, and Appearance sections use `PanelSection` and `PanelRow`.
+- Toggle-button visual states are implemented once through `SegmentedControl` or `IconButton` variants.
+
+## Phase 2: Fix typed property-list boundaries
+
+**Purpose:** Remove template casts and non-null assertions by making renderless primitives expose precise slot types.
+
+### Files to refactor
+
+- `packages/vue/src/primitives/PropertyList/PropertyListRoot.vue`
+- `packages/vue/src/primitives/PropertyList/context.ts`
+- `packages/vue/src/controls/stroke/helpers.ts`
+- `src/components/properties/StrokeSection.vue`
+- `src/components/properties/EffectsSection.vue`
+- `src/components/properties/FillSection.vue`
+- `src/components/properties/LayoutSection/SizeControls.vue`
+
+### Work items
+
+1. Make `PropertyListRoot` generic over the array prop key (`fills`, `strokes`, `effects`) so slot props expose `Fill[]`, `Stroke[]`, or `Effect[]` exactly.
+2. Use `defineSlots` to document the slot contract and preserve type information in consuming templates.
+3. Change the slot shape so consumers do not need `activeNode!`; provide guarded actions or null-safe helpers instead.
+4. Move stroke dash-pattern and independent-side logic from `StrokeSection.vue` into `packages/vue/src/controls/stroke/helpers.ts`.
+5. Replace fake node casts with explicit helper functions that operate on real nodes and return typed patches.
+
+### Acceptance criteria
+
+- `rg 'as Stroke|as Fill|as Effect|as unknown|activeNode!' src/components --glob '*.vue'` returns zero.
+- `StrokeSection.vue` becomes mostly markup and delegates stroke-specific mutations to SDK helpers.
+- `bun run check` passes.
+
+## Phase 3: Rewrite the Layers panel for scale
+
+**Purpose:** Make the Layers panel usable on large imported Figma documents.
+
+### Files to refactor
+
+- `packages/vue/src/primitives/LayerTree/LayerTreeRoot.vue`
+- `packages/vue/src/primitives/LayerTree/LayerTreeItem.vue`
+- `packages/vue/src/primitives/LayerTree/context.ts`
+- `packages/vue/src/primitives/LayerTree/useLayerDrag.ts`
+- `src/components/LayerTree.vue`
+- New app namespace: `src/components/LayerTree/LayerRow.vue`, `LayerRowRename.vue`, `LayerRowActions.vue`, `DropIndicator.vue`
+
+### Work items
+
+1. Replace the recursive tree object with a flat visible-row model derived from the current page and expanded state.
+2. Remove `treeKey` remounting. Tree state must survive node edits, scroll, rename focus, and dragging.
+3. Subscribe to editor lifecycle events instead of watching only `sceneVersion`:
+ - `node:created`
+ - `node:updated`
+ - `node:deleted`
+ - `node:reparented`
+ - `node:reordered`
+ - `page:changed`
+ - `selection:changed`
+4. Patch rows incrementally for name, visibility, lock, and type changes. Rebuild the flat visible list only for structural changes and expansion changes.
+5. Add virtualization over the flat row list. Use fixed row height and keep selection scroll-to behavior by index rather than by per-row DOM refs.
+6. Split the 200+ line app template into row subcomponents.
+7. Add range selection with Shift and preserve additive selection with Cmd/Ctrl.
+8. Add focused and unfocused selected-row visual states.
+
+### Acceptance criteria
+
+- Scrubbing a selected node's X/Y/W/H no longer remounts the Layers tree.
+- Scroll position and rename focus survive unrelated scene updates.
+- A 5,000-node document remains responsive while editing properties.
+- Add tests under `tests/engine/vue/` for visible-row derivation and under `tests/e2e/perf/` for large-tree interaction.
+
+## Phase 4: Make mixed values first-class
+
+**Purpose:** Multi-select editing should behave like Figma, not like first-node editing.
+
+### Files to refactor
+
+- `packages/vue/src/controls/node-props/helpers.ts`
+- `packages/vue/src/controls/prop-scrub/use.ts`
+- `packages/vue/src/primitives/ScrubInput/**`
+- Every property section under `src/components/properties/**`
+
+### Work items
+
+1. Promote the existing `MIXED` symbol into a public SDK concept for control roots.
+2. Make `ScrubInputRoot` and the app `ScrubInput.vue` display a mixed placeholder and commit typed input to all selected nodes.
+3. Add mixed display semantics to color rows, selects, segmented controls, toggles, and variable-bound inputs.
+4. Ensure each panel section distinguishes:
+ - inactive/not applicable
+ - empty list
+ - mixed value
+ - explicit value
+5. Add e2e coverage for multi-select editing: position, fill, stroke, opacity, typography, effects, and layout.
+
+### Acceptance criteria
+
+- Multi-select no longer silently displays the first selected node's value as if it applied to all nodes.
+- A mixed field shows a clear mixed placeholder and a first edit applies uniformly to all selected nodes.
+- Mixed array props (`fills`, `strokes`, `effects`) show clear add/replace behavior.
+
+## Phase 5: Close high-impact Figma panel gaps
+
+Each item should be implemented as SDK logic plus app presentation. Do not put durable editing logic directly in app components.
+
+### 5.1 Constraints
+
+- Add `packages/vue/src/controls/constraints/use.ts`.
+- Add `packages/vue/src/primitives/ConstraintsControl/`.
+- Add `src/components/properties/ConstraintsSection.vue`.
+- Use a Figma-style pin/grid control plus horizontal and vertical mode selectors.
+
+### 5.2 Stroke caps, joins, and miter limit
+
+- Extend `packages/vue/src/controls/stroke/**`.
+- Extend `src/components/properties/StrokeSection.vue`.
+- Use segmented controls for cap and join modes; use a scrub input for miter limit.
+
+### 5.3 Corner smoothing and independent corners
+
+- Extend `packages/vue/src/controls/appearance/**`.
+- Extend `src/components/properties/AppearanceSection.vue`.
+- Add smoothing control and independent-corner presentation that does not depend on inline SVGs.
+
+### 5.4 Shared styles
+
+- Add or expose core model support for fill, stroke, text, effect, and grid style identifiers.
+- Add SDK controls for style binding/unbinding.
+- Add app UI in Fill, Stroke, Typography, Effects, and future Layout Grid sections.
+- Preserve Figma style IDs on import/export where safe.
+
+### 5.5 Component properties
+
+- Add `packages/vue/src/controls/component-props/use.ts`.
+- Add `src/components/properties/ComponentPropsSection.vue`.
+- Expose text, boolean, variant, and instance-swap properties when available.
+
+### 5.6 Blend modes and effect styles
+
+- Extend Fill and Effects sections with blend-mode pickers.
+- Add effect style binding once shared styles exist.
+
+### 5.7 Typography depth
+
+- Extend Typography controls for text case, vertical alignment, justification, truncation/max lines, and OpenType/font variation fields where supported by the scene graph and renderer.
+
+### Acceptance criteria
+
+- Each new capability has SDK control tests and at least one app e2e test.
+- New sections are renderless-friendly: third-party shells can use the SDK logic without OpenPencil app components.
+
+## Phase 6: Polish interaction and density
+
+**Purpose:** Make the panels feel precise and Figma-like.
+
+### Work items
+
+1. Standardize panel density:
+ - 28px control rows
+ - consistent section padding
+ - consistent 4px/8px row gaps
+ - strict two-column input rhythm for paired numeric fields
+2. Extend `src/app.css` theme tokens:
+ - selected row background
+ - selected row unfocused background
+ - panel secondary background
+ - subtle border/focus tokens
+ - warning/success/action states for both dark and light themes
+3. Extend scrub input interactions:
+ - Shift-drag for coarse increments
+ - modifier-drag for fine increments
+ - ArrowUp/ArrowDown increments
+ - math expression commit if a safe dependency or parser is selected deliberately
+4. Add consistent focus rings and keyboard navigation for panel fields, segmented controls, and layer rows.
+5. Audit empty, disabled, and not-applicable states for all property sections.
+6. Align toolbar flyout grouping with design-tool expectations: selection/move tools, frame/section tools, shape tools, drawing tools, text/comment/resource tools.
+
+### Acceptance criteria
+
+- Panel screenshot tests cover single rectangle, text selection, multi-select, instance selection, empty canvas, and layer tree with nested groups.
+- Keyboard-only panel navigation works for the main property sections.
+- No one-off raw Tailwind control rows remain outside the shared panel primitives unless explicitly justified.
+
+## Phase 7: Testing and guardrails
+
+### Tests to add
+
+- `tests/e2e/panels/visual.spec.ts` for DOM screenshots of panels.
+- `tests/e2e/properties/mixed-values.spec.ts`.
+- `tests/e2e/layers/large-tree.spec.ts` or `tests/e2e/perf/layers.spec.ts`.
+- `tests/engine/vue/layer-tree.test.ts` for flat visible-row derivation.
+- SDK-level tests for each new control under existing engine/vue coverage patterns.
+
+### Static checks to add
+
+- No `use*UI()` calls inside Vue templates.
+- No raw `<svg>` inside app templates unless the file is explicitly allowlisted.
+- No `as Stroke`, `as Fill`, `as Effect`, or non-null `activeNode!` in app templates.
+- No new property-section component over 250 lines without a documented split.
+
+## Recommended sequencing
+
+1. **Phase 1:** UI kit consolidation.
+2. **Phase 2:** typed property-list boundaries.
+3. **Phase 4:** mixed values, because it affects every future section.
+4. **Phase 3:** Layers rewrite can run in parallel with 1-2 because it touches a separate surface.
+5. **Phase 5:** feature parity streams in parallel after 1, 2, and 4.
+6. **Phase 6:** density and interaction polish continuously, but final pass after 5.
+7. **Phase 7:** add guardrails as soon as Phase 1 introduces replacement patterns.
+
+## Parallel worktree split
+
+Suggested future-agent branches:
+
+- `ui-kit-foundation`: Phase 1 and related guardrails.
+- `property-list-types`: Phase 2.
+- `layers-virtualized`: Phase 3.
+- `mixed-values`: Phase 4.
+- `constraints-section`: Phase 5.1.
+- `stroke-controls-parity`: Phase 5.2.
+- `appearance-corners`: Phase 5.3.
+- `shared-styles`: Phase 5.4.
+- `component-props-panel`: Phase 5.5.
+- `typography-depth`: Phase 5.7.
+
+## Definition of done
+
+OpenPencil's UI moves out of MVP status when:
+
+- Panels are composed from shared panel primitives rather than ad-hoc markup.
+- Large layer trees are virtualized and incremental.
+- Mixed values behave predictably across multi-select.
+- The highest-impact Figma-compatible properties are editable in the UI.
+- Screenshot and static checks prevent visual and structural regression.
+- SDK controls remain reusable by custom shells, preserving the broader goal of building OpenPencil as a set of Lego-like packages for custom Figma-like editors.
diff --git a/src/components/AppToast.vue b/src/components/AppToast.vue
index b547b9f92..6c611ab6f 100644
--- a/src/components/AppToast.vue
+++ b/src/components/AppToast.vue
@@ -6,10 +6,21 @@ import { useClipboard } from '@vueuse/core'
import Tip from '@/components/ui/Tip.vue'
import { toast } from '@/app/shell/ui'
import { useToastUI } from '@/components/ui/toast'
+
+import type { ToastVariant } from '@/components/ui/toast'
import { useI18n } from '@open-pencil/vue'
const { copy, copied } = useClipboard({ copiedDuring: 1500 })
const { dialogs } = useI18n()
+const defaultToastClass = useToastUI({ tone: 'default' }).base
+const warningToastClass = useToastUI({ tone: 'warning' }).base
+const errorToastClass = useToastUI({ tone: 'error' }).base
+
+function toastClass(tone: ToastVariant) {
+ if (tone === 'error') return errorToastClass
+ if (tone === 'warning') return warningToastClass
+ return defaultToastClass
+}
</script>
<template>
@@ -19,7 +30,7 @@ const { dialogs } = useI18n()
:key="t.id"
data-test-id="toast-item"
:duration="t.variant === 'error' ? toast.ERROR_TOAST_DURATION : toast.TOAST_DURATION"
- :class="useToastUI({ tone: t.variant }).base"
+ :class="toastClass(t.variant)"
@update:open="
(open) => {
if (!open) toast.remove(t.id)
diff --git a/src/components/EditorCanvas.vue b/src/components/EditorCanvas.vue
index ed1eed2df..279e90961 100644
--- a/src/components/EditorCanvas.vue
+++ b/src/components/EditorCanvas.vue
@@ -173,19 +173,7 @@ const cursor = computed(() => toolCursor(store.state.activeTool, cursorOverride.
data-test-id="canvas-loading"
class="absolute inset-0 z-50 flex items-center justify-center bg-canvas"
>
- <svg
- class="size-8 text-surface opacity-45"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- stroke-linecap="round"
- stroke-linejoin="round"
- >
- <path
- d="m15.232 5.232 3.536 3.536m-2.036-5.036a2.5 2.5 0 0 1 3.536 3.536L6.5 21.036H3v-3.572L16.732 3.732Z"
- />
- </svg>
+ <icon-lucide-pencil-line class="size-8 text-surface opacity-45" />
<div
class="absolute bottom-1/2 left-1/2 h-0.5 w-25 -translate-x-1/2 translate-y-10 overflow-hidden rounded-full bg-surface/8"
>
diff --git a/src/components/properties/AppearanceSection.vue b/src/components/properties/AppearanceSection.vue
index 54648e962..6ebb6542d 100644
--- a/src/components/properties/AppearanceSection.vue
+++ b/src/components/properties/AppearanceSection.vue
@@ -5,9 +5,9 @@ import { useAppearance, useI18n } from '@open-pencil/vue'
import ScrubInput from '@/components/ScrubInput.vue'
import VariableScrubInput from '@/components/properties/VariableScrubInput.vue'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelSection from '@/components/ui/PanelSection.vue'
import Tip from '@/components/ui/Tip.vue'
-import { useIconButtonUI } from '@/components/ui/icon-button'
-import { useSectionUI } from '@/components/ui/section'
const { panels } = useI18n()
const {
@@ -27,7 +27,6 @@ const {
commitCornerProp
} = useAppearance()
-const sectionCls = useSectionUI()
const manualExpanded = ref<boolean | null>(null)
const showIndependentCorners = computed(() => {
@@ -49,22 +48,19 @@ function onToggleCorners() {
</script>
<template>
- <div v-if="active" data-test-id="appearance-section" :class="sectionCls.wrapper">
- <div class="mb-1.5 flex items-center justify-between">
- <label class="text-[11px] text-muted">{{ panels.appearance }}</label>
- <Tip :label="panels.toggleVisibility">
- <button
- data-test-id="appearance-visibility"
- class="flex cursor-pointer items-center justify-center rounded border-none bg-transparent p-0.5 text-muted hover:bg-hover hover:text-surface"
- :class="{ 'text-accent': visibilityState === 'hidden' }"
- @click="toggleVisibility"
- >
- <icon-lucide-eye v-if="visibilityState === 'visible'" class="size-3.5" />
- <icon-lucide-eye-off v-else-if="visibilityState === 'hidden'" class="size-3.5" />
- <icon-lucide-eye v-else class="size-3.5 opacity-50" />
- </button>
- </Tip>
- </div>
+ <PanelSection v-if="active" :label="panels.appearance" test-id="appearance-section">
+ <template #actions>
+ <IconButton
+ :label="panels.toggleVisibility"
+ :active="visibilityState === 'hidden'"
+ data-test-id="appearance-visibility"
+ @click="toggleVisibility"
+ >
+ <icon-lucide-eye v-if="visibilityState === 'visible'" class="size-3.5" />
+ <icon-lucide-eye-off v-else-if="visibilityState === 'hidden'" class="size-3.5" />
+ <icon-lucide-eye v-else class="size-3.5 opacity-50" />
+ </IconButton>
+ </template>
<div class="flex gap-1.5">
<Tip :label="panels.opacity">
@@ -128,29 +124,16 @@ function onToggleCorners() {
</ScrubInput>
</Tip>
- <Tip :label="panels.independentCornerRadii">
- <button
- data-test-id="independent-corners-toggle"
- :class="[
- useIconButtonUI({ size: 'md', ui: { base: 'size-[26px] shrink-0' } }).base,
- { '!border-accent !text-accent': showIndependentCorners }
- ]"
- @click="onToggleCorners"
- >
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <path d="M1 4V2.5A1.5 1.5 0 0 1 2.5 1H4" />
- <path d="M8 1h1.5A2.5 2.5 0 0 1 11 3.5V5" />
- <path d="M11 8v1a2 2 0 0 1-2 2H8" />
- <path d="M4 11H3a2 2 0 0 1-2-2V8" />
- </svg>
- </button>
- </Tip>
+ <IconButton
+ :label="panels.independentCornerRadii"
+ size="md"
+ class="size-[26px] shrink-0"
+ :active="showIndependentCorners"
+ data-test-id="independent-corners-toggle"
+ @click="onToggleCorners"
+ >
+ <icon-lucide-square-round-corner class="size-3" />
+ </IconButton>
</template>
</div>
@@ -161,88 +144,44 @@ function onToggleCorners() {
>
<VariableScrubInput
data-test-id="corner-tl-input"
+ label="TL"
:model-value="node.topLeftRadius"
:min="0"
:node-id="node.id"
binding-path="topLeftRadius"
@update:model-value="updateCornerProp('topLeftRadius', $event)"
@commit="(v: number, p: number) => commitCornerProp('topLeftRadius', v, p)"
- >
- <template #icon>
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <path d="M1 11V4a3 3 0 0 1 3-3h7" />
- </svg>
- </template>
- </VariableScrubInput>
+ />
<VariableScrubInput
data-test-id="corner-tr-input"
+ label="TR"
:model-value="node.topRightRadius"
:min="0"
:node-id="node.id"
binding-path="topRightRadius"
@update:model-value="updateCornerProp('topRightRadius', $event)"
@commit="(v: number, p: number) => commitCornerProp('topRightRadius', v, p)"
- >
- <template #icon>
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <path d="M11 11V4a3 3 0 0 0-3-3H1" />
- </svg>
- </template>
- </VariableScrubInput>
+ />
<VariableScrubInput
data-test-id="corner-bl-input"
+ label="BL"
:model-value="node.bottomLeftRadius"
:min="0"
:node-id="node.id"
binding-path="bottomLeftRadius"
@update:model-value="updateCornerProp('bottomLeftRadius', $event)"
@commit="(v: number, p: number) => commitCornerProp('bottomLeftRadius', v, p)"
- >
- <template #icon>
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <path d="M1 1v7a3 3 0 0 0 3 3h7" />
- </svg>
- </template>
- </VariableScrubInput>
+ />
<VariableScrubInput
data-test-id="corner-br-input"
+ label="BR"
:model-value="node.bottomRightRadius"
:min="0"
:node-id="node.id"
binding-path="bottomRightRadius"
@update:model-value="updateCornerProp('bottomRightRadius', $event)"
@commit="(v: number, p: number) => commitCornerProp('bottomRightRadius', v, p)"
- >
- <template #icon>
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <path d="M11 1v7a3 3 0 0 1-3 3H1" />
- </svg>
- </template>
- </VariableScrubInput>
+ />
</div>
- </div>
+ </PanelSection>
</template>
diff --git a/src/components/properties/ColorStyleRow.vue b/src/components/properties/ColorStyleRow.vue
index 7985d072f..423769a46 100644
--- a/src/components/properties/ColorStyleRow.vue
+++ b/src/components/properties/ColorStyleRow.vue
@@ -2,8 +2,8 @@
import ScrubInput from '@/components/ScrubInput.vue'
import BoundVariableButton from '@/components/properties/BoundVariableButton.vue'
import VariablePickerPopover from '@/components/properties/VariablePickerPopover.vue'
+import IconButton from '@/components/ui/IconButton.vue'
import Tip from '@/components/ui/Tip.vue'
-import { useIconButtonUI } from '@/components/ui/icon-button'
import { vTestId, useI18n } from '@open-pencil/vue'
@@ -115,10 +115,8 @@ const { panels, dialogs } = useI18n()
</button>
</Tip>
- <Tip :label="removeLabel">
- <button :class="useIconButtonUI({ ui: { base: 'shrink-0' } }).base" @click="emit('remove')">
- −
- </button>
- </Tip>
+ <IconButton :label="removeLabel" class="shrink-0" @click="emit('remove')">
+ <icon-lucide-minus class="size-3.5" />
+ </IconButton>
</div>
</template>
diff --git a/src/components/properties/EffectsSection.vue b/src/components/properties/EffectsSection.vue
index 197e4197b..c5d00b42f 100644
--- a/src/components/properties/EffectsSection.vue
+++ b/src/components/properties/EffectsSection.vue
@@ -2,9 +2,9 @@
import AppSelect from '@/components/ui/AppSelect.vue'
import ColorInput from '@/components/ColorPicker/ColorInput.vue'
import ScrubInput from '@/components/ScrubInput.vue'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelSection from '@/components/ui/PanelSection.vue'
import Tip from '@/components/ui/Tip.vue'
-import { useIconButtonUI } from '@/components/ui/icon-button'
-import { useSectionUI } from '@/components/ui/section'
import { PropertyListRoot, vTestId, useEffectsControls, useI18n } from '@open-pencil/vue'
import { colorToCSS } from '@open-pencil/core/color'
@@ -13,7 +13,6 @@ import type { Effect } from '@open-pencil/scene-graph'
const effectsCtx = useEffectsControls()
const { panels } = useI18n()
-const sectionCls = useSectionUI()
</script>
<template>
@@ -22,19 +21,16 @@ const sectionCls = useSectionUI()
prop-key="effects"
:label="panels.effects"
>
- <div data-test-id="effects-section" :class="sectionCls.wrapper">
- <div class="flex items-center justify-between">
- <label :class="sectionCls.label">{{ panels.effects }}</label>
- <Tip :label="panels.addEffect">
- <button
- data-test-id="effects-section-add"
- :class="useIconButtonUI().base"
- @click="actions.add(effectsCtx.createDefaultEffect())"
- >
- +
- </button>
- </Tip>
- </div>
+ <PanelSection :label="panels.effects" test-id="effects-section">
+ <template #actions>
+ <IconButton
+ :label="panels.addEffect"
+ data-test-id="effects-section-add"
+ @click="actions.add(effectsCtx.createDefaultEffect())"
+ >
+ <icon-lucide-plus class="size-3.5" />
+ </IconButton>
+ </template>
<p v-if="isMixed" class="text-[11px] text-muted">{{ panels.mixedEffectsHelp }}</p>
@@ -90,14 +86,12 @@ const sectionCls = useSectionUI()
<icon-lucide-eye-off v-else data-test-id="visibility-icon-off" class="size-3.5" />
</button>
</Tip>
- <Tip :label="panels.removeEffect">
- <button
- :class="useIconButtonUI().base"
- @click="effectsCtx.handleRemove(actions.remove, i)"
- >
- −
- </button>
- </Tip>
+ <IconButton
+ :label="panels.removeEffect"
+ @click="effectsCtx.handleRemove(actions.remove, i)"
+ >
+ <icon-lucide-minus class="size-3.5" />
+ </IconButton>
</div>
<div class="flex flex-col gap-1.5 py-1.5">
@@ -197,6 +191,6 @@ const sectionCls = useSectionUI()
</template>
</div>
</div>
- </div>
+ </PanelSection>
</PropertyListRoot>
</template>
diff --git a/src/components/properties/ExportSection.vue b/src/components/properties/ExportSection.vue
index 23ea57567..17babb261 100644
--- a/src/components/properties/ExportSection.vue
+++ b/src/components/properties/ExportSection.vue
@@ -3,9 +3,9 @@ import { ref, computed, watch, onScopeDispose } from 'vue'
import AppSelect from '@/components/ui/AppSelect.vue'
import ExportScaleInput from '@/components/properties/ExportScaleInput.vue'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelSection from '@/components/ui/PanelSection.vue'
import Tip from '@/components/ui/Tip.vue'
-import { useIconButtonUI } from '@/components/ui/icon-button'
-import { useSectionUI } from '@/components/ui/section'
import { useEditorStore } from '@/app/editor/active-store'
import { useExport, useI18n } from '@open-pencil/vue'
@@ -13,7 +13,6 @@ import type { ExportFormatId } from '@open-pencil/vue'
const editorStore = useEditorStore()
const { panels } = useI18n()
-const sectionCls = useSectionUI()
const {
activeTarget,
activeName,
@@ -114,19 +113,12 @@ onScopeDispose(() => {
</script>
<template>
- <div data-test-id="export-section" :class="sectionCls.wrapper">
- <div class="flex items-center justify-between">
- <label :class="sectionCls.label">{{ panels.export }}</label>
- <Tip :label="panels.addExport">
- <button
- data-test-id="export-section-add"
- :class="useIconButtonUI().base"
- @click="addSetting"
- >
- +
- </button>
- </Tip>
- </div>
+ <PanelSection :label="panels.export" test-id="export-section">
+ <template #actions>
+ <IconButton :label="panels.addExport" data-test-id="export-section-add" @click="addSetting">
+ <icon-lucide-plus class="size-3.5" />
+ </IconButton>
+ </template>
<p v-if="mixed" class="text-[11px] text-muted">
{{ panels.mixed }}
</p>
@@ -152,14 +144,9 @@ onScopeDispose(() => {
:label="panels.exportFormat"
@update:model-value="updateFormat(i, $event as ExportFormatId)"
/>
- <Tip :label="panels.removeExport">
- <button
- :class="useIconButtonUI({ ui: { base: 'shrink-0' } }).base"
- @click="removeSetting(i)"
- >
- −
- </button>
- </Tip>
+ <IconButton :label="panels.removeExport" class="shrink-0" @click="removeSetting(i)">
+ <icon-lucide-minus class="size-3.5" />
+ </IconButton>
</div>
<button
@@ -201,5 +188,5 @@ onScopeDispose(() => {
>
{{ panels.exportRenderingPreview }}
</div>
- </div>
+ </PanelSection>
</template>
diff --git a/src/components/properties/FillSection.vue b/src/components/properties/FillSection.vue
index d5b69d069..346d1054d 100644
--- a/src/components/properties/FillSection.vue
+++ b/src/components/properties/FillSection.vue
@@ -3,7 +3,8 @@ import { PropertyListRoot, useFillControls, useOkHCL, useI18n, inputValue } from
import { colorToHexRaw, parseColor } from '@open-pencil/core/color'
import FillPicker from '@/components/FillPicker.vue'
-import Tip from '@/components/ui/Tip.vue'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelSection from '@/components/ui/PanelSection.vue'
import ColorStyleRow from '@/components/properties/ColorStyleRow.vue'
import {
boundVariableSwatchBackground,
@@ -11,15 +12,12 @@ import {
} from '@/components/properties/color-style-row'
import { fillLabel } from '@/components/properties/fill-label'
import { createFillOkhclAdapter } from '@/components/properties/fill-okhcl'
-import { useIconButtonUI } from '@/components/ui/icon-button'
-import { useSectionUI } from '@/components/ui/section'
import type { Fill, SceneNode } from '@open-pencil/scene-graph'
const fillCtx = useFillControls()
const okhcl = useOkHCL()
const { panels } = useI18n()
-const sectionCls = useSectionUI()
function updateFill(
activeNode: SceneNode | null | undefined,
@@ -53,19 +51,16 @@ function updateFillHex(
prop-key="fills"
:label="panels.fill"
>
- <div data-test-id="fill-section" :class="sectionCls.wrapper">
- <div class="flex items-center justify-between">
- <label :class="sectionCls.label">{{ panels.fill }}</label>
- <Tip :label="panels.addFill">
- <button
- data-test-id="fill-section-add"
- :class="useIconButtonUI().base"
- @click="actions.add({ ...fillCtx.defaultFill })"
- >
- +
- </button>
- </Tip>
- </div>
+ <PanelSection :label="panels.fill" test-id="fill-section">
+ <template #actions>
+ <IconButton
+ :label="panels.addFill"
+ data-test-id="fill-section-add"
+ @click="actions.add({ ...fillCtx.defaultFill })"
+ >
+ <icon-lucide-plus class="size-3.5" />
+ </IconButton>
+ </template>
<p v-if="isMixed" class="text-[11px] text-muted">{{ panels.mixedFillsHelp }}</p>
<ColorStyleRow
v-for="(fill, i) in items as Fill[]"
@@ -116,6 +111,6 @@ function updateFillHex(
{{ fillLabel(fill, activeNode ? fillCtx.getBoundVariable(activeNode.id, i) : undefined) }}
</span>
</ColorStyleRow>
- </div>
+ </PanelSection>
</PropertyListRoot>
</template>
diff --git a/src/components/properties/LayoutSection/AutoLayoutControls.vue b/src/components/properties/LayoutSection/AutoLayoutControls.vue
index 19764694f..9941b6cf5 100644
--- a/src/components/properties/LayoutSection/AutoLayoutControls.vue
+++ b/src/components/properties/LayoutSection/AutoLayoutControls.vue
@@ -1,6 +1,7 @@
<script setup lang="ts">
-import Tip from '@/components/ui/Tip.vue'
-import { vTestId, useI18n, useLayoutControlsContext } from '@open-pencil/vue'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelRow from '@/components/ui/PanelRow.vue'
+import { useI18n, useLayoutControlsContext } from '@open-pencil/vue'
import type { LayoutMode } from '@open-pencil/scene-graph'
@@ -16,57 +17,46 @@ const layoutModes: { mode: LayoutMode; test: string }[] = [
</script>
<template>
- <div class="flex items-center justify-between">
- <label class="mb-1.5 block text-[11px] text-muted">{{ panels.autoLayout }}</label>
- <Tip v-if="ctx.node.layoutMode === 'NONE'" :label="panels.addAutoLayout">
- <button
- class="cursor-pointer rounded border-none bg-transparent px-1 text-base leading-none text-muted hover:bg-hover hover:text-surface"
- data-test-id="layout-add-auto"
- @click="ctx.editor.setLayoutMode(ctx.node.id, 'VERTICAL')"
- >
- +
- </button>
- </Tip>
- <Tip v-else :label="panels.removeAutoLayout">
- <button
- class="cursor-pointer rounded border-none bg-transparent px-1 text-base leading-none text-muted hover:bg-hover hover:text-surface"
- data-test-id="layout-remove-auto"
- @click="ctx.editor.setLayoutMode(ctx.node.id, 'NONE')"
- >
- −
- </button>
- </Tip>
- </div>
+ <PanelRow>
+ <IconButton
+ v-if="ctx.node.layoutMode === 'NONE'"
+ :label="panels.addAutoLayout"
+ data-test-id="layout-add-auto"
+ @click="ctx.editor.setLayoutMode(ctx.node.id, 'VERTICAL')"
+ >
+ <icon-lucide-plus class="size-3.5" />
+ </IconButton>
+ <IconButton
+ v-else
+ :label="panels.removeAutoLayout"
+ data-test-id="layout-remove-auto"
+ @click="ctx.editor.setLayoutMode(ctx.node.id, 'NONE')"
+ >
+ <icon-lucide-minus class="size-3.5" />
+ </IconButton>
+ </PanelRow>
- <div v-if="ctx.node.layoutMode !== 'NONE'" class="mt-1.5 flex gap-0.5">
- <button
+ <PanelRow v-if="ctx.node.layoutMode !== 'NONE'" class="mt-1.5" gap="sm">
+ <IconButton
v-for="dir in layoutModes"
:key="dir.mode"
- v-test-id="`layout-direction-${dir.test}`"
- class="flex cursor-pointer items-center justify-center rounded border px-2 py-1"
- :class="
- (dir.mode === 'GRID' ? ctx.isGrid : ctx.node.layoutMode === dir.mode)
- ? 'border-accent bg-accent/10 text-accent'
- : 'border-border text-muted hover:bg-hover hover:text-surface'
- "
+ size="md"
+ :active="dir.mode === 'GRID' ? ctx.isGrid : ctx.node.layoutMode === dir.mode"
+ :data-test-id="`layout-direction-${dir.test}`"
@click="ctx.editor.setLayoutMode(ctx.node.id, dir.mode)"
>
<icon-lucide-arrow-right v-if="dir.mode === 'HORIZONTAL'" class="size-3.5" />
<icon-lucide-arrow-down v-else-if="dir.mode === 'VERTICAL'" class="size-3.5" />
<icon-lucide-layout-grid v-else class="size-3.5" />
- </button>
- <button
+ </IconButton>
+ <IconButton
v-if="ctx.isFlex"
+ size="md"
+ :active="ctx.node.layoutWrap === 'WRAP'"
data-test-id="layout-direction-wrap"
- class="flex cursor-pointer items-center justify-center rounded border px-2 py-1"
- :class="
- ctx.node.layoutWrap === 'WRAP'
- ? 'border-accent bg-accent/10 text-accent'
- : 'border-border text-muted hover:bg-hover hover:text-surface'
- "
@click="ctx.updateProp('layoutWrap', ctx.node.layoutWrap === 'WRAP' ? 'NO_WRAP' : 'WRAP')"
>
<icon-lucide-wrap-text class="size-3.5" />
- </button>
- </div>
+ </IconButton>
+ </PanelRow>
</template>
diff --git a/src/components/properties/LayoutSection/GridControls.vue b/src/components/properties/LayoutSection/GridControls.vue
index 87c327797..ca9fe0a8b 100644
--- a/src/components/properties/LayoutSection/GridControls.vue
+++ b/src/components/properties/LayoutSection/GridControls.vue
@@ -1,6 +1,7 @@
<script setup lang="ts">
import AppSelect from '@/components/ui/AppSelect.vue'
import ScrubInput from '@/components/ScrubInput.vue'
+import IconButton from '@/components/ui/IconButton.vue'
import { useI18n, useLayoutControlsContext } from '@open-pencil/vue'
import type { GridTrackProp } from '@/components/properties/LayoutSection/types'
@@ -25,12 +26,9 @@ function defaultTrackValue(sizing: GridTrackSizing): number {
<label class="text-[11px] text-muted">
{{ trackProp === 'gridTemplateColumns' ? panels.columns : panels.rows }}
</label>
- <button
- class="cursor-pointer rounded border-none bg-transparent px-1 text-xs leading-none text-muted hover:bg-hover hover:text-surface"
- @click="ctx.addTrack(trackProp)"
- >
- +
- </button>
+ <IconButton @click="ctx.addTrack(trackProp)">
+ <icon-lucide-plus class="size-3.5" />
+ </IconButton>
</div>
<div class="flex flex-col gap-1">
<div v-for="(track, i) in ctx.node[trackProp]" :key="i" class="flex items-center gap-1">
@@ -54,13 +52,9 @@ function defaultTrackValue(sizing: GridTrackSizing): number {
})
"
/>
- <button
- v-if="ctx.node[trackProp].length > 1"
- class="cursor-pointer rounded border-none bg-transparent px-0.5 text-xs text-muted hover:text-surface"
- @click="ctx.removeTrack(trackProp, i)"
- >
- ×
- </button>
+ <IconButton v-if="ctx.node[trackProp].length > 1" @click="ctx.removeTrack(trackProp, i)">
+ <icon-lucide-x class="size-3.5" />
+ </IconButton>
</div>
</div>
</div>
@@ -68,18 +62,24 @@ function defaultTrackValue(sizing: GridTrackSizing): number {
<div class="mt-2 grid grid-cols-2 gap-1.5">
<ScrubInput
- icon="↔"
:model-value="Math.round(ctx.node.gridColumnGap)"
:min="0"
@update:model-value="ctx.updateProp('gridColumnGap', $event)"
@commit="(v: number, p: number) => ctx.commitProp('gridColumnGap', v, p)"
- />
+ >
+ <template #icon>
+ <icon-lucide-move-horizontal class="size-3" />
+ </template>
+ </ScrubInput>
<ScrubInput
- icon="↕"
:model-value="Math.round(ctx.node.gridRowGap)"
:min="0"
@update:model-value="ctx.updateProp('gridRowGap', $event)"
@commit="(v: number, p: number) => ctx.commitProp('gridRowGap', v, p)"
- />
+ >
+ <template #icon>
+ <icon-lucide-move-vertical class="size-3" />
+ </template>
+ </ScrubInput>
</div>
</template>
diff --git a/src/components/properties/LayoutSection/LayoutSection.vue b/src/components/properties/LayoutSection/LayoutSection.vue
index 3bc941a28..09798d084 100644
--- a/src/components/properties/LayoutSection/LayoutSection.vue
+++ b/src/components/properties/LayoutSection/LayoutSection.vue
@@ -7,10 +7,9 @@ import FlexControls from '@/components/properties/LayoutSection/FlexControls.vue
import GridControls from '@/components/properties/LayoutSection/GridControls.vue'
import PaddingControls from '@/components/properties/LayoutSection/PaddingControls.vue'
import SizeControls from '@/components/properties/LayoutSection/SizeControls.vue'
-import { useSectionUI } from '@/components/ui/section'
+import PanelSection from '@/components/ui/PanelSection.vue'
const { panels } = useI18n()
-const sectionCls = useSectionUI()
const CONTAINER_TYPES = ['FRAME', 'COMPONENT', 'COMPONENT_SET', 'INSTANCE']
</script>
@@ -18,13 +17,12 @@ const CONTAINER_TYPES = ['FRAME', 'COMPONENT', 'COMPONENT_SET', 'INSTANCE']
<template>
<LayoutControlsRoot v-slot="ctx">
<template v-if="ctx.node">
- <div data-test-id="layout-section" :class="sectionCls.wrapper">
- <label class="mb-1.5 block text-[11px] text-muted">{{ panels.layout }}</label>
+ <PanelSection :label="panels.layout" test-id="layout-section">
<SizeControls />
- </div>
+ </PanelSection>
<template v-if="CONTAINER_TYPES.includes(ctx.node.type)">
- <div :class="sectionCls.wrapper">
+ <PanelSection :label="panels.autoLayout">
<AutoLayoutControls />
<template v-if="ctx.node.layoutMode !== 'NONE'">
@@ -35,7 +33,7 @@ const CONTAINER_TYPES = ['FRAME', 'COMPONENT', 'COMPONENT_SET', 'INSTANCE']
<ClipContentControl />
</template>
</template>
- </div>
+ </PanelSection>
</template>
</template>
</LayoutControlsRoot>
diff --git a/src/components/properties/PageSection.vue b/src/components/properties/PageSection.vue
index 6bda96474..a073be692 100644
--- a/src/components/properties/PageSection.vue
+++ b/src/components/properties/PageSection.vue
@@ -3,19 +3,17 @@ import { computed } from 'vue'
import { useI18n } from '@open-pencil/vue'
import ColorInput from '@/components/ColorPicker/ColorInput.vue'
-import { useSectionUI } from '@/components/ui/section'
+import PanelSection from '@/components/ui/PanelSection.vue'
import { useEditorStore } from '@/app/editor/active-store'
const editor = useEditorStore()
const pageColor = computed(() => editor.state.pageColor)
-const sectionCls = useSectionUI()
const { panels } = useI18n()
</script>
<template>
- <div data-test-id="page-section" :class="sectionCls.wrapper">
- <label class="mb-1.5 block text-[11px] text-muted">{{ panels.page ?? 'Page' }}</label>
+ <PanelSection :label="panels.page ?? 'Page'" test-id="page-section">
<ColorInput :color="pageColor" editable @update="editor.setPageColor($event)" />
- </div>
+ </PanelSection>
</template>
diff --git a/src/components/properties/PositionSection.vue b/src/components/properties/PositionSection.vue
index 435fd4eb0..2e0a6aab1 100644
--- a/src/components/properties/PositionSection.vue
+++ b/src/components/properties/PositionSection.vue
@@ -1,14 +1,14 @@
<script setup lang="ts">
import ScrubInput from '@/components/ScrubInput.vue'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelRow from '@/components/ui/PanelRow.vue'
+import PanelSection from '@/components/ui/PanelSection.vue'
import Tip from '@/components/ui/Tip.vue'
-import { useIconButtonUI } from '@/components/ui/icon-button'
-import { useSectionUI } from '@/components/ui/section'
import { useEditorStore } from '@/app/editor/active-store'
import { PositionControlsRoot, useI18n } from '@open-pencil/vue'
const { panels } = useI18n()
const store = useEditorStore()
-const sectionCls = useSectionUI()
function handleAlign(
nodeAlign: (axis: 'horizontal' | 'vertical', pos: 'min' | 'center' | 'max') => void,
@@ -28,71 +28,63 @@ function handleAlign(
<PositionControlsRoot
v-slot="{ active, isMulti, xValue, yValue, wValue, hValue, rotationValue, actions }"
>
- <div v-if="active" data-test-id="position-section" :class="sectionCls.wrapper">
- <label class="mb-1.5 block text-[11px] text-muted">{{ panels.position }}</label>
-
- <div class="mb-1.5 flex gap-2">
- <div class="flex gap-0.5">
- <Tip :label="panels.alignLeft">
- <button
- :class="useIconButtonUI({ size: 'md' }).base"
- data-test-id="position-align-left"
- @click="handleAlign(actions.align, 'horizontal', 'min')"
- >
- <icon-lucide-align-start-vertical class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="panels.alignCenterHorizontally">
- <button
- :class="useIconButtonUI({ size: 'md' }).base"
- data-test-id="position-align-center-h"
- @click="handleAlign(actions.align, 'horizontal', 'center')"
- >
- <icon-lucide-align-center-vertical class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="panels.alignRight">
- <button
- :class="useIconButtonUI({ size: 'md' }).base"
- data-test-id="position-align-right"
- @click="handleAlign(actions.align, 'horizontal', 'max')"
- >
- <icon-lucide-align-end-vertical class="size-3.5" />
- </button>
- </Tip>
- </div>
- <div class="flex gap-0.5">
- <Tip :label="panels.alignTop">
- <button
- :class="useIconButtonUI({ size: 'md' }).base"
- data-test-id="position-align-top"
- @click="handleAlign(actions.align, 'vertical', 'min')"
- >
- <icon-lucide-align-start-horizontal class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="panels.alignCenterVertically">
- <button
- :class="useIconButtonUI({ size: 'md' }).base"
- data-test-id="position-align-center-v"
- @click="handleAlign(actions.align, 'vertical', 'center')"
- >
- <icon-lucide-align-center-horizontal class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="panels.alignBottom">
- <button
- :class="useIconButtonUI({ size: 'md' }).base"
- data-test-id="position-align-bottom"
- @click="handleAlign(actions.align, 'vertical', 'max')"
- >
- <icon-lucide-align-end-horizontal class="size-3.5" />
- </button>
- </Tip>
- </div>
- </div>
+ <PanelSection v-if="active" :label="panels.position" test-id="position-section">
+ <PanelRow class="mb-1.5 gap-2">
+ <PanelRow gap="sm">
+ <IconButton
+ :label="panels.alignLeft"
+ size="md"
+ data-test-id="position-align-left"
+ @click="handleAlign(actions.align, 'horizontal', 'min')"
+ >
+ <icon-lucide-align-start-vertical class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="panels.alignCenterHorizontally"
+ size="md"
+ data-test-id="position-align-center-h"
+ @click="handleAlign(actions.align, 'horizontal', 'center')"
+ >
+ <icon-lucide-align-center-vertical class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="panels.alignRight"
+ size="md"
+ data-test-id="position-align-right"
+ @click="handleAlign(actions.align, 'horizontal', 'max')"
+ >
+ <icon-lucide-align-end-vertical class="size-3.5" />
+ </IconButton>
+ </PanelRow>
+ <PanelRow gap="sm">
+ <IconButton
+ :label="panels.alignTop"
+ size="md"
+ data-test-id="position-align-top"
+ @click="handleAlign(actions.align, 'vertical', 'min')"
+ >
+ <icon-lucide-align-start-horizontal class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="panels.alignCenterVertically"
+ size="md"
+ data-test-id="position-align-center-v"
+ @click="handleAlign(actions.align, 'vertical', 'center')"
+ >
+ <icon-lucide-align-center-horizontal class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="panels.alignBottom"
+ size="md"
+ data-test-id="position-align-bottom"
+ @click="handleAlign(actions.align, 'vertical', 'max')"
+ >
+ <icon-lucide-align-end-horizontal class="size-3.5" />
+ </IconButton>
+ </PanelRow>
+ </PanelRow>
- <div class="flex gap-1.5">
+ <PanelRow cols="two">
<Tip :label="panels.xAxis">
<ScrubInput
icon="X"
@@ -109,9 +101,9 @@ function handleAlign(
@commit="(v: number, p: number) => actions.commitProp('y', v, p)"
/>
</Tip>
- </div>
+ </PanelRow>
- <div v-if="isMulti" class="mt-1.5 flex gap-1.5">
+ <PanelRow v-if="isMulti" cols="two" class="mt-1.5">
<Tip :label="panels.width">
<ScrubInput
icon="W"
@@ -130,9 +122,9 @@ function handleAlign(
@commit="(v: number, p: number) => actions.commitProp('height', v, p)"
/>
</Tip>
- </div>
+ </PanelRow>
- <div class="mt-1.5 flex items-center gap-1.5">
+ <PanelRow cols="fill" class="mt-1.5">
<Tip :label="panels.rotation">
<ScrubInput
class="flex-1"
@@ -148,34 +140,34 @@ function handleAlign(
</template>
</ScrubInput>
</Tip>
- <Tip :label="panels.flipHorizontal">
- <button
- :class="useIconButtonUI({ size: 'md', ui: { base: 'shrink-0' } }).base"
- data-test-id="position-flip-horizontal"
- @click="actions.flip('horizontal')"
- >
- <icon-lucide-flip-horizontal-2 class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="panels.flipVertical">
- <button
- :class="useIconButtonUI({ size: 'md', ui: { base: 'shrink-0' } }).base"
- data-test-id="position-flip-vertical"
- @click="actions.flip('vertical')"
- >
- <icon-lucide-flip-vertical-2 class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="panels.rotate90">
- <button
- :class="useIconButtonUI({ size: 'md', ui: { base: 'shrink-0' } }).base"
- data-test-id="position-rotate-90"
- @click="actions.rotate(90)"
- >
- <icon-lucide-rotate-cw-square class="size-3.5" />
- </button>
- </Tip>
- </div>
- </div>
+ <IconButton
+ :label="panels.flipHorizontal"
+ size="md"
+ class="shrink-0"
+ data-test-id="position-flip-horizontal"
+ @click="actions.flip('horizontal')"
+ >
+ <icon-lucide-flip-horizontal-2 class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="panels.flipVertical"
+ size="md"
+ class="shrink-0"
+ data-test-id="position-flip-vertical"
+ @click="actions.flip('vertical')"
+ >
+ <icon-lucide-flip-vertical-2 class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="panels.rotate90"
+ size="md"
+ class="shrink-0"
+ data-test-id="position-rotate-90"
+ @click="actions.rotate(90)"
+ >
+ <icon-lucide-rotate-cw-square class="size-3.5" />
+ </IconButton>
+ </PanelRow>
+ </PanelSection>
</PositionControlsRoot>
</template>
diff --git a/src/components/properties/StrokeSection.vue b/src/components/properties/StrokeSection.vue
index 92ca5114f..10d67c3d9 100644
--- a/src/components/properties/StrokeSection.vue
+++ b/src/components/properties/StrokeSection.vue
@@ -15,9 +15,9 @@ import { boundVariableColor } from '@/components/properties/color-style-row'
import AppSelect from '@/components/ui/AppSelect.vue'
import ColorInput from '@/components/ColorPicker/ColorInput.vue'
import ScrubInput from '@/components/ScrubInput.vue'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelSection from '@/components/ui/PanelSection.vue'
import Tip from '@/components/ui/Tip.vue'
-import { useIconButtonUI } from '@/components/ui/icon-button'
-import { useSectionUI } from '@/components/ui/section'
import type { Color, SceneNode, Stroke } from '@open-pencil/scene-graph'
@@ -25,7 +25,6 @@ const strokeCtx = useStrokeControls()
const strokeVarCtx = useColorVariableBinding('strokes')
const okhcl = useOkHCL()
const { panels } = useI18n()
-const sectionCls = useSectionUI()
const expandedSides = ref(false)
@@ -88,19 +87,16 @@ function setGap(stroke: Stroke | undefined, patch: StrokePatch, value: number) {
prop-key="strokes"
:label="panels.stroke"
>
- <div data-test-id="stroke-section" :class="sectionCls.wrapper">
- <div class="flex items-center justify-between">
- <label :class="sectionCls.label">{{ panels.stroke }}</label>
- <Tip :label="panels.addStroke">
- <button
- data-test-id="stroke-section-add"
- :class="useIconButtonUI().base"
- @click="actions.add(strokeCtx.defaultStroke)"
- >
- +
- </button>
- </Tip>
- </div>
+ <PanelSection :label="panels.stroke" test-id="stroke-section">
+ <template #actions>
+ <IconButton
+ :label="panels.addStroke"
+ data-test-id="stroke-section-add"
+ @click="actions.add(strokeCtx.defaultStroke)"
+ >
+ <icon-lucide-plus class="size-3.5" />
+ </IconButton>
+ </template>
<p v-if="isMixed" class="text-[11px] text-muted">{{ panels.mixedStrokesHelp }}</p>
@@ -161,94 +157,53 @@ function setGap(stroke: Stroke | undefined, patch: StrokePatch, value: number) {
<ScrubInput
v-if="!expandedSides"
class="flex-1"
+ icon="W"
:model-value="activeNode!.strokes[0]?.weight ?? 1"
:min="0"
@update:model-value="actions.patch(0, { weight: $event })"
- >
- <template #icon>
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <line x1="1" y1="3" x2="11" y2="3" />
- <line x1="1" y1="6" x2="11" y2="6" />
- <line x1="1" y1="9" x2="11" y2="9" />
- </svg>
- </template>
- </ScrubInput>
- </Tip>
- <Tip :label="panels.strokeSides">
- <button
- data-test-id="stroke-sides-toggle"
- :class="[
- useIconButtonUI({ size: 'md', ui: { base: 'size-[26px] shrink-0' } }).base,
- { '!border-accent !text-accent': expandedSides }
- ]"
- @click="onToggleSides(activeNode!)"
- >
- <svg class="size-3.5" viewBox="0 0 14 14" fill="currentColor">
- <rect x="1" y="1" width="5" height="5" rx="1" />
- <rect x="8" y="1" width="5" height="5" rx="1" />
- <rect x="1" y="8" width="5" height="5" rx="1" />
- <rect x="8" y="8" width="5" height="5" rx="1" />
- </svg>
- </button>
+ />
</Tip>
+ <IconButton
+ :label="panels.strokeSides"
+ size="md"
+ class="size-[26px] shrink-0"
+ :active="expandedSides"
+ data-test-id="stroke-sides-toggle"
+ @click="onToggleSides(activeNode!)"
+ >
+ <icon-lucide-grid-2x2 class="size-3.5" />
+ </IconButton>
</div>
<div
v-if="!isMixed && (items as unknown[]).length > 0"
class="mt-1.5 flex items-center gap-1.5"
>
- <Tip :label="panels.strokeDash">
- <button
- data-test-id="stroke-dash-toggle"
- :aria-label="panels.strokeDash"
- class="flex h-[26px] shrink-0 cursor-pointer items-center gap-1 rounded border bg-input px-1.5 text-[11px]"
- :class="
- dashState((items as Stroke[])[0]).on
- ? '!border-accent !text-accent'
- : 'border-border text-muted hover:bg-hover hover:text-surface'
- "
- @click="toggleDash((items as Stroke[])[0], actions.patch)"
- >
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <line x1="1" y1="6" x2="11" y2="6" stroke-dasharray="3 2" />
- </svg>
- </button>
- </Tip>
+ <IconButton
+ :label="panels.strokeDash"
+ size="md"
+ class="shrink-0"
+ :active="dashState((items as Stroke[])[0]).on"
+ data-test-id="stroke-dash-toggle"
+ @click="toggleDash((items as Stroke[])[0], actions.patch)"
+ >
+ <span class="flex items-center gap-0.5">
+ <icon-lucide-minus class="size-2.5" />
+ <icon-lucide-minus class="size-2.5" />
+ </span>
+ </IconButton>
<template v-if="dashState((items as Stroke[])[0]).on">
<ScrubInput
class="flex-1"
+ icon="D"
:model-value="(items as Stroke[])[0].dashPattern?.[0] ?? 6"
:min="1"
data-test-id="stroke-dash-length"
@update:model-value="setDash((items as Stroke[])[0], actions.patch, $event)"
- >
- <template #icon>
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <line x1="1" y1="6" x2="5" y2="6" />
- <line x1="7" y1="6" x2="11" y2="6" />
- </svg>
- </template>
- </ScrubInput>
+ />
<ScrubInput
class="flex-1"
+ icon="G"
:model-value="
(items as Stroke[])[0].dashPattern?.[1] ??
(items as Stroke[])[0].dashPattern?.[0] ??
@@ -257,20 +212,7 @@ function setGap(stroke: Stroke | undefined, patch: StrokePatch, value: number) {
:min="1"
data-test-id="stroke-dash-gap"
@update:model-value="setGap((items as Stroke[])[0], actions.patch, $event)"
- >
- <template #icon>
- <svg
- class="size-3"
- viewBox="0 0 12 12"
- fill="none"
- stroke="currentColor"
- stroke-width="1.5"
- >
- <line x1="1" y1="6" x2="3" y2="6" />
- <line x1="9" y1="6" x2="11" y2="6" />
- </svg>
- </template>
- </ScrubInput>
+ />
</template>
</div>
@@ -281,6 +223,7 @@ function setGap(stroke: Stroke | undefined, patch: StrokePatch, value: number) {
<ScrubInput
v-for="side in strokeCtx.borderSides"
:key="side"
+ :label="side[0].toUpperCase()"
:model-value="
activeNode![
`border${side[0].toUpperCase()}${side.slice(1)}Weight` as keyof SceneNode
@@ -288,41 +231,8 @@ function setGap(stroke: Stroke | undefined, patch: StrokePatch, value: number) {
"
:min="0"
@update:model-value="strokeCtx.updateBorderWeight(side, $event, activeNode!)"
- >
- <template #icon>
- <svg class="size-3" viewBox="0 0 12 12" fill="none" stroke-width="1.5">
- <rect
- x="1"
- y="1"
- width="10"
- height="10"
- rx="1"
- stroke="currentColor"
- stroke-opacity="0.3"
- stroke-dasharray="2 2"
- />
- <line v-if="side === 'top'" x1="1" y1="1" x2="11" y2="1" stroke="currentColor" />
- <line
- v-else-if="side === 'right'"
- x1="11"
- y1="1"
- x2="11"
- y2="11"
- stroke="currentColor"
- />
- <line
- v-else-if="side === 'bottom'"
- x1="1"
- y1="11"
- x2="11"
- y2="11"
- stroke="currentColor"
- />
- <line v-else x1="1" y1="1" x2="1" y2="11" stroke="currentColor" />
- </svg>
- </template>
- </ScrubInput>
+ />
</div>
- </div>
+ </PanelSection>
</PropertyListRoot>
</template>
diff --git a/src/components/properties/TypographySection.vue b/src/components/properties/TypographySection.vue
index 341e83b60..73458210b 100644
--- a/src/components/properties/TypographySection.vue
+++ b/src/components/properties/TypographySection.vue
@@ -1,28 +1,25 @@
<script setup lang="ts">
-import { ToggleGroupItem, ToggleGroupRoot } from 'reka-ui'
-
import { TypographyControlsRoot, useI18n } from '@open-pencil/vue'
import FontPicker from '@/components/FontPicker.vue'
import FontSettingsPopover from '@/components/FontSettings/FontSettingsPopover.vue'
import VariableScrubInput from '@/components/properties/VariableScrubInput.vue'
import AppSelect from '@/components/ui/AppSelect.vue'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelRow from '@/components/ui/PanelRow.vue'
+import PanelSection from '@/components/ui/PanelSection.vue'
import Tip from '@/components/ui/Tip.vue'
-import { useSectionUI } from '@/components/ui/section'
import { loadFont } from '@/app/editor/fonts'
import { appMenuShortcutLabel } from '@/app/shell/menu/shortcut'
const { panels, menu } = useI18n()
-const sectionCls = useSectionUI()
const fontLoader = { load: loadFont }
</script>
<template>
<TypographyControlsRoot v-slot="ctx" :font-loader="fontLoader">
- <div v-if="ctx.node.value" data-test-id="typography-section" :class="sectionCls.wrapper">
- <label class="mb-1.5 block text-[11px] text-muted">{{ panels.typography }}</label>
-
- <div class="mb-1.5 flex items-center gap-1.5">
+ <PanelSection v-if="ctx.node.value" :label="panels.typography" test-id="typography-section">
+ <PanelRow class="mb-1.5">
<FontPicker
class="min-w-0 flex-1"
:model-value="ctx.node.value.fontFamily"
@@ -43,9 +40,9 @@ const fontLoader = { load: loadFont }
class="size-3.5 shrink-0 text-[var(--color-warning-action)]"
/>
</Tip>
- </div>
+ </PanelRow>
- <div class="mb-1.5 flex gap-1.5">
+ <PanelRow cols="two" class="mb-1.5">
<AppSelect
:model-value="ctx.node.value.fontWeight"
:options="ctx.weights"
@@ -61,9 +58,9 @@ const fontLoader = { load: loadFont }
@update:model-value="ctx.actions.updateProp('fontSize', $event)"
@commit="(v: number, p: number) => ctx.actions.commitProp('fontSize', v, p)"
/>
- </div>
+ </PanelRow>
- <div class="mb-1.5 flex gap-1.5">
+ <PanelRow cols="two" class="mb-1.5">
<VariableScrubInput
class="flex-1"
:model-value="
@@ -92,7 +89,7 @@ const fontLoader = { load: loadFont }
<icon-lucide-a-large-small class="size-3" />
</template>
</VariableScrubInput>
- </div>
+ </PanelRow>
<div class="mb-1.5">
<label class="mb-1 block text-[11px] text-muted">{{ panels.direction }}</label>
@@ -107,64 +104,69 @@ const fontLoader = { load: loadFont }
/>
</div>
- <div class="flex items-center gap-3">
- <ToggleGroupRoot
- type="single"
- class="flex gap-0.5"
- :model-value="ctx.node.value.textAlignHorizontal"
- @update:model-value="ctx.actions.align"
- >
- <ToggleGroupItem
- v-for="align in ['LEFT', 'CENTER', 'RIGHT'] as const"
- :key="align"
- :value="align"
- class="flex cursor-pointer items-center justify-center rounded border border-border bg-input px-2 py-1 text-muted hover:bg-hover hover:text-surface data-[state=on]:border-accent data-[state=on]:bg-accent data-[state=on]:text-white"
+ <PanelRow class="gap-3">
+ <PanelRow gap="sm">
+ <IconButton
+ :label="panels.alignLeft"
+ size="md"
+ :active="ctx.node.value.textAlignHorizontal === 'LEFT'"
+ @click="ctx.actions.align('LEFT')"
>
- <icon-lucide-align-left v-if="align === 'LEFT'" class="size-3.5" />
- <icon-lucide-align-center v-else-if="align === 'CENTER'" class="size-3.5" />
- <icon-lucide-align-right v-else class="size-3.5" />
- </ToggleGroupItem>
- </ToggleGroupRoot>
- <div class="flex gap-0.5">
- <Tip :label="`${menu.bold} (${appMenuShortcutLabel('text.bold')})`">
- <button
- data-test-id="typography-bold-button"
- class="flex cursor-pointer items-center justify-center rounded border border-border bg-input px-2 py-1 font-bold text-muted hover:bg-hover hover:text-surface data-[state=on]:border-accent data-[state=on]:bg-accent data-[state=on]:text-white"
- :data-state="ctx.activeFormatting.value.includes('bold') ? 'on' : 'off'"
- @click="ctx.actions.toggleBold"
- >
- <icon-lucide-bold class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="`${menu.italic} (${appMenuShortcutLabel('text.italic')})`">
- <button
- class="flex cursor-pointer items-center justify-center rounded border border-border bg-input px-2 py-1 text-muted hover:bg-hover hover:text-surface data-[state=on]:border-accent data-[state=on]:bg-accent data-[state=on]:text-white"
- :data-state="ctx.activeFormatting.value.includes('italic') ? 'on' : 'off'"
- @click="ctx.actions.toggleItalic"
- >
- <icon-lucide-italic class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="`${menu.underline} (${appMenuShortcutLabel('text.underline')})`">
- <button
- class="flex cursor-pointer items-center justify-center rounded border border-border bg-input px-2 py-1 text-muted hover:bg-hover hover:text-surface data-[state=on]:border-accent data-[state=on]:bg-accent data-[state=on]:text-white"
- :data-state="ctx.activeFormatting.value.includes('underline') ? 'on' : 'off'"
- @click="ctx.actions.toggleDecoration('UNDERLINE')"
- >
- <icon-lucide-underline class="size-3.5" />
- </button>
- </Tip>
- <Tip :label="menu.strikethrough">
- <button
- class="flex cursor-pointer items-center justify-center rounded border border-border bg-input px-2 py-1 text-muted hover:bg-hover hover:text-surface data-[state=on]:border-accent data-[state=on]:bg-accent data-[state=on]:text-white"
- :data-state="ctx.activeFormatting.value.includes('strikethrough') ? 'on' : 'off'"
- @click="ctx.actions.toggleDecoration('STRIKETHROUGH')"
- >
- <icon-lucide-strikethrough class="size-3.5" />
- </button>
- </Tip>
- </div>
- </div>
- </div>
+ <icon-lucide-align-left class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="panels.alignCenterHorizontally"
+ size="md"
+ :active="ctx.node.value.textAlignHorizontal === 'CENTER'"
+ @click="ctx.actions.align('CENTER')"
+ >
+ <icon-lucide-align-center class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="panels.alignRight"
+ size="md"
+ :active="ctx.node.value.textAlignHorizontal === 'RIGHT'"
+ @click="ctx.actions.align('RIGHT')"
+ >
+ <icon-lucide-align-right class="size-3.5" />
+ </IconButton>
+ </PanelRow>
+ <PanelRow gap="sm">
+ <IconButton
+ :label="`${menu.bold} (${appMenuShortcutLabel('text.bold')})`"
+ size="md"
+ :active="ctx.activeFormatting.value.includes('bold')"
+ data-test-id="typography-bold-button"
+ @click="ctx.actions.toggleBold"
+ >
+ <icon-lucide-bold class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="`${menu.italic} (${appMenuShortcutLabel('text.italic')})`"
+ size="md"
+ :active="ctx.activeFormatting.value.includes('italic')"
+ @click="ctx.actions.toggleItalic"
+ >
+ <icon-lucide-italic class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="`${menu.underline} (${appMenuShortcutLabel('text.underline')})`"
+ size="md"
+ :active="ctx.activeFormatting.value.includes('underline')"
+ @click="ctx.actions.toggleDecoration('UNDERLINE')"
+ >
+ <icon-lucide-underline class="size-3.5" />
+ </IconButton>
+ <IconButton
+ :label="menu.strikethrough"
+ size="md"
+ :active="ctx.activeFormatting.value.includes('strikethrough')"
+ @click="ctx.actions.toggleDecoration('STRIKETHROUGH')"
+ >
+ <icon-lucide-strikethrough class="size-3.5" />
+ </IconButton>
+ </PanelRow>
+ </PanelRow>
+ </PanelSection>
</TypographyControlsRoot>
</template>
diff --git a/src/components/properties/VariablesSection.vue b/src/components/properties/VariablesSection.vue
index c9c4c3b43..6f07b755c 100644
--- a/src/components/properties/VariablesSection.vue
+++ b/src/components/properties/VariablesSection.vue
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { computed } from 'vue'
-import Tip from '@/components/ui/Tip.vue'
-import { useSectionUI } from '@/components/ui/section'
+import IconButton from '@/components/ui/IconButton.vue'
+import PanelSection from '@/components/ui/PanelSection.vue'
import { useI18n, useSceneComputed } from '@open-pencil/vue'
import { useEditorStore } from '@/app/editor/active-store'
@@ -19,27 +19,27 @@ const variableCount = useSceneComputed(() => {
return editor.getVariableCount()
})
const hasVariables = computed(() => variableCount.value > 0)
-const sectionCls = useSectionUI()
const { panels } = useI18n()
</script>
<template>
- <div data-test-id="variables-section" :class="sectionCls.wrapper">
- <div class="flex items-center justify-between">
- <label class="text-[11px] font-medium text-surface">{{ panels.variables }}</label>
- <Tip :label="panels.openVariables">
- <button
- data-test-id="variables-section-open"
- class="flex size-5 cursor-pointer items-center justify-center rounded border-none bg-transparent text-muted hover:bg-hover hover:text-surface"
- @click="emit('openDialog')"
- >
- <icon-lucide-settings-2 class="size-3.5" />
- </button>
- </Tip>
- </div>
+ <PanelSection
+ :label="panels.variables"
+ test-id="variables-section"
+ :ui="{ label: 'font-medium text-surface' }"
+ >
+ <template #actions>
+ <IconButton
+ :label="panels.openVariables"
+ data-test-id="variables-section-open"
+ @click="emit('openDialog')"
+ >
+ <icon-lucide-settings-2 class="size-3.5" />
+ </IconButton>
+ </template>
<div v-if="hasVariables" class="mt-1 text-[11px] text-muted">
{{ variableCount }} / {{ collectionCount }}
</div>
<div v-else class="mt-1 text-[11px] text-muted">{{ panels.noLocalVariables }}</div>
- </div>
+ </PanelSection>
</template>
diff --git a/src/components/properties/VariantSection.vue b/src/components/properties/VariantSection.vue
index c814b176c..2fe3375db 100644
--- a/src/components/properties/VariantSection.vue
+++ b/src/components/properties/VariantSection.vue
@@ -4,12 +4,11 @@ import { computed } from 'vue'
import { useI18n, useSelectionState } from '@open-pencil/vue'
import AppSelect from '@/components/ui/AppSelect.vue'
-import { useSectionUI } from '@/components/ui/section'
+import PanelSection from '@/components/ui/PanelSection.vue'
import { useEditorStore } from '@/app/editor/active-store'
const editor = useEditorStore()
const { selectedNode: node } = useSelectionState()
-const sectionCls = useSectionUI()
const { panels } = useI18n()
const instanceComponent = computed(() => {
@@ -43,8 +42,12 @@ function switchVariant(propertyName: string, newValue: string) {
</script>
<template>
- <div v-if="hasVariants" data-test-id="variant-section" :class="sectionCls.wrapper">
- <label class="mb-1.5 block text-[11px] font-medium text-component">{{ panels.variants }}</label>
+ <PanelSection
+ v-if="hasVariants"
+ :label="panels.variants"
+ test-id="variant-section"
+ :ui="{ label: 'font-medium text-component' }"
+ >
<div class="flex flex-col gap-1.5">
<div
v-for="[propName, options] in variantOptions"
@@ -59,5 +62,5 @@ function switchVariant(propertyName: string, newValue: string) {
/>
</div>
</div>
- </div>
+ </PanelSection>
</template>
diff --git a/src/components/ui/AppInput.vue b/src/components/ui/AppInput.vue
index d56f508f2..9772f936b 100644
--- a/src/components/ui/AppInput.vue
+++ b/src/components/ui/AppInput.vue
@@ -1,4 +1,6 @@
<script setup lang="ts">
+import { computed } from 'vue'
+
import type { TestIdProps } from '@open-pencil/vue'
import { useInputUI } from '@/components/ui/input'
@@ -32,6 +34,8 @@ const {
testId
} = defineProps<AppInputProps>()
+const inputClass = computed(() => useInputUI({ size, ui }).base)
+
const modelValue = defineModel<string | number>({ required: true })
const emit = defineEmits<{
change: []
@@ -52,7 +56,7 @@ const emit = defineEmits<{
:min="min"
:max="max"
:step="step"
- :class="useInputUI({ size, ui }).base"
+ :class="inputClass"
@change="emit('change')"
@keydown.enter="emit('enter', $event)"
@focus="emit('focus', $event)"
diff --git a/src/components/ui/IconButton.vue b/src/components/ui/IconButton.vue
new file mode 100644
index 000000000..a80b96cf3
--- /dev/null
+++ b/src/components/ui/IconButton.vue
@@ -0,0 +1,61 @@
+<script setup lang="ts">
+import { computed, normalizeClass, useAttrs } from 'vue'
+
+import { useIconButtonUI } from '@/components/ui/icon-button'
+import Tip from '@/components/ui/Tip.vue'
+
+const {
+ active = false,
+ disabled = false,
+ label,
+ side = 'top',
+ size = 'sm',
+ type = 'button'
+} = defineProps<{
+ active?: boolean
+ disabled?: boolean
+ label?: string
+ side?: 'top' | 'bottom' | 'left' | 'right'
+ size?: 'sm' | 'md'
+ type?: 'button' | 'submit' | 'reset'
+}>()
+
+const attrs = useAttrs()
+
+defineOptions({ inheritAttrs: false })
+
+const buttonAttrs = computed(() => {
+ const { class: _class, ...rest } = attrs
+ return rest
+})
+
+const cls = computed(
+ () =>
+ useIconButtonUI({
+ size,
+ ui: {
+ base: normalizeClass([
+ attrs.class,
+ active ? 'border-accent text-accent' : '',
+ disabled ? 'cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted' : ''
+ ])
+ }
+ }).base
+)
+</script>
+
+<template>
+ <Tip :label="label" :side="side" :disabled="disabled || !label">
+ <button
+ v-bind="buttonAttrs"
+ :type="type"
+ :disabled="disabled"
+ :aria-label="label"
+ :aria-pressed="active ? 'true' : undefined"
+ :data-state="active ? 'on' : 'off'"
+ :class="cls"
+ >
+ <slot />
+ </button>
+ </Tip>
+</template>
diff --git a/src/components/ui/PanelRow.vue b/src/components/ui/PanelRow.vue
new file mode 100644
index 000000000..16d0bbb65
--- /dev/null
+++ b/src/components/ui/PanelRow.vue
@@ -0,0 +1,19 @@
+<script setup lang="ts">
+const { cols = 'auto', gap = 'md' } = defineProps<{
+ cols?: 'auto' | 'two' | 'fill'
+ gap?: 'sm' | 'md'
+}>()
+</script>
+
+<template>
+ <div
+ class="flex items-center"
+ :class="[
+ gap === 'sm' ? 'gap-0.5' : 'gap-1.5',
+ cols === 'two' ? '[&>*]:min-w-0 [&>*]:flex-1' : '',
+ cols === 'fill' ? '[&>*:first-child]:min-w-0 [&>*:first-child]:flex-1' : ''
+ ]"
+ >
+ <slot />
+ </div>
+</template>
diff --git a/src/components/ui/PanelSection.vue b/src/components/ui/PanelSection.vue
new file mode 100644
index 000000000..b08855a97
--- /dev/null
+++ b/src/components/ui/PanelSection.vue
@@ -0,0 +1,30 @@
+<script setup lang="ts">
+import type { TestIdProps } from '@open-pencil/vue'
+
+import { useSectionUI } from '@/components/ui/section'
+
+interface PanelSectionUi {
+ label?: string
+ wrapper?: string
+}
+
+interface PanelSectionProps extends TestIdProps {
+ label: string
+ ui?: PanelSectionUi
+}
+
+const { label, testId, ui } = defineProps<PanelSectionProps>()
+
+const sectionCls = useSectionUI(ui)
+</script>
+
+<template>
+ <section :data-test-id="testId" :class="sectionCls.wrapper">
+ <div v-if="$slots.actions" class="flex items-center justify-between">
+ <label :class="sectionCls.label">{{ label }}</label>
+ <slot name="actions" />
+ </div>
+ <label v-else :class="sectionCls.label">{{ label }}</label>
+ <slot />
+ </section>
+</template>
diff --git a/src/components/ui/SegmentedControl.vue b/src/components/ui/SegmentedControl.vue
new file mode 100644
index 000000000..982e47d8a
--- /dev/null
+++ b/src/components/ui/SegmentedControl.vue
@@ -0,0 +1,68 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+
+import type { TestIdProps } from '@open-pencil/vue'
+
+export interface SegmentedControlOption extends TestIdProps {
+ value: string
+ label: string
+ disabled?: boolean
+}
+
+const {
+ options,
+ label,
+ size = 'sm',
+ testId
+} = defineProps<
+ TestIdProps & {
+ options: SegmentedControlOption[]
+ label?: string
+ size?: 'sm' | 'md'
+ }
+>()
+
+const modelValue = defineModel<string>({ required: true })
+const emit = defineEmits<{ change: [value: string] }>()
+
+const itemClass = computed(() =>
+ size === 'md' ? 'min-h-7 px-2 text-xs' : 'min-h-6 px-1.5 text-[11px]'
+)
+
+function select(value: string) {
+ modelValue.value = value
+ emit('change', value)
+}
+</script>
+
+<template>
+ <div
+ :data-test-id="testId"
+ role="radiogroup"
+ :aria-label="label"
+ class="inline-flex min-w-0 items-center gap-0.5 rounded bg-input p-0.5"
+ >
+ <button
+ v-for="option in options"
+ :key="option.value"
+ :data-test-id="option.testId"
+ type="button"
+ role="radio"
+ :aria-label="option.label"
+ :aria-checked="modelValue === option.value"
+ :disabled="option.disabled"
+ :class="[
+ itemClass,
+ 'flex min-w-0 cursor-pointer items-center justify-center rounded border border-transparent text-muted hover:bg-hover hover:text-surface disabled:cursor-not-allowed disabled:opacity-50',
+ modelValue === option.value
+ ? 'border-accent bg-accent text-white hover:bg-accent hover:text-white'
+ : ''
+ ]"
+ @click="select(option.value)"
+ >
+ <slot name="option" :option="option" :selected="modelValue === option.value">
+ <span class="truncate">{{ option.label }}</span>
+ </slot>
+ </button>
+ </div>
+</template>