mirror of
https://git.aramjonghu.dev/AramJonghu/aramjonghu-site.git
synced 2026-09-06 15:33:29 +02:00
Chore(refactor): refactor project info into separate component
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { useState, type ReactElement } from "react";
|
||||
import MdProcessor from "./MdProcessor";
|
||||
import projects from "../content/projects.json";
|
||||
|
||||
export default function ProjectInfo(): ReactElement {
|
||||
const [projIdx, setProjIdx] = useState<number>(0);
|
||||
const prevProject = () =>
|
||||
setProjIdx((i) => (i - 1 + projects.length) % projects.length);
|
||||
const nextProject = () => setProjIdx((i) => (i + 1) % projects.length);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1 className="text-center m-6 text-3xl font-bold text-ctp-mauve">
|
||||
Projects
|
||||
</h1>
|
||||
<div className="flex justify-center mb-6">
|
||||
<button
|
||||
onClick={prevProject}
|
||||
className="px-3 py-1 rounded ui-btn text-ctp-text"
|
||||
>
|
||||
◀︎ Prev
|
||||
</button>
|
||||
<span className="self-center mx-6 font-medium">
|
||||
{projects[projIdx].name} ({projIdx + 1}/
|
||||
{projects.length})
|
||||
</span>
|
||||
<button
|
||||
onClick={nextProject}
|
||||
className="px-3 py-1 rounded ui-btn text-ctp-text"
|
||||
>
|
||||
Next ▶︎
|
||||
</button>
|
||||
</div>
|
||||
<MdProcessor repoUrl={projects[projIdx].url} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user