From b86da5f426a48daadf5da8516b65fb13222ee2d3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 16 Apr 2024 15:35:50 -0500 Subject: [PATCH] Badge: fix page crash when color isn't defined Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1650 --- src/components/badge.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/badge.tsx b/src/components/badge.tsx index ac3c60a9e..e5476ca81 100644 --- a/src/components/badge.tsx +++ b/src/components/badge.tsx @@ -13,7 +13,9 @@ const Badge: React.FC = ({ title, slug, color }) => { const fallback = !['patron', 'admin', 'moderator', 'opaque', 'badge:donor'].includes(slug); const isDark = useMemo(() => { - const hsl = hexToHsl(color!); + if (!color) return false; + + const hsl = hexToHsl(color); if (hsl && hsl.l > 50) return false;