Compare commits

..

No commits in common. "fix/stroke-only-shape-color-control" and "main" have entirely different histories.

2 changed files with 3 additions and 25 deletions

View File

@ -1,7 +1,6 @@
import { useLayoutEffect, useRef, type ReactNode } from 'react'
import { fontOptions } from '../data'
import { deviceOptions, getDevicePlacement } from '../mockups/catalog'
import { strokeOnlyShapes } from '../shapes'
import {
AlignCenter,
AlignLeft,
@ -236,13 +235,7 @@ const ShapeSettings = ({ element, onUpdate }: {
}) => (
<div className="toolbar-popover-section">
<strong className="toolbar-popover-heading">Shape details</strong>
{/* `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 })} />
)}
<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>
@ -441,17 +434,8 @@ export const ElementToolbar = ({ element, onUpdate, onUploadToDevice, onDuplicat
{element.type === 'text' && <TextControls element={element} onUpdate={onUpdate} />}
{element.type === 'shape' && (
<>
<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 })} />
)}
<ToolbarColor label="Fill" value={element.color} onChange={(color) => onUpdate({ color })} />
<ToolbarColor label="Stroke" value={element.strokeColor ?? '#171713'} onChange={(strokeColor) => onUpdate({ strokeColor })} />
<ToolbarRange
label="Stroke"
value={element.strokeWidth ?? 0}

View File

@ -22,12 +22,6 @@ 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,