- A Smart playlists page with the ones I made and a way to make a new one. - A page for a smart playlist: its rules in words, its songs, Play, Shuffle again (for the random order), Save as playlist (keeps what is on screen), Edit and Delete. - An editor for a new one and for one that exists, with a live preview of the songs the rules give: genres (chips, with the library's genres offered), file format and bitrate, when it was added, listening, taste, length, order and limit. What the editor has no field for (artists, albums, skipped lately, another format) is kept when a playlist is changed. - Texts in English and Italian, and tests for the list, the page, the editor and the preview.
60 lines
2.6 KiB
TypeScript
60 lines
2.6 KiB
TypeScript
import { NavLink } from 'react-router-dom'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useSession } from '@/auth/session'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
const LINKS = [
|
|
{ to: '/', key: 'nav.home', end: true, adminOnly: false },
|
|
{ to: '/search', key: 'nav.search', end: false, adminOnly: false },
|
|
{ to: '/discover', key: 'nav.discover', end: false, adminOnly: false },
|
|
{ to: '/artists', key: 'nav.artists', end: false, adminOnly: false },
|
|
{ to: '/albums', key: 'nav.albums', end: false, adminOnly: false },
|
|
{ to: '/songs', key: 'nav.songs', end: false, adminOnly: false },
|
|
{ to: '/mixes', key: 'nav.mixes', end: false, adminOnly: false },
|
|
{ to: '/playlists', key: 'nav.playlists', end: false, adminOnly: false },
|
|
{ to: '/smart-playlists', key: 'nav.smartPlaylists', end: false, adminOnly: false },
|
|
{ to: '/admin', key: 'nav.admin', end: false, adminOnly: true },
|
|
{ to: '/settings', key: 'nav.settings', end: false, adminOnly: false },
|
|
]
|
|
|
|
export default function Sidebar() {
|
|
const { t } = useTranslation()
|
|
const { user } = useSession()
|
|
const links = LINKS.filter((link) => !link.adminOnly || user?.is_admin)
|
|
return (
|
|
<nav
|
|
aria-label={t('nav.main')}
|
|
className="flex flex-[0_0_248px] flex-col gap-6 rounded-xl bg-card p-5 text-card-foreground max-sm:flex-[1_1_100%] max-sm:gap-3 max-sm:p-3"
|
|
>
|
|
<div className="flex items-center gap-3">
|
|
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" aria-hidden="true">
|
|
<circle cx="14" cy="14" r="3" fill="var(--primary)" />
|
|
<circle cx="14" cy="14" r="8" stroke="var(--primary)" strokeWidth="2" opacity="0.75" />
|
|
<circle cx="14" cy="14" r="12.5" stroke="var(--primary)" strokeWidth="1.5" opacity="0.35" />
|
|
</svg>
|
|
<span className="text-[22px] font-extrabold tracking-tight">{t('app.name')}</span>
|
|
</div>
|
|
<ul className="flex flex-col gap-1 max-sm:flex-row max-sm:flex-wrap">
|
|
{links.map((link) => (
|
|
<li key={link.to}>
|
|
<NavLink
|
|
to={link.to}
|
|
end={link.end}
|
|
className={({ isActive }) =>
|
|
cn(
|
|
'flex min-h-11 items-center rounded-lg px-3 font-semibold',
|
|
isActive ? 'bg-secondary text-foreground' : 'text-muted-foreground hover:text-foreground',
|
|
)
|
|
}
|
|
>
|
|
{t(link.key)}
|
|
</NavLink>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
<p className="mt-auto rounded-lg bg-secondary px-3 py-2.5 text-[13px] text-muted-foreground max-sm:hidden">
|
|
{t('app.privacy')}
|
|
</p>
|
|
</nav>
|
|
)
|
|
}
|