Skip to content

feat(theme): custom theme editor foundation#17

Open
noahbclarkson wants to merge 10 commits intomainfrom
feat/theme-editor
Open

feat(theme): custom theme editor foundation#17
noahbclarkson wants to merge 10 commits intomainfrom
feat/theme-editor

Conversation

@noahbclarkson
Copy link
Copy Markdown
Owner

Summary

Foundation for a custom theme editor UI. This PR adds:

  • Serialize support for Theme: and now derive
  • ** mutation methods**:
    • — directly set the active theme
    • — add to available list and activate
  • **** — serialize any theme to JSON
  • **** — save to
  • Roundtrip tests verifying serialize → deserialize works correctly

Format notes

  • serializes as lowercase (, ) to match the existing JSON loader
  • serializes as (8-char hex with alpha), which parses correctly
  • Existing themes in JSON files (6-char hex) load normally

What's NOT included (next PRs)

  • Theme Editor dialog UI (color pickers, preview)
  • Export/import buttons in Settings modal
  • Delete custom theme

Tests

  • — verifies output structure
  • — verifies full roundtrip of Catppuccin Mocha

CI

CI will run on this PR. Draft until UI work is complete.

@noahbclarkson noahbclarkson marked this pull request as ready for review April 19, 2026 00:51
noahbclarkson pushed a commit that referenced this pull request Apr 19, 2026
Enables the Theme Editor UI to read Hsla values back from a serialized
theme and edit them as hex strings. The function:
- Converts HSL to RGB using the standard algorithm
- Outputs #RRGGBB for fully-opaque colors (a=1.0)
- Outputs #RRGGBBAA for transparent colors (a<1.0)
- Preserves Catppuccin Mocha and other built-in themes through roundtrip

7 new tests covering pure colors, transparency, black, white, and roundtrip
on real theme data.

Ref: PR #17
noahbclarkson pushed a commit that referenced this pull request Apr 20, 2026
Enables the Theme Editor UI to read Hsla values back from a serialized
theme and edit them as hex strings. The function:
- Converts HSL to RGB using the standard algorithm
- Outputs #RRGGBB for fully-opaque colors (a=1.0)
- Outputs #RRGGBBAA for transparent colors (a<1.0)
- Preserves Catppuccin Mocha and other built-in themes through roundtrip

7 new tests covering pure colors, transparency, black, white, and roundtrip
on real theme data.

Ref: PR #17
Forge and others added 10 commits April 21, 2026 05:46
…eState

Foundation for custom theme editor UI.

- Add Serialize to Theme and Appearance (with lowercase rename)
- ThemeState: add set_active_theme() and insert_theme() methods
- json_theme: add serialize_theme_to_json() and save_theme_to_file()
- 2 new roundtrip tests: serialize produces valid JSON, serialize→deserialize roundtrip

Hsla serializes to #rrggbbaa hex (8-char), compatible with hex_to_hsla loader.
Enables the Theme Editor UI to read Hsla values back from a serialized
theme and edit them as hex strings. The function:
- Converts HSL to RGB using the standard algorithm
- Outputs #RRGGBB for fully-opaque colors (a=1.0)
- Outputs #RRGGBBAA for transparent colors (a<1.0)
- Preserves Catppuccin Mocha and other built-in themes through roundtrip

7 new tests covering pure colors, transparency, black, white, and roundtrip
on real theme data.

Ref: PR #17
…ditor_dialog

- Fix closure type inference in build_color_fields and build_status_fields
  using explicit type annotations with fn pointer types
- Add ColorFieldSpec and StatusFieldSpec type aliases for complex types
- Fix needless_borrow clippy warnings on hex_val and text
- Remove unused StyledText and TextInputEvent imports
- Fix parse_hex_or_default to accept &str directly
- Add missing lifetime parameters to type aliases

Build: cargo build ✓ cargo test --workspace ✓ cargo clippy ✓
Previously the event was emitting self.editable_theme (the pre-save
theme) instead of new_theme (the actually-saved theme with updated
colors). Although no current subscriber depends on this, the event
contract should reflect the actual saved state.
Without this, if a user keeps the dialog open and edits a second
color field before saving again, the second save would start from
the original theme values rather than the just-saved state, causing
the first edit to be silently lost.
Add Ctrl+Shift+T / Alt+9 to open theme editor directly:
- CommandId::OpenThemeEditor in command_palette enum
- as_str, display_label, TryFrom for OpenThemeEditor
- PaletteCommand entry with Ctrl+Shift+T shortcut
- Workspace command handler for OpenThemeEditor
- key_handler: Escape dismisses editor, Ctrl+Shift+T / Alt+9 opens it
- any_overlay_active blocks panel shortcuts when editor is open
Add Alt+8 (stashes) and Ctrl+Shift+T / Alt+9 (theme editor) to the
shortcuts help overlay under the Panels section.
- Default visible=false so the editor no longer appears on workspace launch.
- Pre-populate inputs with the current hex via set_text instead of only
  set_placeholder. Empty inputs previously caused save() to pass "" to
  hex_to_hsla, which returned black and reset every visible field.
- save() now skips empty inputs and keeps the current theme value.
- Preview swatches fall back to the current theme color when the typed text
  is empty or malformed, rather than flashing to black.
- Clear save_status when the dialog is reopened, and render it in the footer
  (success or error) so the user gets feedback and sees the saved file path.
- Remove the dead "cmd+enter" branch from the key handler; keystroke.key
  holds just the key name, never a modifier combination.
- Tidy up redundant parentheses around setter calls.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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