wikimusic-ssr-0.6.0.0: src/WikiMusic/SSR/View/ArtistHtml.hs
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module WikiMusic.SSR.View.ArtistHtml
( artistListPage',
artistDetailPage',
artistCreatePage',
)
where
import Data.Map qualified as Map
import Optics
import Relude
import Text.Blaze.Html
import Text.Blaze.Html5 as H
import Text.Blaze.Html5.Attributes as A
import WikiMusic.Interaction.Model.Artist
import WikiMusic.SSR.Language
import WikiMusic.SSR.Model.Api
import WikiMusic.SSR.Model.Env
import WikiMusic.SSR.View.Components.Forms
import WikiMusic.SSR.View.Components.Meta
import WikiMusic.SSR.View.Components.Other
import WikiMusic.SSR.View.Components.PageTop
artistListPage' :: (MonadIO m) => Env -> UiMode -> Language -> Palette -> SortOrder -> GetArtistsQueryResponse -> m Html
artistListPage' env mode language palette sortOrder xs = do
sharedHead <- mkSharedHead env mode palette (dictionary ^. #titles % #artistsPage |##| language)
pure $ H.html $ do
sharedHead
body $ section $ do
sharedPageTop (Just $ dictionary ^. #titles % #artistsPage |##| language) mode language palette
section ! class_ "flex direction-row justify-content-center gap-small align-items-baseline" $ do
H.a ! href "/artists/create" $ button $ H.small "+ new artist"
mkSortingForm language sortOrder "/user-preferences/artist-sorting" "artist-sorting"
section ! class_ "entity-card-section" $ mapM_ (simpleEntityCard language "artists") sortedXs
where
sortedXs =
mapMaybe
(\identifier -> (xs ^. #artists) Map.!? identifier)
(xs ^. #sortOrder)
artistDetailPage' :: (MonadIO m) => Env -> UiMode -> Language -> Palette -> Artist -> m Html
artistDetailPage' env mode language palette x = do
sharedHead <- mkSharedHead env mode palette (dictionary ^. #titles % #artistsPage |##| language)
pure $ H.html $ do
sharedHead
body $ section $ do
sharedPageTop Nothing mode language palette
entityDetails language "artists" x
artistCreatePage' :: (MonadIO m) => Env -> UiMode -> Language -> Palette -> m Html
artistCreatePage' env mode language palette = do
sharedHead <- mkSharedHead env mode palette (dictionary ^. #titles % #artistsPage |##| language)
pure $ H.html $ do
sharedHead
body $ section $ do
sharedPageTop Nothing mode language palette
section $ do
H.h2 "Create artist"
postForm "/artists/create" $ do
requiredTextInput "displayName" "artist name"
optionalTextArea "description" "description"
optionalTextInput "spotifyUrl" "spotify URL"
optionalTextInput "youtubeUrl" "youtube URL"
optionalTextInput "wikipediaUrl" "wikipedia URL"
optionalTextInput "soundcloudUrl" "soundcloud URL"
submitButton language