fix(web): allow opening the sidebar on mobile
This commit is contained in:
9 files changed
+68
-16
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||||
import { Plus } from "lucide-react"
|
import { Plus } from "lucide-react"
|
||||||
|
|
||||||
import { useAddToPlaylist } from "@/components/add-to-playlist-provider"
|
import { useAddToPlaylist } from "@/components/add-to-playlist-provider"
|
||||||
@@ -17,7 +18,10 @@ export default function Page() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-svh flex-col">
|
<div className="flex h-svh flex-col">
|
||||||
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
|
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
|
||||||
<h1 className="text-lg font-semibold">Playlists</h1>
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
|
<MobileSidebarTrigger />
|
||||||
|
<h1 className="text-lg font-semibold">Playlists</h1>
|
||||||
|
</div>
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||||
import { Suspense, useCallback, useEffect, useRef, useState } from "react"
|
import { Suspense, useCallback, useEffect, useRef, useState } from "react"
|
||||||
import { SearchIcon } from "lucide-react"
|
import { SearchIcon } from "lucide-react"
|
||||||
import { usePathname, useSearchParams } from "next/navigation"
|
import { usePathname, useSearchParams } from "next/navigation"
|
||||||
@@ -212,7 +213,8 @@ function SearchPageContent() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-svh flex-col">
|
<div className="flex h-svh flex-col">
|
||||||
<header className="flex items-center justify-center border-b px-4 py-3">
|
<header className="flex items-center justify-center gap-2 border-b px-4 py-3">
|
||||||
|
<MobileSidebarTrigger />
|
||||||
<div className="relative w-full max-w-xl">
|
<div className="relative w-full max-w-xl">
|
||||||
<SearchIcon className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
|
<SearchIcon className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
@@ -391,9 +392,12 @@ export function AlbumView({
|
|||||||
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
||||||
Album
|
Album
|
||||||
</p>
|
</p>
|
||||||
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
|
<div className="flex min-w-0 items-center justify-center gap-2 sm:justify-start md:contents">
|
||||||
{album.title}
|
<MobileSidebarTrigger />
|
||||||
</h1>
|
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
|
||||||
|
{album.title}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
<Link
|
<Link
|
||||||
href={"/artist/" + album.artist.id}
|
href={"/artist/" + album.artist.id}
|
||||||
className="inline-block text-lg font-semibold text-primary hover:underline"
|
className="inline-block text-lg font-semibold text-primary hover:underline"
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import {
|
|||||||
SidebarMenu,
|
SidebarMenu,
|
||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
|
useSidebar,
|
||||||
} from "@/components/ui/sidebar"
|
} from "@/components/ui/sidebar"
|
||||||
import { ThemeToggle } from "@/components/theme-toggle"
|
import { ThemeToggle } from "@/components/theme-toggle"
|
||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
@@ -63,6 +64,7 @@ const library = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export function AppSidebar() {
|
export function AppSidebar() {
|
||||||
|
const { setOpenMobile } = useSidebar()
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { signOut } = useAuthActions()
|
const { signOut } = useAuthActions()
|
||||||
@@ -120,7 +122,7 @@ export function AppSidebar() {
|
|||||||
{browse.map((item) => (
|
{browse.map((item) => (
|
||||||
<SidebarMenuItem key={item.title}>
|
<SidebarMenuItem key={item.title}>
|
||||||
<SidebarMenuButton isActive={pathname === item.path} asChild>
|
<SidebarMenuButton isActive={pathname === item.path} asChild>
|
||||||
<Link href={item.path}>
|
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||||
<item.icon />
|
<item.icon />
|
||||||
<span>{item.title}</span>
|
<span>{item.title}</span>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -144,7 +146,7 @@ export function AppSidebar() {
|
|||||||
}
|
}
|
||||||
asChild
|
asChild
|
||||||
>
|
>
|
||||||
<Link href={item.path}>
|
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||||
<item.icon />
|
<item.icon />
|
||||||
<span>{item.title}</span>
|
<span>{item.title}</span>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -162,7 +164,7 @@ export function AppSidebar() {
|
|||||||
{playlistNav.map((item) => (
|
{playlistNav.map((item) => (
|
||||||
<SidebarMenuItem key={item.path}>
|
<SidebarMenuItem key={item.path}>
|
||||||
<SidebarMenuButton isActive={pathname === item.path} asChild>
|
<SidebarMenuButton isActive={pathname === item.path} asChild>
|
||||||
<Link href={item.path}>
|
<Link href={item.path} onClick={() => setOpenMobile(false)}>
|
||||||
<item.icon />
|
<item.icon />
|
||||||
<span>{item.title}</span>
|
<span>{item.title}</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
import { Play, Shuffle } from "lucide-react"
|
import { Play, Shuffle } from "lucide-react"
|
||||||
@@ -79,9 +80,12 @@ export function ArtistView({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex min-w-0 flex-1 flex-col gap-4">
|
<div className="flex min-w-0 flex-1 flex-col gap-4">
|
||||||
<h1 className="min-w-0 truncate text-3xl font-bold tracking-tight sm:text-4xl lg:text-5xl">
|
<div className="flex min-w-0 items-center gap-2 md:contents">
|
||||||
{artist.name}
|
<MobileSidebarTrigger />
|
||||||
</h1>
|
<h1 className="min-w-0 truncate text-3xl font-bold tracking-tight sm:text-4xl lg:text-5xl">
|
||||||
|
{artist.name}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||||
import { Skeleton } from "@/components/ui/skeleton"
|
import { Skeleton } from "@/components/ui/skeleton"
|
||||||
import { albumGridClassName } from "@/lib/album-grid-classes"
|
import { albumGridClassName } from "@/lib/album-grid-classes"
|
||||||
import { TRACK_LIST_CONTAINER } from "@/lib/selection-range-styles"
|
import { TRACK_LIST_CONTAINER } from "@/lib/selection-range-styles"
|
||||||
@@ -21,6 +22,7 @@ function LoadingRegion({
|
|||||||
export function PageHeader({ title }: { title: string }) {
|
export function PageHeader({ title }: { title: string }) {
|
||||||
return (
|
return (
|
||||||
<header className="flex items-center gap-2 border-b px-4 py-3">
|
<header className="flex items-center gap-2 border-b px-4 py-3">
|
||||||
|
<MobileSidebarTrigger />
|
||||||
<h1 className="text-lg font-semibold">{title}</h1>
|
<h1 className="text-lg font-semibold">{title}</h1>
|
||||||
</header>
|
</header>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { Menu } from "lucide-react"
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button"
|
||||||
|
import { useSidebar } from "@/components/ui/sidebar"
|
||||||
|
|
||||||
|
export function MobileSidebarTrigger() {
|
||||||
|
const { openMobile, setOpenMobile } = useSidebar()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="size-11 shrink-0 md:hidden"
|
||||||
|
aria-label="Open sidebar"
|
||||||
|
aria-expanded={openMobile}
|
||||||
|
onClick={() => setOpenMobile(true)}
|
||||||
|
>
|
||||||
|
<Menu />
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||||
import { stationArtistId } from "@/lib/station-artist"
|
import { stationArtistId } from "@/lib/station-artist"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
@@ -544,9 +545,12 @@ export function PlaylistView({ playlist }: { playlist: BrowsePlaylistDetail }) {
|
|||||||
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
||||||
Playlist
|
Playlist
|
||||||
</p>
|
</p>
|
||||||
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
|
<div className="flex min-w-0 items-center justify-center gap-2 sm:justify-start md:contents">
|
||||||
{playlist.title}
|
<MobileSidebarTrigger />
|
||||||
</h1>
|
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl">
|
||||||
|
{playlist.title}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
<p className="text-lg font-semibold text-primary">
|
<p className="text-lg font-semibold text-primary">
|
||||||
{playlist.owner.name}
|
{playlist.owner.name}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger"
|
||||||
import { stationArtistId } from "@/lib/station-artist"
|
import { stationArtistId } from "@/lib/station-artist"
|
||||||
import { useEffect, useMemo, useState, useRef, MouseEvent } from "react"
|
import { useEffect, useMemo, useState, useRef, MouseEvent } from "react"
|
||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
@@ -362,7 +363,10 @@ export function SongsView() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-svh flex-col">
|
<div className="flex h-svh flex-col">
|
||||||
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
|
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
|
||||||
<h1 className="text-lg font-semibold">Songs</h1>
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
|
<MobileSidebarTrigger />
|
||||||
|
<h1 className="text-lg font-semibold">Songs</h1>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<SongListSkeleton />
|
<SongListSkeleton />
|
||||||
</div>
|
</div>
|
||||||
@@ -372,7 +376,10 @@ export function SongsView() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-svh flex-col">
|
<div className="flex h-svh flex-col">
|
||||||
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
|
<header className="flex items-center justify-between gap-2 border-b px-4 py-3">
|
||||||
<h1 className="text-lg font-semibold">Songs</h1>
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
|
<MobileSidebarTrigger />
|
||||||
|
<h1 className="text-lg font-semibold">Songs</h1>
|
||||||
|
</div>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant="ghost" size="icon-sm" aria-label="Sort songs">
|
<Button variant="ghost" size="icon-sm" aria-label="Sort songs">
|
||||||
|
|||||||
Reference in new issue
Block a user