-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathTabsBar.tsx
45 lines (41 loc) · 1014 Bytes
/
TabsBar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2023-2025 the Deno authors. All rights reserved. MIT license.
import { ComponentChildren } from "preact";
export interface TabItemProps {
/** Path of the item's URL */
path: string;
/** Whether the user is on the item's URL */
active: boolean;
children?: ComponentChildren;
}
export function TabItem(props: TabItemProps) {
return (
<a
href={props.path}
class={`px-4 py-2 rounded-lg ${
props.active
? "bg-gray-100 text-black dark:bg-gray-800 dark:text-white"
: ""
} link-styles`}
>
{props.children}
</a>
);
}
export interface TabsBarProps {
links: {
path: string;
innerText: string;
}[];
currentPath: string;
}
export default function TabsBar(props: TabsBarProps) {
return (
<div class="flex flex-row w-full mb-8">
{props.links.map((link) => (
<TabItem path={link.path} active={link.path === props.currentPath}>
{link.innerText}
</TabItem>
))}
</div>
);
}