All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import { useTheme } from '@/providers/theme-provider';
|
|
|
|
interface ThemeToggleProps {
|
|
className?: string;
|
|
}
|
|
|
|
export function ThemeToggle({ className = '' }: ThemeToggleProps): React.JSX.Element {
|
|
const { theme, toggleTheme } = useTheme();
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={toggleTheme}
|
|
className={`btn-ghost rounded-md p-2 ${className}`}
|
|
title={`Switch to ${theme === 'dark' ? 'light' : 'dark'} mode`}
|
|
aria-label={`Switch to ${theme === 'dark' ? 'light' : 'dark'} mode`}
|
|
>
|
|
{theme === 'dark' ? (
|
|
<svg
|
|
className="h-5 w-5"
|
|
style={{ color: 'var(--warn)' }}
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor"
|
|
strokeWidth={1.5}
|
|
>
|
|
<circle cx="12" cy="12" r="4" />
|
|
<path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41" />
|
|
</svg>
|
|
) : (
|
|
<svg
|
|
className="h-5 w-5"
|
|
style={{ color: 'var(--text-2)' }}
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor"
|
|
strokeWidth={1.5}
|
|
>
|
|
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z" />
|
|
</svg>
|
|
)}
|
|
</button>
|
|
);
|
|
}
|