From a1f69d978426c6a4cb7e8f3116e087553dbbffd5 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 31 Aug 2023 19:18:48 +0800 Subject: ... --- FrontEnd/src/components/tab/TabBar.tsx | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 FrontEnd/src/components/tab/TabBar.tsx (limited to 'FrontEnd/src/components/tab/TabBar.tsx') diff --git a/FrontEnd/src/components/tab/TabBar.tsx b/FrontEnd/src/components/tab/TabBar.tsx new file mode 100644 index 00000000..601f664d --- /dev/null +++ b/FrontEnd/src/components/tab/TabBar.tsx @@ -0,0 +1,69 @@ +import { ReactNode } from "react"; +import { Link } from "react-router-dom"; +import classNames from "classnames"; + +import { Text, ThemeColor, useC } from "../common"; + +import "./TabBar.css"; + +export interface Tab { + name: string; + text: Text; + link?: string; + onClick?: () => void; +} + +export interface TabsProps { + activeTabName?: string; + tabs: Tab[]; + color?: ThemeColor; + actions?: ReactNode; + dense?: boolean; + className?: string; +} + +export default function TabBar(props: TabsProps) { + const { tabs, color, activeTabName, className, dense, actions } = props; + + const c = useC(); + + return ( +
+
+ {tabs.map((tab) => { + const { name, text, link, onClick } = tab; + + const active = activeTabName === name; + const className = classNames("cru-tab-bar-item", active && "active"); + + if (link != null) { + return ( + + {c(text)} + + ); + } else { + return ( + + {c(text)} + + ); + } + })} +
+
{actions}
+
+ ); +} -- cgit v1.2.3