Make memory graph cluster colors configurable#1162
Open
advaitpaliwal wants to merge 1 commit into
Open
Conversation
Comment on lines
+85
to
+88
| const swatches = | ||
| colors.clusterColors.length > 0 | ||
| ? colors.clusterColors.slice(0, 5) | ||
| : [colors.memStrokeDefault] |
There was a problem hiding this comment.
Inconsistent fallback behavior when clusterColors is empty. The legend shows [colors.memStrokeDefault] (single color), but the graph data functions in use-graph-data.ts fall back to DEFAULT_CLUSTER_COLORS (full palette). This causes a mismatch where the legend could display one color while the actual graph uses the default multi-color palette.
// Fix: Use consistent fallback
const swatches =
colors.clusterColors.length > 0
? colors.clusterColors.slice(0, 5)
: DEFAULT_CLUSTER_COLORS.slice(0, 5)This ensures the legend accurately represents the colors actually used in the graph when clusterColors is explicitly set to an empty array via overrides.
Suggested change
| const swatches = | |
| colors.clusterColors.length > 0 | |
| ? colors.clusterColors.slice(0, 5) | |
| : [colors.memStrokeDefault] | |
| const swatches = | |
| colors.clusterColors.length > 0 | |
| ? colors.clusterColors.slice(0, 5) | |
| : DEFAULT_CLUSTER_COLORS.slice(0, 5) | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clusterColorsto the memory graph theme contract--graph-cluster-colorsorcolors.clusterColorsWhy
Consumers can already override most graph colors through CSS variables or the
colorsprop, but cluster colors were still hard-coded in graph data and legend rendering. This lets host apps fully align the graph palette without patching package internals.Validation
bunx biome check packages/memory-graph/src/types.ts packages/memory-graph/src/constants.ts packages/memory-graph/src/hooks/use-graph-theme.ts packages/memory-graph/src/hooks/use-graph-data.ts packages/memory-graph/src/components/legend.tsxbun run check-typesinpackages/memory-graphbun run testinpackages/memory-graph(172 passed)