import {formatDateIso} from "../_utils/date.ts" import {AnimeData, AnimeProgress, animeProgressToClassName, animeProgressToIconDef, animeProgressToTitle} from "../_utils/anime.ts" import {ratingToClassName} from "../_utils/rating.ts" export type AnimeRowColumnKind = "rating" | "progress" | "name" | "nameoriginal" | "namesort" | "hascontent" | "date" export type AnimeRowColumnPriority = undefined | "rating" | "progress" | "mixed" export const animeRowColumnKindDefault: AnimeRowColumnKind[] = ["rating", "name", "namesort", "hascontent", "date", "progress"] export type AnimeRowProps = { anime: AnimeData, columns?: AnimeRowColumnKind[] priority?: AnimeRowColumnPriority } export function AnimeRow({anime, columns = animeRowColumnKindDefault, priority}: AnimeRowProps) { const activeClass: string = anime.active ? "review-active" : "" const activeClassFa: string = anime.active ? "fa-beat-fade" : "" const ratingText: string = anime.rating ? `${anime.rating}` : "" const ratingClass: string = ratingToClassName(anime.rating) const progressClass: string = animeProgressToClassName(anime.progress) const progressIcon: string = animeProgressToIconDef(anime.progress) const progressTitle: string = animeProgressToTitle(anime.progress) const priorityClass: string = priority ? `priority-${priority}` : "" const columnsElements = columns.map((kind, index) => { switch(kind) { case "rating": { return ( {ratingText} ) } case "progress": { return ( {progressIcon && } ) } case "name": { return ( {anime.name} ) } case "nameoriginal": { return ( {anime.name_original} ) } case "namesort": { return ( ) } case "hascontent": { return ( {anime.content && } ) } case "date": { const date = formatDateIso(anime.date) return ( ) } } }) return ( {columnsElements} ) }