palabras: borrar el recolor muerto de la Paleta (ya es solo display)

Tras hacer la Paleta un grid de solo display (`ca883e819`), el código de recolor quedó
sin uso: `writePaletteColor` / `resetPalette` / `paletteModified` + la fila del ↺ reset +
el `onPick`/`presets` del swatch. Borrados. `onPick` de `PalabrasColorRow` pasa a OPCIONAL
(el modo swatchOnly no recolorea). Conservados `paletteValueOf` (lo lee el swatch),
`commitDocScheme`/`baseScheme` (los usan Medida/Márgenes/Texto).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@
alpha-0.1-sec-dom
dev 3 months ago
parent 4adcc4c7fd
commit 712ea236ba

@ -25,7 +25,8 @@
* tooltip), NO picker on click — it is a legend of the document's colours here,
* not an editor (user 2026-07-18). N colours read as a grid, not a tall list. */
swatchOnly?: boolean;
onPick: (hex: string | undefined) => void;
/** Recolour callback — for the editable row. Omitted in `swatchOnly` (display). */
onPick?: (hex: string | undefined) => void;
} = $props();
let draft = $state<ColorValue | undefined>(undefined);
@ -48,9 +49,9 @@
size="sm"
bind:value={draft}
onValueChange={(cv: ColorValue | undefined) => {
if (cv === undefined && current !== undefined) onPick(undefined);
if (cv === undefined && current !== undefined) onPick?.(undefined);
}}
onValueChangeEnd={(cv: ColorValue | undefined) => onPick(cv?.hex)}
onValueChangeEnd={(cv: ColorValue | undefined) => onPick?.(cv?.hex)}
>
<ColorPicker.Control>
<!-- The Trigger already paints ONE swatch (showSwatch); no inner ValueSwatch. -->

@ -404,34 +404,11 @@
assembleRouteStyles(route, style);
}
// Palette editing — recolour existing entries (add / remove / rename = v2).
// The delta stores the FULL array (names ride along); clearing a swatch
// restores that entry from the app palette, and when every entry matches the
// app again the whole delta is dropped.
const paletteModified = $derived(docDeltas?.palette !== undefined);
// Palette entry → its hex. The Paleta grid is a DISPLAY of the document's
// colours (scheme-driven); per-swatch recolour was removed 2026-07-18 (the
// palette comes from the esquema, like typography — not edited color-by-color).
const paletteValueOf = (e: PalabrasPaletteEntry | undefined) =>
e === undefined ? undefined : typeof e === 'string' ? e : e.value;
function writePaletteColor(index: number, hex: string | undefined) {
const base = baseScheme.palette ?? [];
const next = (scheme.palette ?? []).map((e, i) => {
if (i !== index) return e;
const value = hex ?? paletteValueOf(base[i]);
if (value === undefined) return e;
return typeof e === 'string' ? value : { ...e, value };
});
const equalsApp =
next.length === base.length &&
next.every((e, i) => paletteValueOf(e) === paletteValueOf(base[i]));
const bag: Record<string, unknown> = { ...docDeltas };
if (equalsApp) delete bag.palette;
else bag.palette = next;
commitDocScheme(bag);
}
function resetPalette() {
const bag: Record<string, unknown> = { ...docDeltas };
delete bag.palette;
commitDocScheme(bag);
}
// Doc pills — measure, canvas margins (inline padding) and vertical rhythm.
// All anchored steps (palanca #1); raw values live in the bag. EVERY control
@ -1589,36 +1566,15 @@
<ScrollArea autosize scrollbars="vertical" type="auto" size="sm" data-palabras-scroll>
<ScrollArea.Viewport>
<div data-palabras-panel-fields>
{#if paletteModified}
<div data-palabras-section-reset-row>
<Button
variant="ghost"
size="sm"
iconOnly
data-palabras-section-reset
aria-label="{ts(
'#?components.palabras.action.reset-section|Restablecer'
)} {ts(PALETTE_SECTION)}"
title={ts(
'#?components.palabras.action.reset-section-title|Restablecer la sección a los valores por defecto'
)}
onclick={resetPalette}
>
{#snippet icon()}<RotateCcw />{/snippet}
</Button>
</div>
{/if}
<!-- Palette = a GRID of swatches, not a row-per-colour (that read as a
tall, scrolling list). Each swatch opens the full picker; its name
rides as a hover tooltip (user 2026-07-18). -->
<!-- Palette = a DISPLAY grid of swatches (the document's colours, the
name in a tooltip). Scheme-driven, not edited per-swatch here
(user 2026-07-18: the palette comes from the document's esquema). -->
<div data-palabras-palette-grid>
{#each scheme.palette ?? [] as entry, i (i)}
<PalabrasColorRow
swatchOnly
label={typeof entry === 'string' ? entry : entry.name}
current={paletteValueOf(entry)}
presets={schemePaletteValues(scheme)}
onPick={(hex) => writePaletteColor(i, hex)}
/>
{/each}
</div>

Loading…
Cancel
Save

Powered by TurnKey Linux.