package ui import ( "fmt" "mal/web/components/watchlist" ) type AnimeCardProps struct { ID int Title string ImageURL string Href string Class string ImgClass string TitleClass string HideTitle bool CurrentNode bool Synopsis string PlayHref string TitleEnglish string TitleJapanese string Airing bool WatchlistStatus string DisableWatchlist bool } templ AnimeCard(props AnimeCardProps) {
@animeCardPoster(props) if !props.HideTitle { if props.CurrentNode {
{ props.Title }
} else {
{ props.Title }
} } { children... }
} func cardHref(props AnimeCardProps) string { if props.Href != "" { return props.Href } return fmt.Sprintf("/anime/%d", props.ID) } templ animeCardPoster(props AnimeCardProps) {
@animeCardImage(props)
if props.Synopsis != "" {
{ props.Title }

{ props.Synopsis }

} if !props.CurrentNode { } if props.PlayHref != "" || !props.CurrentNode && !props.DisableWatchlist {
if props.PlayHref != "" { Play } if !props.CurrentNode && !props.DisableWatchlist { @watchlist.CardButton( props.ID, props.Title, props.TitleEnglish, props.TitleJapanese, props.ImageURL, props.Airing, props.WatchlistStatus != "", ) }
}
} templ animeCardImage(props AnimeCardProps) { if props.ImageURL != "" { { } else {
No image
} } func defaultString(val, fallback string) string { if val == "" { return fallback } return val }