starshard/peafowl
Template
1
Fork 0
mirror of https://github.com/starshardstudio/peafowl.git synced 2024-11-22 04:54:19 +00:00
peafowl/_components/AnimeTable.tsx

101 lines
3.5 KiB
TypeScript
Raw Normal View History

2024-11-05 12:39:33 +00:00
import {AnimeData} from "../_utils/anime.ts"
import {AnimeRow, AnimeRowColumnKind, animeRowColumnKindDefault, AnimeRowColumnPriority} from "./AnimeRow.tsx"
export type AnimeTableProps = {
id?: string,
anime: AnimeData[],
columns?: AnimeRowColumnKind[]
priority?: AnimeRowColumnPriority
}
export function AnimeTable({id, anime, columns = animeRowColumnKindDefault, priority}: AnimeTableProps) {
const colElements = columns.map((column, index) => {
switch(column) {
case "rating": return (
<col key={index} className={`review-rating`}/>
)
case "progress": return (
<col key={index} className={`anime-progress`}/>
)
case "name": return (
<col key={index} className={`review-name`}/>
)
case "hascontent": return (
<col key={index} className={`review-hascontent`}/>
)
case "date": return (
<col key={index} className={`review-date`}/>
)
}
})
const thElements = columns.map((column, index) => {
switch(column) {
case "rating": return (
<th key={index} scope={"col"} className={`review-rating`}>
2024-11-05 12:51:18 +00:00
<abbr title={"The rating of the anime, from 1 to 100."}>
2024-11-05 12:39:33 +00:00
<i className={`fa-sharp fa-solid fa-thumbs-up`}/>
</abbr>
</th>
)
case "progress": return (
2024-11-05 12:51:18 +00:00
<th key={index} scope={"col"} className={`anime-progress`}>
<abbr title={"The progress that has been made in the anime."}>
2024-11-05 12:39:33 +00:00
<i className={`fa-sharp fa-solid fa-bars-progress`}/>
</abbr>
</th>
)
case "name": return (
<th key={index} scope={"col"} className={`review-name`}>
2024-11-05 12:51:18 +00:00
<abbr title={"The title of the anime."}>
2024-11-05 12:39:33 +00:00
Title
</abbr>
</th>
)
case "namesort": return (
<th key={index} scope={"col"} className={`review-namesort`} hidden={true}>
2024-11-05 12:51:18 +00:00
<abbr title={"The title to sort the anime as."}>
2024-11-05 12:39:33 +00:00
Sort by
</abbr>
</th>
)
case "hascontent":
return (
<th key={index} scope={"col"} className={`review-hascontent`}>
<abbr title={"Whether the review has textual content, or just metadata."}>
<i className={`fa-sharp fa-regular fa-bars-sort`}/>
</abbr>
</th>
)
case "date": return (
<th key={index} scope={"col"} className={`review-date`}>
<abbr title={"The date of the last update of the review."}>
Date
</abbr>
</th>
)
}
})
const trTdElements = anime.map((ani: AnimeData) => (
<AnimeRow key={ani.url} anime={ani} columns={columns} priority={priority}/>
))
return (
<table id={id}>
<colgroup>
{colElements}
</colgroup>
<thead>
<tr>
{thElements}
</tr>
</thead>
<tbody>
{trTdElements}
</tbody>
</table>
)
}