jongalloway / jongalloway/DiagramForge
Standardize theme palette precedence across diagram types
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 12
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Standardize how DiagramForge chooses colors for repeated visual elements across diagram types so theme behavior is predictable and consistent.
This is a follow-up to the Target Diagram work and should stay out of the Target Diagram PR itself.
Problem
DiagramForge currently has a clear distinction between:
- semantic theme colors such as
PrimaryColor,SecondaryColor, andAccentColor - repeated-element palettes such as
NodePalette/NodeStrokePalette
But that distinction is not applied consistently across diagram types.
Examples:
- generic node rendering prefers
NodePalettewhen present - snake layout assigns circle colors from
NodePalette - Target ring colors derive a custom set from semantic theme colors plus
NodePalette - XY chart series colors currently derive a separate palette from
AccentColorand related theme colors rather than preferringNodePalette
The result is that a theme can look coherent in one diagram kind and behave differently in another, even when the caller expects the palette to be the main source of repeated colors.
Goal
Make DiagramForge theme behavior more standard and predictable by defining a single precedence model for repeated colors.
Recommended direction:
- Semantic theme colors define overall theme identity.
NodePalettedefines the default color cycle for repeated visual elements.- Diagram-specific derivation should happen only when needed, and only as an explicit extension of the palette model.
- When no palette is present, diagram types may derive a small fallback cycle from semantic colors.
Scope
In scope:
- define precedence rules for repeated-element colors
- document whether repeated elements should prefer
NodePalettefirst - align XY chart series color selection with the same rules used by other diagram kinds where appropriate
- review Target and snake behavior against the standard rules
- update docs for theme semantics vs palette semantics
- add focused tests that lock the precedence model down
Out of scope:
- redesigning all built-in themes
- introducing new public theme models or breaking changes unless clearly justified
- broad visual redesign work unrelated to color-selection rules
Recommended implementation direction
Create and document a standard precedence order such as:
- explicit element color override
- diagram-specific explicit palette override
Theme.NodePalette/Theme.NodeStrokePalette- derived fallback from semantic theme colors
- legacy single-fill fallback (
NodeFillColor/NodeStrokeColor)
The exact order can be refined during implementation, but the important part is that it is shared and documented.
Candidate files
src/DiagramForge/Models/Theme.cssrc/DiagramForge/Rendering/SvgNodeWriter.cssrc/DiagramForge/Rendering/SvgRenderSupport.cssrc/DiagramForge/Layout/DefaultLayoutEngine.Snake.cssrc/DiagramForge/Layout/DefaultLayoutEngine.Target.csdoc/theming.md- tests under
tests/DiagramForge.Tests
Acceptance criteria
- repeated color selection rules are documented in code and in
doc/theming.md - generic nodes, snake, target, and XY chart follow the same documented precedence model unless a deliberate exception is documented
- themes with a 3-color
NodePaletteuse that palette predictably rather than silently bypassing it - themes created from
FromPalette(...)continue to work, with the expanded derived palette participating in the same standard precedence rules - targeted tests cover the agreed precedence behavior across at least generic nodes, snake, and XY chart
Why now
The Target Diagram work surfaced that DiagramForge has the right building blocks already, but color selection policy is still partially implicit and partially diagram-specific. Locking down the standard now will reduce future drift as more diagram kinds are added.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading src/DiagramForge/Models/Theme.cs and the candidate rendering and layout files, then inspect tests under tests/DiagramForge.Tests. Define the shared precedence rules before changing generic nodes, snake, target, and XY chart behavior. Done means the rules are documented in doc/theming.md and code, with focused tests covering the agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- computer-graphics, documentation, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100