Skip to content

Commit

Permalink
feat: add history page
Browse files Browse the repository at this point in the history
  • Loading branch information
taga3s committed Aug 7, 2024
1 parent b1e0447 commit 4f7c58a
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 1 deletion.
25 changes: 25 additions & 0 deletions app/api/workExperience/fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Context } from "hono";
import apiClient from "../apiClient";

type Response = {
contents: {
id: string;
span: string;
company: string;
description: string;
techStack: string;
order: number;
}[];
totalCount: number;
offset: number;
limit: number;
};

const fetchWorkExperience = async (c: Context) => {
const res = await apiClient.GET<Response>(c, "/work-experience");
return res.contents.map((content) => {
return { ...content };
});
};

export { fetchWorkExperience };
2 changes: 2 additions & 0 deletions app/api/workExperience/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./fetch";
export * from "./model";
9 changes: 9 additions & 0 deletions app/api/workExperience/model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type WorkExperience = {
span: string;
company: string;
description: string;
techStack: string;
order: number;
};

export type { WorkExperience };
15 changes: 15 additions & 0 deletions app/components/history/HistoryEducationalBackground.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { css } from "hono/css";

const list = css`
display: flex;
flex-direction: column;
gap: 16px;
margin-top: 32px;
`;

const listItem = css`
display: flex;
gap: 16px;
`;

export { list, listItem };
17 changes: 17 additions & 0 deletions app/components/history/HistoryEducationalBackground.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Section } from "../layout/Section";
import { list, listItem } from "./HistoryEducationalBackground.css";

const HistoryEducationalBackground = () => {
return (
<Section title="Educational background">
<ul class={list}>
<li class={listItem}>
<span>2022年4月 - 現在</span>
<span>早稲田大学法学部在学中</span>
</li>
</ul>
</Section>
);
};

export { HistoryEducationalBackground };
9 changes: 9 additions & 0 deletions app/components/history/HistoryPresenter.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { css } from "hono/css";

const layout = css`
display: flex;
flex-direction: column;
gap: 48px;
`;

export { layout };
22 changes: 22 additions & 0 deletions app/components/history/HistoryPresenter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { FC } from "hono/jsx";
import type { WorkExperience } from "../../api/workExperience";
import { HistoryEducationalBackground } from "./HistoryEducationalBackground";
import { layout } from "./HistoryPresenter.css";
import { HistoryWorkExperience } from "./HistoryWorkExperience";

type Props = {
workExperience: WorkExperience[];
};

const HistoryPresenter: FC<Props> = (props) => {
const { workExperience } = props;

return (
<div class={layout}>
<HistoryWorkExperience workExperience={workExperience} />
<HistoryEducationalBackground />
</div>
);
};

export { HistoryPresenter };
17 changes: 17 additions & 0 deletions app/components/history/HistoryWorkExperience.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { css } from "hono/css";

const list = css`
display: flex;
flex-direction: column;
gap: 16px;
margin-top: 32px;
`;

const description = css`
display: flex;
flex-direction: column;
gap: 8px;
padding: 8px;
`;

export { list, description };
37 changes: 37 additions & 0 deletions app/components/history/HistoryWorkExperience.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { FC } from "hono/jsx";
import type { WorkExperience } from "../../api/workExperience";
import { Section } from "../layout/Section";
import { list } from "./HistoryEducationalBackground.css";
import { description } from "./HistoryWorkExperience.css";

type Props = {
workExperience: WorkExperience[];
};

const HistoryWorkExperience: FC<Props> = (props) => {
const { workExperience } = props;

return (
<Section title="Work experience">
<ul class={list}>
{workExperience
.toSorted((a, b) => a.order - b.order)
.map((item) => (
<li key={item.company}>
<details>
<summary>
{item.span}: {item.company}
</summary>
<p class={description}>
<span>{item.description}</span>
<span>使用技術: {item.techStack}</span>
</p>
</details>
</li>
))}
</ul>
</Section>
);
};

export { HistoryWorkExperience };
5 changes: 4 additions & 1 deletion app/routes/history.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { createRoute } from "honox/factory";
import { HistoryPresenter } from "../components/history/HistoryPresenter";
import { fetchWorkExperience } from "../api/workExperience";

export default createRoute(async (c) => {
return c.render(<div>history</div>)
const workExperience = await fetchWorkExperience(c);
return c.render(<HistoryPresenter workExperience={workExperience} />);
});

0 comments on commit 4f7c58a

Please sign in to comment.