59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import React from "react";
|
|
|
|
import styles from "./Sections.module.css";
|
|
|
|
interface SectionsData {
|
|
name: string;
|
|
url: string;
|
|
}
|
|
|
|
interface SectionsProps {
|
|
/* Whether to display the "Sections" title and separator that appears on the left. */
|
|
showHeader?: boolean;
|
|
/* Width of the entire Sections, in px. */
|
|
width?: number;
|
|
data: SectionsData[];
|
|
className?: string;
|
|
}
|
|
|
|
export function Sections({
|
|
data,
|
|
showHeader = true,
|
|
width = 800,
|
|
className,
|
|
}: SectionsProps) {
|
|
return (
|
|
<section
|
|
className={
|
|
className ? `${className} ${styles.sections}` : `${styles.sections}`
|
|
}
|
|
style={{ width: width }}
|
|
>
|
|
{showHeader ? (
|
|
<>
|
|
<h1>Sections</h1>
|
|
<div className={styles.separator} />
|
|
</>
|
|
) : (
|
|
""
|
|
)}
|
|
<nav className={styles.nav}>
|
|
<ul>
|
|
{data.map((datum, index) => {
|
|
return (
|
|
<li key={`${datum.name}-${index}`}>
|
|
<a href={datum.url}>
|
|
<span className={styles.linkNumber}>
|
|
{String(index).padStart(2, "0")}{" "}
|
|
</span>
|
|
<span className={styles.linkName}>{datum.name}</span>
|
|
</a>
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
</nav>
|
|
</section>
|
|
);
|
|
}
|