import {formatDateIso} from "../_utils/date.ts" import {GameData} from "../_utils/game.ts" import {Progress, progressToClassName, progressToIconDef, progressToTitle} from "../_utils/progress.ts" import {ratingToClassName} from "../_utils/rating.ts" export type GameRowColumnKind = "rating" | "progress" | "name" | "namesort" | "hascontent" | "date" | "hoursplayed" export type GameRowColumnPriority = undefined | "rating" | "progress" | "mixed" export const gameRowColumnKindDefault: GameRowColumnKind[] = ["rating", "name", "namesort", "hascontent", "date", "progress", "hoursplayed"] export type GameRowProps = { game: GameData, columns?: GameRowColumnKind[] priority?: GameRowColumnPriority } export function GameRow({game, columns = gameRowColumnKindDefault, priority}: GameRowProps) { const activeClass: string = game.active ? "review-active" : "" const activeClassFa: string = game.active ? "fa-beat-fade" : "" const ratingText: string = game.rating ? `${game.rating}` : "" const ratingClass: string = ratingToClassName(game.rating) const progressClass: string = progressToClassName(game.progress) const progressIcon: string = progressToIconDef(game.progress) const progressTitle: string = progressToTitle(game.progress) const priorityClass: string = priority ? `priority-${priority}` : "" const columnsElements = columns.map((kind, index) => { switch(kind) { case "rating": { return (