Skip to content

DRY: Palette color onChange handler duplicated inline for color picker and hex input #10

@cjv

Description

@cjv

Problem

In src/components/Sidebar.tsx, the palette edit section maps over state.palette and renders two inputs per slot. Both the <input type="color"> and <input type="text"> share the same two-line handler written out twice inline:

onChange={(e) => { state.setPaletteColor(i, e.target.value); setSelectedPreset('custom'); }}

Affected lines: ~158–169.

Proposed fix

Extract the handler above the return:

const handlePaletteChange = (i: number, color: string) => {
  state.setPaletteColor(i, color);
  setSelectedPreset('custom');
};

Reference it from both inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions