Add title text to theme switcher

This commit is contained in:
Sam Becker 2024-07-21 19:15:27 -05:00
parent 69fa01e20b
commit 91a17369bd
2 changed files with 7 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import { SHOULD_PREFETCH_ALL_LINKS } from '@/site/config';
export default function SwitcherItem({
icon,
title,
href,
className: classNameProp,
onClick,
@ -12,6 +13,7 @@ export default function SwitcherItem({
prefetch = SHOULD_PREFETCH_ALL_LINKS,
}: {
icon: JSX.Element
title?: string
href?: string
className?: string
onClick?: () => void
@ -41,9 +43,9 @@ export default function SwitcherItem({
return (
href
? <Link {...{ href, className, prefetch }}>
? <Link {...{ title, href, className, prefetch }}>
{renderIcon()}
</Link>
: <div {...{ onClick, className }}>{renderIcon()}</div>
: <div {...{ title, onClick, className }}>{renderIcon()}</div>
);
};

View File

@ -22,16 +22,19 @@ export default function ThemeSwitcher () {
return (
<Switcher>
<SwitcherItem
title="System"
icon={<BiDesktop size={16} />}
onClick={() => setTheme('system')}
active={theme === 'system'}
/>
<SwitcherItem
title="Light"
icon={<BiSun size={18} />}
onClick={() => setTheme('light')}
active={theme === 'light'}
/>
<SwitcherItem
title="Dark"
icon={<BiMoon size={16} />}
onClick={() => setTheme('dark')}
active={theme === 'dark'}