Skip to content

Commit c092490

Browse files
author
Dylan Huang
committed
Add TabButton component for improved tab navigation in Dashboard
1 parent 97afc9d commit c092490

2 files changed

Lines changed: 49 additions & 30 deletions

File tree

vite-app/src/components/Dashboard.tsx

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { state } from "../App";
55
import Button from "./Button";
66
import { EvaluationTable } from "./EvaluationTable";
77
import PivotTable from "./PivotTable";
8+
import TabButton from "./TabButton";
89
import flattenJson from "../util/flatten-json";
910

1011
interface DashboardProps {
@@ -91,46 +92,30 @@ const Dashboard = observer(({ onRefresh }: DashboardProps) => {
9192
) : (
9293
<div className="bg-white border border-gray-200">
9394
{/* Tabs + contextual actions */}
94-
<div className="px-3 pt-2 border-b border-gray-200">
95-
<div className="flex items-center justify-between">
96-
<div className="flex gap-1">
97-
<button
98-
type="button"
99-
role="tab"
100-
aria-selected={activeTab === "table"}
101-
title="View table"
95+
<div className="px-3 pt-2 border-b border-gray-200">
96+
<div className="flex justify-between h-8">
97+
<div id="tabs" className="flex gap-1">
98+
<TabButton
99+
label="Table"
100+
isActive={activeTab === "table"}
102101
onClick={() => {
103102
setActiveTab("table");
104103
navigate("/table");
105104
}}
106-
className={`text-xs px-3 py-2 border-b-2 -mb-px rounded-none focus:outline-none cursor-pointer transition-colors ${
107-
activeTab === "table"
108-
? "text-gray-900 font-semibold border-gray-900 bg-transparent"
109-
: "text-gray-600 hover:text-gray-800 hover:border-gray-400 border-transparent bg-transparent hover:bg-gray-100"
110-
}`}
111-
>
112-
Table
113-
</button>
114-
<button
115-
type="button"
116-
role="tab"
117-
aria-selected={activeTab === "pivot"}
118-
title="View pivot"
105+
title="View table"
106+
/>
107+
<TabButton
108+
label="Pivot"
109+
isActive={activeTab === "pivot"}
119110
onClick={() => {
120111
setActiveTab("pivot");
121112
navigate("/pivot");
122113
}}
123-
className={`text-xs px-3 py-2 border-b-2 -mb-px rounded-none focus:outline-none cursor-pointer transition-colors ${
124-
activeTab === "pivot"
125-
? "text-gray-900 font-semibold border-gray-900 bg-transparent"
126-
: "text-gray-600 hover:text-gray-800 hover:border-gray-400 border-transparent bg-transparent hover:bg-gray-100"
127-
}`}
128-
>
129-
Pivot
130-
</button>
114+
title="View pivot"
115+
/>
131116
</div>
132117
{activeTab === "table" && (
133-
<div className="flex gap-2 pb-1">
118+
<div className="flex gap-2 pb-2">
134119
<Button onClick={expandAll} size="sm" variant="secondary">
135120
Expand All
136121
</Button>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from "react";
2+
3+
interface TabButtonProps {
4+
label: string;
5+
isActive: boolean;
6+
onClick: () => void;
7+
title?: string;
8+
}
9+
10+
const TabButton: React.FC<TabButtonProps> = ({
11+
label,
12+
isActive,
13+
onClick,
14+
title,
15+
}) => {
16+
return (
17+
<button
18+
type="button"
19+
role="tab"
20+
aria-selected={isActive}
21+
title={title}
22+
onClick={onClick}
23+
className={`text-xs font-medium px-2 py-0.5 border-b-2 focus:outline-none cursor-pointer transition-colors ${
24+
isActive
25+
? "text-gray-900 border-gray-900 bg-transparent"
26+
: "text-gray-700 hover:text-gray-900 hover:border-gray-400 border-transparent bg-transparent hover:bg-gray-100"
27+
}`}
28+
>
29+
{label}
30+
</button>
31+
);
32+
};
33+
34+
export default TabButton;

0 commit comments

Comments
 (0)