From d489adee3c2b82820edf3515a83d5816182989a3 Mon Sep 17 00:00:00 2001 From: AramJonghu Date: Mon, 20 Jul 2026 16:48:30 +0200 Subject: [PATCH] Chore(refactor): refactor project info into separate component --- frontend/src/App.tsx | 4 +- frontend/src/components/ProjectInfo.tsx | 37 +++++++++++++++ frontend/src/content/projects.json | 22 +++++++++ frontend/src/pages/Home.tsx | 63 +------------------------ 4 files changed, 62 insertions(+), 64 deletions(-) create mode 100644 frontend/src/components/ProjectInfo.tsx create mode 100644 frontend/src/content/projects.json diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index ac94928..7587deb 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -5,7 +5,7 @@ import Layout from "./components/Layout"; import Home from "./pages/Home"; import Stream from "./pages/Stream"; -function App(): ReactElement { +export default function App(): ReactElement { const path = window.location.pathname.toLowerCase(); let content: ReactElement = ; @@ -15,5 +15,3 @@ function App(): ReactElement { return {content}; } - -export default App; diff --git a/frontend/src/components/ProjectInfo.tsx b/frontend/src/components/ProjectInfo.tsx new file mode 100644 index 0000000..a12b79f --- /dev/null +++ b/frontend/src/components/ProjectInfo.tsx @@ -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(0); + const prevProject = () => + setProjIdx((i) => (i - 1 + projects.length) % projects.length); + const nextProject = () => setProjIdx((i) => (i + 1) % projects.length); + + return ( + <> +

+ Projects +

+
+ + + {projects[projIdx].name} ({projIdx + 1}/ + {projects.length}) + + +
+ + + ); +} diff --git a/frontend/src/content/projects.json b/frontend/src/content/projects.json new file mode 100644 index 0000000..7c5a262 --- /dev/null +++ b/frontend/src/content/projects.json @@ -0,0 +1,22 @@ +[ + { + "id": "site", + "name": "aramjonghu-site", + "url": "https://git.aramjonghu.dev/AramJonghu/aramjonghu-site/raw/branch/master/README.md" + }, + { + "id": "maran freelance portfolio", + "name": "maran-site", + "url": "https://git.aramjonghu.dev/AramJonghu/maran-site/src/branch/main/README.md" + }, + { + "id": "file-organizer", + "name": "file-organizer written in zig", + "url": "https://git.aramjonghu.dev/AramJonghu/file-organizer/src/branch/main/README.md" + }, + { + "id": "nvim", + "name": "Nvim Config", + "url": "https://git.aramjonghu.dev/AramJonghu/nvim/src/branch/main/README.md" + } +] diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index 5e897b0..f45145d 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -1,14 +1,8 @@ import { useState, type ReactElement } from "react"; -import MdProcessor from "../components/MdProcessor"; +import ProjectInfo from "../components/ProjectInfo"; import CurrentActivity from "../components/CurrentActivity"; import About from "../components/About"; -interface ProjectInfo { - id: string; - name: string; - url: string; -} - interface Section { id: string; title: string; @@ -16,66 +10,13 @@ interface Section { } export default function Home(): ReactElement { - const projectList: ProjectInfo[] = [ - { - id: "site", - name: "aramjonghu-site", - url: "https://git.aramjonghu.dev/AramJonghu/aramjonghu-site/raw/branch/master/README.md", - }, - { - id: "maran freelance portfolio", - name: "maran-site", - url: "https://git.aramjonghu.dev/AramJonghu/maran-site/src/branch/main/README.md", - }, - { - id: "file-organizer", - name: "file-organizer written in zig", - url: "https://git.aramjonghu.dev/AramJonghu/file-organizer/src/branch/main/README.md", - }, - { - id: "nvim", - name: "Nvim Config", - url: "https://git.aramjonghu.dev/AramJonghu/nvim/src/branch/main/README.md", - }, - ]; - - const [projIdx, setProjIdx] = useState(0); - const prevProject = () => - setProjIdx((i) => (i - 1 + projectList.length) % projectList.length); - const nextProject = () => setProjIdx((i) => (i + 1) % projectList.length); - const [activeTab, setActiveTab] = useState("projects"); const sections: Section[] = [ { id: "projects", title: "Projects", - content: ( - <> -

- Projects -

-
- - - {projectList[projIdx].name} ({projIdx + 1}/ - {projectList.length}) - - -
- - - ), + content: , }, { id: "current-activity",