chore: handle case where theme is undefined

This commit is contained in:
Rotimi Best
2026-05-21 14:11:30 +01:00
parent ec92fc5083
commit 9043bede59
@@ -2,10 +2,10 @@ import { darken, lighten } from 'color2k';
import { tc } from '$lib/utils/functions/trycatch';
export function setTheme(theme: string) {
export function setTheme(theme: string = '') {
localStorage.setItem('theme', theme);
if (theme.includes('#')) {
if (theme?.includes('#')) {
const escapedHex = theme.replace(/"/g, '\\"');
document.body.setAttribute('data-theme', escapedHex);