Skip to content

Commit b9cfdfa

Browse files
committed
feat: パンくずリストのコンポーネントを追加
1 parent 509c099 commit b9cfdfa

File tree

6 files changed

+87
-30
lines changed

6 files changed

+87
-30
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const ChevronRightIcon = () => {
2+
return (
3+
<svg
4+
xmlns="http://www.w3.org/2000/svg"
5+
viewBox="0 0 24 24"
6+
fill="none"
7+
stroke="currentColor"
8+
stroke-width="2"
9+
stroke-linecap="round"
10+
stroke-linejoin="round"
11+
class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-right"
12+
>
13+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
14+
<path d="M9 6l6 6l-6 6" />
15+
</svg>
16+
);
17+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export const HomeIcon = () => {
2+
return (
3+
<svg
4+
xmlns="http://www.w3.org/2000/svg"
5+
viewBox="0 0 24 24"
6+
fill="none"
7+
stroke="currentColor"
8+
stroke-width="2"
9+
stroke-linecap="round"
10+
stroke-linejoin="round"
11+
class="icon icon-tabler icons-tabler-outline icon-tabler-home"
12+
>
13+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
14+
<path d="M5 12l-2 0l9 -9l9 9l-2 0" />
15+
<path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
16+
<path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
17+
</svg>
18+
);
19+
};

website/src/components/icons/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Tabler Icons
2+
// https://tabler.io/icons
3+
export { HomeIcon } from "./HomeIcon";
4+
export { ChevronRightIcon } from "./ChevronRightIcon";
5+
16
// Simple Icons
27
// https://simpleicons.org/
38
export { GitHubIcon } from "./GitHubIcon";

website/src/components/templates/BaseTemplate.tsx

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FC, PropsWithChildren } from "hono/jsx";
22
import type { Page } from "../../types/model";
3-
import { SiteNoticeBanner, Footer } from "../ui/common/";
3+
import { SiteNoticeBanner, Footer, Breadcrumbs } from "../ui/common/";
44

55
export type BaseTemplateProps = PropsWithChildren<{
66
page: Page;
@@ -345,35 +345,7 @@ export const BaseTemplate: FC<BaseTemplateProps> = ({
345345
</nav>
346346

347347
<main>
348-
<ul class="breadcrumbs" aria-label="Breadcrumbs">
349-
<li class="root">
350-
<a href="/docs/">
351-
<img
352-
src="/assets/icons/16-docs-dark.svg"
353-
alt="Docs"
354-
width="16"
355-
height="16"
356-
/>
357-
</a>
358-
</li>
359-
360-
{path &&
361-
path.map((item, idx) => (
362-
<>
363-
<li aria-hidden="true">
364-
<img
365-
src="/assets/icons/16-arrow-right.svg"
366-
width="16"
367-
height="16"
368-
alt=""
369-
/>
370-
</li>
371-
<li>
372-
<a href={item.route}>{item.title}</a>
373-
</li>
374-
</>
375-
))}
376-
</ul>
348+
<Breadcrumbs path={path} />
377349

378350
{children}
379351

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { Page } from "../../../types/model";
2+
import { ChevronRightIcon, HomeIcon } from "../../icons";
3+
4+
export type BreadcrumbsProps = {
5+
path: Page[];
6+
};
7+
8+
export const Breadcrumbs = ({ path }: BreadcrumbsProps) => {
9+
return (
10+
<nav class="flex justify-between px-3.5 py-1 border border-neutral-200/60 rounded-md">
11+
<ol class="inline-flex items-center mb-3 space-x-1 text-xs text-neutral-500 [&_.active-breadcrumb]:text-neutral-600 [&_.active-breadcrumb]:font-medium sm:mb-0">
12+
<li class="flex items-center h-full">
13+
<a href="/docs/" class="py-1 hover:text-neutral-900">
14+
<div class="w-4 h-4">
15+
<HomeIcon />
16+
</div>
17+
</a>
18+
</li>
19+
{path.map((item, idx) => (
20+
<>
21+
<div class="w-4 h-4 text-gray-400/70">
22+
<ChevronRightIcon />
23+
</div>
24+
<li>
25+
{idx === path.length - 1 ? (
26+
<a class="inline-flex items-center py-1 font-semibold text-neutral-700 rounded cursor-default focus:outline-none">
27+
{item.title}
28+
</a>
29+
) : (
30+
<a
31+
href={item.route}
32+
class="inline-flex items-center py-1 font-normal hover:text-neutral-900 focus:outline-none"
33+
>
34+
{item.title}
35+
</a>
36+
)}
37+
</li>
38+
</>
39+
))}
40+
</ol>
41+
</nav>
42+
);
43+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { SiteNoticeBanner } from "./SiteNoticeBanner";
2+
export { Breadcrumbs, type BreadcrumbsProps } from "./Breadcrumbs";
23
export { Footer } from "./Footer";

0 commit comments

Comments
 (0)