package ui import "fmt" type AnimeCardProps struct { ID int Title string ImageURL string Href string // Options to customize the card behavior Class string // override default wrapper class ImgClass string // override default image class TitleClass string // override default title class HideTitle bool // if true, do not render the default title block CurrentNode bool // if true, renders a div instead of an anchor tag (useful for graph nodes) Synopsis string // optional synopsis for hover detail Score int // optional score for hover detail PlayHref string // optional play button href (anchored to poster) } templ AnimeCard(props AnimeCardProps) { if props.CurrentNode {
@animeCardPoster(props) if !props.HideTitle {
{ props.Title }
} { children... }
} else {
@animeCardPoster(props) if !props.HideTitle {
{ 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) {
if props.ImageURL != "" { { } else {
No image
}
if props.Synopsis != "" || props.Score > 0 {
if props.Score > 0 {
{ fmt.Sprintf("%d", props.Score) }
}
{ props.Title }
if props.Synopsis != "" {

{ props.Synopsis }

}
} if props.PlayHref != "" { }
} func defaultString(val, fallback string) string { if val == "" { return fallback } return val }