-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathZodiacBar.tsx
More file actions
34 lines (29 loc) · 1.05 KB
/
ZodiacBar.tsx
File metadata and controls
34 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Link from 'next/link';
import { FC, ReactNode } from 'react';
export const ZodiacSigns = ['🐵', '🐔', '🐶', '🐷', '🐭', '🐮', '🐯', '🐰', '🐲', '🐍', '🐴', '🐐'];
export interface ZodiacBarProps {
startYear: number;
endYear?: number;
itemOf?: (year: number, zodiac: string) => { link?: string; title?: ReactNode };
}
export const ZodiacBar: FC<ZodiacBarProps> = ({
startYear,
endYear = new Date().getFullYear(),
itemOf,
}) => (
<ol className="list-inline d-flex flex-wrap justify-content-center gap-3">
{Array.from({ length: endYear - startYear + 1 }, (_, index) => {
const year = endYear - index;
const zodiac = ZodiacSigns[year % 12];
const { link = '#', title } = itemOf?.(year, zodiac) || {};
return (
<li key={index} className="list-inline-item border rounded">
<Link className="d-inline-block p-3 text-decoration-none text-center" href={link}>
<div className="fs-1">{zodiac}</div>
{title}
</Link>
</li>
);
})}
</ol>
);