Skip to content

Use one color picker for all colors - #14

Open
RrrrobertB1992 wants to merge 13 commits into
paxx12:mainfrom
RrrrobertB1992:one-color-picker
Open

RrrrobertB1992 wants to merge 13 commits into
paxx12:mainfrom
RrrrobertB1992:one-color-picker

Conversation

@RrrrobertB1992

@RrrrobertB1992 RrrrobertB1992 commented Oct 18, 2026 •

Copy link
Copy Markdown

Replaces the full picker per color (and the checkboxes for turning extra colors on) with one shared picker and a row of color buttons, so multi-color filament no longer means scrolling past a picker for every color.

What it does

  • Color buttons appear above the picker, showing only the colors in use, followed by a single +.
    • Tapping a button points the picker, hex box and hue slider at that color. "Editing Color N" shows which one.
    • + adds the next color, starting as a copy of the previous one (white if the previous code isn't valid), and selects it. A new + appears after it until the format's maximum is reached.
    • The buttons use the existing palette grid, so they wrap like the other palettes (4 per row on a typical phone), and work from the keyboard (Tab, Enter/Space) like the other palettes.
  • Under the picker, while there are 2 or more colors: "🗑 Remove Color N", "◀ Move left" and "Move right ▶".
    • Remove asks to confirm, works on any color including Color 1, and moves the later colors down (e.g. removing Color 1 of 3 makes the old 2 and 3 the new 1 and 2). With a single color there's no button row.
    • Move swaps the selected color with its neighbour, and the selection follows it.
    • Remove is first and the Move buttons are always shown (greyed out at the ends), so repeated taps never land on a different button.
  • Hex box
    • Typing keeps only hex digits, in upper case, up to 6. Autocorrect/autocomplete are off.
    • Pasting picks the code out of the pasted text (##FF5733, 0xFF5733, #ff5733cc, Color: #FF5733) and replaces the box; alpha is dropped and 3 digits are expanded.
    • A typed 3-digit code (e.g. F53) is accepted and expands to FF5533 when the box is left, when switching/adding/moving colors, and before writing, downloading or saving.
    • Any other length (1, 2, 4, 5, or empty) is invalid: after leaving the box it turns red with a message, and its preview and color button show red stripes instead of a color. Writing, downloading and saving (with Save colors per brand and material type #13) are blocked with a status message, and the picker jumps to the first bad color. The error clears as soon as the code is valid.
  • One-line hint ("Hold and drag on the picker, or type a hex code") for every color, so the picker stays at the same height when switching colors.
  • Formats with one color (e.g. OpenSpool Compat) keep the plain Color 1 picker; no buttons are shown. The hex box cleanup and validation still apply.
  • Unchanged underneath: the original color fields stay in the page (only the selected one shown), so reading, writing and files don't change.
  • Layouts: works with the current single "Additional Colors" checkbox (colors 2-4 are moved up next to Color 1 and the checkbox is hidden) and with a checkbox per color (Support up to 5 colors on OpenSpool tags #7). With the single checkbox, a white extra color still counts as unused, as before.
  • Saved colors (Save colors per brand and material type #13): if present, selecting a saved color hides the buttons along with the picker. Neither feature needs the other.

All the code is in a new public/colorslots.js, loaded after app.js; app.js isn't changed.

Testing

Tested on a Samsung Galaxy S26 (Chrome, Android) with real tags, together with #7 and #13:

  • Added colors 2-5 with + and set each one; tapping between them shows the right color in the picker each time.
  • Dragging the picker and the hue slider changes only the selected color.
  • Removing a middle color (e.g. Color 2 of 4) moves the later colors down.
  • Removing Color 1 of 3 makes the old 2 and 3 the new 1 and 2; removing Color 1 again leaves one color and the Remove button goes away.
  • Writing a tag after removing Color 1 and reading it back gives the colors in the new order.
  • Wrote and read back 1-color and multi-color tags; they load with the right number of buttons.
  • Selecting and deselecting a saved multi-color entry brings back the hand-picked colors, and writing with the new picker saves the colors.
  • Moved colors left and right; the button row stays in place, with the unavailable Move button greyed out.
  • 3-digit codes expand to 6 digits.
  • Invalid codes show the red stripes; the error only shows after leaving the box or trying to save/write, and clears as soon as the code is fixed.
  • Writing a tag or saving with an invalid color is blocked and jumps back to the bad hex box, even after switching to another color.
  • Typing in a hex box and tapping + right away adds a color on the first tap.
  • Adding a color after an invalid one starts the new color as white.
  • A new color starts as a copy of the previous one.
  • Remove asks to confirm; cancelling keeps the color.
  • The one-line hint keeps the picker at the same height when switching between Color 1 and the others.
  • Lowercase letters switch to upper case, non-hex characters are ignored, and a pasted code with a leading # drops the #.
  • Pasting #abc gives AABBCC right away; typing F53 shows no error while still in the box; 1, 2, 4, 5 digits or an empty box show the error after leaving it.
  • Pasting codes with multiple #s in front (e.g. ##FF5733) gives the right code.

Everything above, plus keyboard use (not tested on the phone), is also covered by automated Playwright tests (headless Chromium, mocked Web NFC) on both color layouts.

Made with help from Claude

A row of color buttons above the picker picks which color it edits.
Only the colors in use are shown, followed by a single "+" that adds
the next color. Colors 2 and up get a Remove button; removing a color
moves the later ones down. This replaces scrolling through a full
picker per color and the checkbox(es) for turning extra colors on.

The original color fields stay in the page with only the selected one
shown, so reading, writing and file handling are unchanged. Works with
the single "Additional Colors" checkbox (colors 2-4 move up next to
Color 1) and with a checkbox per color. Formats with one color keep
the plain Color 1 picker.

Made with help from Claude
Their inline display style was overriding the rule that hides them.

Made with help from Claude
With two or more colors, any color can be removed, including Color 1;
the later colors move down one. With a single color there's no Remove
button.

Made with help from Claude
- Color buttons and + work from the keyboard (Tab, Enter/Space), like
  the other palettes, and keep focus after a press.
- A new color starts as a copy of the previous one instead of white.
- "◀ Move left" / "Move right ▶" swap the selected color with its
  neighbour.
- Removing a color asks to confirm first.

Made with help from Claude
Remove now comes first in the row, and Move left/right are always shown
(greyed out when they can't be used), so repeated taps on a Move button
never land on a different button.

Made with help from Claude
- Every color shows the same one-line hint ("Hold and drag on the
  picker, or type a hex code"), so the picker no longer moves up and
  down when switching between Color 1 and the others.
- Hex boxes keep only hex digits, switch to upper case, stop at 6
  characters and drop a pasted leading #. The cursor stays where it was
  when a character is rejected.

Made with help from Claude
- A 3-digit hex code (e.g. F53) expands to 6 digits (FF5533) when the
  box is left, when switching, adding or moving colors, and right before
  writing, downloading or saving.
- Any other length (1, 2, 4, 5 digits, or empty) is not a valid color:
  the box turns red with a message under it, and its color button gets
  a red outline. Writing, downloading and "Save current colors" are
  stopped with a status message, and the picker jumps to the first bad
  color. The error clears as soon as the code is valid.

Made with help from Claude
Leaving a hex box updates the page, which redrew the color buttons in
the middle of the tap that left it, so the first tap on + or another
color could be lost. The buttons are now only redrawn when the number
of colors or the selected color changes.

Made with help from Claude
While a hex code isn't valid, its preview box and color button show a
red-striped pattern instead of a color (the browser would show e.g.
"C039" as a see-through color, and the button showed white). A 3-digit
code is shown as its expanded color. A bad color's button keeps its red
outline even when selected.

Made with help from Claude
The box's 7-character limit cut pastes like "##FF5733" short before
they could be cleaned, leaving 5 digits. Pasting now picks the first
stand-alone 3, 6 or 8 digit hex code out of the pasted text ("##FF5733",
"0xFF5733", " #ff5733cc ", "Color: #FF5733") and puts it in the box,
replacing what was there; alpha is dropped. Clipboard text inserted by
a keyboard without a paste event is handled the same way. The box has
no browser length limit any more; typing still stops at 6 digits.

Made with help from Claude
A 3-digit code no longer shows the "not a valid color" error while it's
still in the box (it's expanded on leaving, or before writing/saving),
and a pasted 3-digit code like "#abc" is expanded to AABBCC right away.

Made with help from Claude

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant