| 1 | import { LogOut, Moon, Sun } from 'lucide-react' |
| 2 | import { signOut } from '../lib/api' |
| 3 | |
| 4 | function toggleTheme() { |
| 5 | const dark = document.documentElement.classList.toggle('dark') |
| 6 | localStorage.theme = dark ? 'dark' : 'light' |
| 7 | } |
| 8 | |
| 9 | type Props = { className: string; button: string; label?: string } |
| 10 | |
| 11 | // Theme and sign out. They aren't places, so they stay out of the |
| 12 | // phone's bottom bar: there they live on your own profile. |
| 13 | export function Settings({ className, button, label }: Props) { |
| 14 | return ( |
| 15 | <div className={className}> |
| 16 | <button onClick={toggleTheme} className={button}> |
| 17 | <Moon size={20} className="dark:hidden" aria-hidden /> |
| 18 | <Sun size={20} className="hidden dark:block" aria-hidden /> |
| 19 | <span className={label}>Theme</span> |
| 20 | </button> |
| 21 | <button onClick={signOut} className={button}> |
| 22 | <LogOut size={20} aria-hidden /> |
| 23 | <span className={label}>Sign out</span> |
| 24 | </button> |
| 25 | </div> |
| 26 | ) |
| 27 | } |