sonda/web/src/components/layout/Sidebar.tsx
tgiachi c0e8874e71 feat(web): playlists
A Playlists page lists the user's playlists and makes a new one. A playlist has its
own page: play it (songs that are not available are skipped), rename it, delete it
after a confirmation, move a song up or down and take one out. Every song of a list
gets an Add to playlist button that opens a window to choose a playlist or make a
new one, and says what it did.

TrackRow keeps the song as one button and takes extra buttons at its end, so the
add button is not inside the button that plays. A long playlist is read whole,
page after page. English and Italian texts, error texts for the new codes.

Closes #92
2026-11-12 17:04:44 +01:00

58 lines
2.4 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: '/playlists', key: 'nav.playlists', 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>
)
}