Skip to content

SLOP-27: Fix CSS formatter output for empty palette#1

Open
tosfos wants to merge 1 commit intomasterfrom
SLOP-27-fix-css-empty-palette
Open

SLOP-27: Fix CSS formatter output for empty palette#1
tosfos wants to merge 1 commit intomasterfrom
SLOP-27-fix-css-empty-palette

Conversation

@tosfos
Copy link
Contributor

@tosfos tosfos commented Feb 13, 2026

Jira

SLOP-27

Summary

When css.generate([]) is called with an empty palette, the formatter still appends the "Semantic color mapping" block that references --color-primary, --color-secondary, --color-primary-rgb, and --color-accent. Those variables are never defined for an empty palette, so the output is invalid CSS.

Changes

  • colormaestro/formatters/css.py: If palette is empty, return ":root {\n}\n" immediately and do not add the semantic block or dark-mode block.
  • tests/test_generators.py: Use dark_mode=True instead of dark=True when calling ui_palette.generate() so the test matches the API (fixes test bug only).

Verification

  • pytest tests/test_formatters.py -k "CSS or empty" — all 7 passed (including test_generate_empty).
  • Full suite: 30 passed; 3 other failures are pre-existing (generator/contrast assertions).

GitHub issue

To be created and linked.

- colormaestro/formatters/css.py: return minimal ':root {}' when palette is
  empty instead of appending semantic block with undefined variables.
- tests/test_generators.py: use dark_mode=True for ui_palette.generate().

Co-authored-by: Cursor <cursoragent@cursor.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