Badge: fix page crash when color isn't defined

Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1650
This commit is contained in:
Alex Gleason 2024-04-16 15:35:50 -05:00
parent 1518615767
commit b86da5f426
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -13,7 +13,9 @@ const Badge: React.FC<IBadge> = ({ 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;