misc: theme toggle, icons, logos

This commit is contained in:
joshuafhiggins committed 2026-06-01 23:40:11 -04:00 Verified
1 parent 39e7147068
commit e85453174e
8 files changed
+81 -45

No files matched your search

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

+15 -3
View File
@@ -2,18 +2,25 @@ import { Geist, Geist_Mono, Inter } from "next/font/google"
import "./globals.css"
import { ThemeProvider } from "@/components/theme-provider"
import { cn } from "@/lib/utils";
import { cn } from "@/lib/utils"
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"
import { AppSidebar } from "@/components/app-sidebar"
import { PlayerBar } from "@/components/player-bar"
import type { Metadata } from "next"
const inter = Inter({subsets:['latin'],variable:'--font-sans'})
const inter = Inter({ subsets: ["latin"], variable: "--font-sans" })
const fontMono = Geist_Mono({
subsets: ["latin"],
variable: "--font-mono",
})
export const metadata: Metadata = {
title: "oTunes",
description: "Our Music",
// keywords: ["Next.js", "React", "SEO"],
}
export default function RootLayout({
children,
}: Readonly<{
@@ -23,7 +30,12 @@ export default function RootLayout({
<html
lang="en"
suppressHydrationWarning
className={cn("antialiased", fontMono.variable, "font-sans", inter.variable)}
className={cn(
"antialiased",
fontMono.variable,
"font-sans",
inter.variable
)}
>
<body className={"overflow-x-hidden"}>
<ThemeProvider>
+17 -4
View File
@@ -24,8 +24,11 @@ import {
SidebarMenuButton,
SidebarMenuItem,
} from "@/components/ui/sidebar"
import { ThemeToggle } from "@/components/theme-toggle"
import Image from "next/image"
import Link from "next/link"
import { useTheme } from "next-themes"
import * as React from "react"
const browse = [
{ title: "Home", path: "/", icon: House },
@@ -51,11 +54,20 @@ export function AppSidebar() {
const router = useRouter()
const pathname = usePathname()
const { resolvedTheme } = useTheme()
const [mounted, setMounted] = React.useState(false)
React.useEffect(() => {
setMounted(true)
}, [])
const isDark = mounted && resolvedTheme === "dark"
return (
<Sidebar>
<SidebarHeader>
<div className="flex items-center gap-1 px-2 py-1">
<Image src={"/logo.svg"} alt={"oTunes"} width={20} height={20} className="size-5 dark:invert" />
<Image src={isDark ? "/logo-dark.png" : "/logo.png"} alt={"oTunes"} width={20} height={20} className="size-5" />
<span className="text-lg font-semibold tracking-tight">oTunes</span>
</div>
</SidebarHeader>
@@ -120,13 +132,14 @@ export function AppSidebar() {
<SidebarFooter>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg">
<SidebarMenuItem className="flex items-center justify-around gap-1">
<SidebarMenuButton size="lg" className="min-w-0 flex-1">
<Avatar size="sm">
<AvatarFallback>JH</AvatarFallback>
</Avatar>
<span>Joshua Higgins</span>
<span className="truncate">Joshua Higgins</span>
</SidebarMenuButton>
<ThemeToggle />
</SidebarMenuItem>
</SidebarMenu>
</SidebarFooter>
+18 -38
View File
@@ -15,55 +15,35 @@ function ThemeProvider({
disableTransitionOnChange
{...props}
>
<ThemeHotkey />
<ThemeFavicon />
{children}
</NextThemesProvider>
)
}
function isTypingTarget(target: EventTarget | null) {
if (!(target instanceof HTMLElement)) {
return false
}
return (
target.isContentEditable ||
target.tagName === "INPUT" ||
target.tagName === "TEXTAREA" ||
target.tagName === "SELECT"
)
}
function ThemeHotkey() {
const { resolvedTheme, setTheme } = useTheme()
function ThemeFavicon() {
const { resolvedTheme } = useTheme()
React.useEffect(() => {
function onKeyDown(event: KeyboardEvent) {
if (event.defaultPrevented || event.repeat) {
return
}
if (event.metaKey || event.ctrlKey || event.altKey) {
return
}
if (event.key.toLowerCase() !== "d") {
return
}
if (isTypingTarget(event.target)) {
return
}
setTheme(resolvedTheme === "dark" ? "light" : "dark")
if (!resolvedTheme) {
return
}
window.addEventListener("keydown", onKeyDown)
const href =
resolvedTheme === "dark" ? "/favicon-dark.ico" : "/favicon.ico"
return () => {
window.removeEventListener("keydown", onKeyDown)
for (const rel of ["icon", "shortcut icon"] as const) {
let link = document.querySelector<HTMLLinkElement>(`link[rel="${rel}"]`)
if (!link) {
link = document.createElement("link")
link.rel = rel
document.head.appendChild(link)
}
link.href = href
}
}, [resolvedTheme, setTheme])
}, [resolvedTheme])
return null
}
+31
View File
@@ -0,0 +1,31 @@
"use client"
import * as React from "react"
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
import { Button } from "@/components/ui/button"
export function ThemeToggle() {
const { resolvedTheme, setTheme } = useTheme()
const [mounted, setMounted] = React.useState(false)
React.useEffect(() => {
setMounted(true)
}, [])
const isDark = mounted && resolvedTheme === "dark"
return (
<Button
variant="ghost"
size="icon-sm"
className="shrink-0 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
disabled={!mounted}
aria-label={isDark ? "Switch to light mode" : "Switch to dark mode"}
onClick={() => setTheme(isDark ? "light" : "dark")}
>
{isDark ? <Moon /> : <Sun />}
</Button>
)
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 981 KiB