feat: display the color itself instead of gray if there's only one color in the handle (#6980)

refactor: Improve handle color rendering with unique color handling
This commit is contained in:
Gabriel Luiz Freitas Almeida 2025-03-11 12:19:39 -03:00 committed by GitHub
commit 339e4d28c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -278,11 +278,17 @@ const HandleRenderComponent = memo(function HandleRenderComponent({
const isNullHandle =
filterPresent && !(openHandle || ownDraggingHandle || ownFilterHandle);
// Create a Set from colorName to remove duplicates
const colorNameSet = new Set(colorName || []);
const uniqueColorCount = colorNameSet.size;
const firstUniqueColor =
colorName && colorName.length > 0 ? colorName[0] : "";
const handleColorName = connectedEdge
? connectedColor
: colorName!.length > 1
: uniqueColorCount > 1
? "secondary-foreground"
: "datatype-" + colorName![0];
: "datatype-" + firstUniqueColor;
const handleColor = isNullHandle
? dark
@ -290,15 +296,15 @@ const HandleRenderComponent = memo(function HandleRenderComponent({
: "hsl(var(--accent-gray-foreground)"
: connectedEdge
? "hsl(var(--datatype-" + connectedColor + "))"
: colorName!.length > 1
: uniqueColorCount > 1
? "hsl(var(--secondary-foreground))"
: "hsl(var(--datatype-" + colorName![0] + "))";
: "hsl(var(--datatype-" + firstUniqueColor + "))";
const accentForegroundColorName = connectedEdge
? "hsl(var(--datatype-" + connectedColor + "-foreground))"
: colorName!.length > 1
: uniqueColorCount > 1
? "hsl(var(--input))"
: "hsl(var(--datatype-" + colorName![0] + "-foreground))";
: "hsl(var(--datatype-" + firstUniqueColor + "-foreground))";
const currentFilter = left
? {