Skip to content

Commit

Permalink
add handling for invalid/undefined color when hovering (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
seveibar authored Jan 31, 2025
1 parent 43646ba commit 070daa3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions site/components/InteractiveGraphics/Rect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const Rect = ({
index: number
}) => {
const defaultColor = defaultColors[index % defaultColors.length]
const { center, width, height, fill, stroke, layer, step } = rect
let { center, width, height, fill, stroke, layer, step } = rect
const { activeLayers, activeStep, realToScreen } = interactiveState
const [isHovered, setIsHovered] = useState(false)

Expand All @@ -29,7 +29,14 @@ export const Rect = ({

let backgroundColor = hasStrokeOrFill ? fill || "transparent" : defaultColor
if (isHovered) {
backgroundColor = lighten(0.2, backgroundColor)
try {
backgroundColor = lighten(0.2, backgroundColor)
} catch (e) {}
try {
if (stroke) {
stroke = lighten(0.2, stroke)
}
} catch (e) {}
}

return (
Expand Down

0 comments on commit 070daa3

Please sign in to comment.