-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic artist view (no details yet)
- Loading branch information
Showing
11 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.sideNavLink { | ||
display: block; | ||
flex-shrink: 0; | ||
width: 100%; | ||
line-height: 1; | ||
font-size: 1rem; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { type LoaderFunctionArgs, useParams } from 'react-router-dom'; | ||
import type { LoaderData } from '../types/museeks'; | ||
|
||
export default function ViewArtistDetails() { | ||
// const { /** */ } = useLoaderData() as ArtistDetailsLoaderData; | ||
const params = useParams(); | ||
return <div>{params.artist}</div>; | ||
} | ||
|
||
export type ArtistDetailsLoaderData = LoaderData< | ||
typeof ViewArtistDetails.loader | ||
>; | ||
|
||
ViewArtistDetails.loader = async ({ params }: LoaderFunctionArgs) => { | ||
if (typeof params.artist !== 'string') { | ||
throw new Error('Invalid artist'); | ||
} | ||
|
||
return {}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useLoaderData, useOutlet } from 'react-router-dom'; | ||
|
||
import SideNav from '../components/SideNav'; | ||
import SideNavLink from '../components/SideNavLink'; | ||
import View from '../elements/View'; | ||
import * as ViewMessage from '../elements/ViewMessage'; | ||
import database from '../lib/database'; | ||
import type { LoaderData } from '../types/museeks'; | ||
|
||
export default function ViewArtists() { | ||
const { artists } = useLoaderData() as ArtistsLoaderData; | ||
const outlet = useOutlet(); | ||
|
||
return ( | ||
<View | ||
sideNav={ | ||
<SideNav title="Artists"> | ||
{artists.map((artist) => ( | ||
<SideNavLink | ||
key={artist} | ||
id={artist} | ||
label={artist} | ||
href={`/artists/${artist}`} | ||
/> | ||
))} | ||
</SideNav> | ||
} | ||
> | ||
{outlet ?? ( | ||
<ViewMessage.Notice> | ||
<p>No artist selected</p> | ||
</ViewMessage.Notice> | ||
)} | ||
</View> | ||
); | ||
} | ||
|
||
export type ArtistsLoaderData = LoaderData<typeof ViewArtists.loader>; | ||
|
||
ViewArtists.loader = async () => { | ||
const artists = await database.getAllArtists(); | ||
|
||
return { artists }; | ||
}; |