Compare commits

...

1 Commits

Author SHA1 Message Date
8cbb022bed fix(shapes): hide the dead Stroke color control for line-only shapes
ShapeGraphic renders ring/line/arrow/wave as a single colored line using
only `color` (the "Fill" swatch) — `strokeColor` is never read for them.
The toolbar still showed a separate "Stroke" color picker for these
shapes (in both the main toolbar row and the "More settings" popover),
bound to `strokeColor`. Dragging it had zero visible effect, and its
default swatch (#171713) didn't even match the shape's actual rendered
color (the default lime #d8ff55), since every new shape gets both
fields set regardless of shape type.

Hide the color picker for ring/line/arrow/wave (`strokeOnlyShapes` in
shapes.ts) and relabel the remaining color control "Color" instead of
"Fill" for them, since there is no fill. Filled shapes (circle, square,
star, etc.) are unaffected — they still show both Fill and Stroke.

Verified live: bun run dev + browse, inspected the real toolbar DOM.
Before: Line/Arrow/Wave/Ring showed Fill + a dead Stroke color button
with a mismatched swatch. After: they show just "Color" (swatch
correctly matches the rendered line), Stroke width, and Shadow. Circle
still shows Fill + Stroke unchanged. typecheck/lint/build clean,
test 416/416, no regressions.
2026-10-29 12:43:54 +03:00
2 changed files with 25 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import { useLayoutEffect, useRef, type ReactNode } from 'react'
import { fontOptions } from '../data'
import { deviceOptions, getDevicePlacement } from '../mockups/catalog'
import { strokeOnlyShapes } from '../shapes'
import {
AlignCenter,
AlignLeft,
@ -235,7 +236,13 @@ const ShapeSettings = ({ element, onUpdate }: {
}) => (
<div className="toolbar-popover-section">
<strong className="toolbar-popover-heading">Shape details</strong>
<ToolbarColor label="Stroke" value={element.strokeColor ?? '#171713'} onChange={(strokeColor) => onUpdate({ strokeColor })} />
{/* `ShapeGraphic` never reads `strokeColor` for these line-only shapes
(their visible color is `color`, shown as "Fill"/"Color" in the main
toolbar), so this picker must stay hidden here or it silently does
nothing. */}
{!strokeOnlyShapes.has(element.shape) && (
<ToolbarColor label="Stroke" value={element.strokeColor ?? '#171713'} onChange={(strokeColor) => onUpdate({ strokeColor })} />
)}
<AdvancedSlider label="Stroke width" value={element.strokeWidth ?? 0} min={0} max={12} displayValue={`${element.strokeWidth ?? 0} px`} onChange={(strokeWidth) => onUpdate({ strokeWidth })} />
<AdvancedSlider label="Shadow" value={element.shadow ?? 0} min={0} max={100} displayValue={`${element.shadow ?? 0}%`} onChange={(shadow) => onUpdate({ shadow })} />
</div>
@ -434,8 +441,17 @@ export const ElementToolbar = ({ element, onUpdate, onUploadToDevice, onDuplicat
{element.type === 'text' && <TextControls element={element} onUpdate={onUpdate} />}
{element.type === 'shape' && (
<>
<ToolbarColor label="Fill" value={element.color} onChange={(color) => onUpdate({ color })} />
<ToolbarColor label="Stroke" value={element.strokeColor ?? '#171713'} onChange={(strokeColor) => onUpdate({ strokeColor })} />
<ToolbarColor
label={strokeOnlyShapes.has(element.shape) ? 'Color' : 'Fill'}
value={element.color}
onChange={(color) => onUpdate({ color })}
/>
{/* `ShapeGraphic` renders ring/line/arrow/wave as a single
colored line using `color` only; `strokeColor` is never read
for them, so this picker would silently do nothing. */}
{!strokeOnlyShapes.has(element.shape) && (
<ToolbarColor label="Stroke" value={element.strokeColor ?? '#171713'} onChange={(strokeColor) => onUpdate({ strokeColor })} />
)}
<ToolbarRange
label="Stroke"
value={element.strokeWidth ?? 0}

View File

@ -22,6 +22,12 @@ export const shapeCatalog: {
{ id: 'wave', label: 'Wave', group: 'Lines' },
]
// `ShapeGraphic` draws these as a single colored line with no fill, so their
// visible color comes from `color` (the toolbar's "Fill"/"Color" swatch) —
// `strokeColor` is never read for them. The toolbar must not offer a separate
// "Stroke" color control for these shapes; it would silently do nothing.
export const strokeOnlyShapes: ReadonlySet<ShapeElement['shape']> = new Set(['ring', 'line', 'arrow', 'wave'])
export const shapeAspectRatio: Record<ShapeElement['shape'], number> = {
circle: 1,
square: 1,