diff --git a/web/src/components/ArtistPhoto.tsx b/web/src/components/ArtistPhoto.tsx index 25d12da..684c54a 100644 --- a/web/src/components/ArtistPhoto.tsx +++ b/web/src/components/ArtistPhoto.tsx @@ -32,7 +32,7 @@ export default function ArtistPhoto({ return (
{photo && failed !== src ? ( { + render(Albums) + const h1 = screen.getByRole('heading', { level: 1, name: 'Albums' }) + expect(h1.className).toContain('text-4xl') + expect(h1.className).toContain('font-extrabold') +}) + +test('a greeting is larger still', () => { + render(Good evening) + expect(screen.getByRole('heading', { level: 1 }).className).toContain('text-5xl') +}) diff --git a/web/src/components/PageTitle.tsx b/web/src/components/PageTitle.tsx new file mode 100644 index 0000000..3310f37 --- /dev/null +++ b/web/src/components/PageTitle.tsx @@ -0,0 +1,11 @@ +import type { ReactNode } from 'react' +import { cn } from '@/lib/utils' + +/** The title of a page: the largest text on it. A greeting (`large`) is larger still. */ +export default function PageTitle({ children, large = false, className }: { children: ReactNode; large?: boolean; className?: string }) { + return ( +

+ {children} +

+ ) +} diff --git a/web/src/components/cards.test.tsx b/web/src/components/cards.test.tsx new file mode 100644 index 0000000..ba014e7 --- /dev/null +++ b/web/src/components/cards.test.tsx @@ -0,0 +1,23 @@ +import { render, screen } from '@testing-library/react' +import { MemoryRouter } from 'react-router-dom' +import { beforeEach, expect, test, vi } from 'vitest' +import { initI18n } from '@/i18n' +import { AlbumCard, ArtistCard } from './cards' + +beforeEach(async () => { + vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US') + await initI18n() +}) + +test('a card is the picture and the words, with no panel around them', () => { + render( + + + + , + ) + for (const link of screen.getAllByRole('link')) { + expect(link.className).not.toMatch(/(^|\s)(bg-|p-3|rounded-xl)/) + expect(link.className).toContain('lift') // it still answers the pointer + } +}) diff --git a/web/src/components/cards.tsx b/web/src/components/cards.tsx index 5351329..404ac85 100644 --- a/web/src/components/cards.tsx +++ b/web/src/components/cards.tsx @@ -10,7 +10,7 @@ export const CARD_GRID = 'grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] g export function ArtistCard({ artist }: { artist: Artist }) { const { t } = useTranslation() return ( - + {artist.name} @@ -24,7 +24,7 @@ export function ArtistCard({ artist }: { artist: Artist }) { export function AlbumCard({ album }: { album: Album }) { return ( - + {album.title} diff --git a/web/src/pages/AlbumsPage.tsx b/web/src/pages/AlbumsPage.tsx index 177bb30..338e627 100644 --- a/web/src/pages/AlbumsPage.tsx +++ b/web/src/pages/AlbumsPage.tsx @@ -4,6 +4,7 @@ import { useAlbumList } from '@/api/catalog' import { AlbumCard, CARD_GRID } from '@/components/cards' import LoadMore from '@/components/LoadMore' import { EmptyMessage, ErrorMessage, Loading } from '@/components/Status' +import PageTitle from '@/components/PageTitle' export default function AlbumsPage() { const { t } = useTranslation() @@ -14,7 +15,7 @@ export default function AlbumsPage() { return (
-

{t('nav.albums')}

+ {t('nav.albums')} {query.isError ? ( query.refetch()} /> ) : query.isPending ? ( diff --git a/web/src/pages/ArtistsPage.tsx b/web/src/pages/ArtistsPage.tsx index 5fbfd05..372d8bf 100644 --- a/web/src/pages/ArtistsPage.tsx +++ b/web/src/pages/ArtistsPage.tsx @@ -4,6 +4,7 @@ import { useArtistList } from '@/api/catalog' import { ArtistCard, CARD_GRID } from '@/components/cards' import LoadMore from '@/components/LoadMore' import { EmptyMessage, ErrorMessage, Loading } from '@/components/Status' +import PageTitle from '@/components/PageTitle' export default function ArtistsPage() { const { t } = useTranslation() @@ -14,7 +15,7 @@ export default function ArtistsPage() { return (
-

{t('nav.artists')}

+ {t('nav.artists')} {query.isError ? ( query.refetch()} /> ) : query.isPending ? ( diff --git a/web/src/pages/DiscoverPage.tsx b/web/src/pages/DiscoverPage.tsx index 8c256bc..6dcb20a 100644 --- a/web/src/pages/DiscoverPage.tsx +++ b/web/src/pages/DiscoverPage.tsx @@ -4,6 +4,7 @@ import { useSearchParams } from 'react-router-dom' import { cn } from '@/lib/utils' import MarkedList from './discover/MarkedList' import SuggestionsTab from './discover/SuggestionsTab' +import PageTitle from '@/components/PageTitle' const TABS = [ { id: 'suggestions', key: 'discover.tabs.suggestions' }, @@ -39,9 +40,9 @@ export default function DiscoverPage() { return (
-

{t('discover.title')}

+ {t('discover.title')} -
+
{TABS.map((tab) => ( diff --git a/web/src/pages/MixesPage.tsx b/web/src/pages/MixesPage.tsx index f8ca517..e37d1a9 100644 --- a/web/src/pages/MixesPage.tsx +++ b/web/src/pages/MixesPage.tsx @@ -6,11 +6,12 @@ import MixCover from '@/components/MixCover' import Section from '@/components/Section' import { EmptyMessage, ErrorMessage, Loading } from '@/components/Status' import { mixTitle } from './mixTitle' +import PageTitle from '@/components/PageTitle' function MixCard({ mix }: { mix: Mix }) { const { t } = useTranslation() return ( - + {mixTitle(t, mix)} @@ -29,7 +30,7 @@ export default function MixesPage() { return (
-

{t('nav.mixes')}

+ {t('nav.mixes')} {query.isError ? ( query.refetch()} /> ) : query.isPending ? ( diff --git a/web/src/pages/NotFoundPage.tsx b/web/src/pages/NotFoundPage.tsx index 5e1a305..d734dfe 100644 --- a/web/src/pages/NotFoundPage.tsx +++ b/web/src/pages/NotFoundPage.tsx @@ -1,11 +1,12 @@ import { Link } from 'react-router-dom' import { useTranslation } from 'react-i18next' +import PageTitle from '@/components/PageTitle' export default function NotFoundPage() { const { t } = useTranslation() return (
-

{t('common.notFound')}

+ {t('common.notFound')} {t('common.backHome')} diff --git a/web/src/pages/PlaylistsPage.tsx b/web/src/pages/PlaylistsPage.tsx index a29740e..7e6334c 100644 --- a/web/src/pages/PlaylistsPage.tsx +++ b/web/src/pages/PlaylistsPage.tsx @@ -12,6 +12,7 @@ import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { errorMessageKey } from '@/i18n' import { formatTime } from '@/lib/time' +import PageTitle from '@/components/PageTitle' /** Your playlists, and a form to make another. */ export default function PlaylistsPage() { @@ -30,7 +31,7 @@ export default function PlaylistsPage() { return (
-

{t('nav.playlists')}

+ {t('nav.playlists')} {query.isError ? ( query.refetch()} /> @@ -43,7 +44,7 @@ export default function PlaylistsPage() {
    {items.map((p) => (
  • - + {p.name} diff --git a/web/src/pages/SearchPage.tsx b/web/src/pages/SearchPage.tsx index 7ff362c..119c9b8 100644 --- a/web/src/pages/SearchPage.tsx +++ b/web/src/pages/SearchPage.tsx @@ -7,6 +7,7 @@ import Section from '@/components/Section' import { EmptyMessage, ErrorMessage, Loading } from '@/components/Status' import TrackList from '@/components/TrackList' import { Input } from '@/components/ui/input' +import PageTitle from '@/components/PageTitle' /** Wait this long after the last keystroke before asking the server. */ const DEBOUNCE_MS = 250 @@ -49,7 +50,7 @@ export default function SearchPage() { return (
    -

    {t('nav.search')}

    + {t('nav.search')}