aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/common/tab
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-06-26 19:54:24 +0800
committercrupest <crupest@outlook.com>2021-06-26 19:54:24 +0800
commitc3f17f1dd1099c244e36d09b14c3e131d703830e (patch)
tree9f6b58f3bf16bcd119f22475625464537aa2b42b /FrontEnd/src/views/common/tab
parenta168336c0761b263ee5371218cbf6da236c0acce (diff)
downloadtimeline-c3f17f1dd1099c244e36d09b14c3e131d703830e.tar.gz
timeline-c3f17f1dd1099c244e36d09b14c3e131d703830e.tar.bz2
timeline-c3f17f1dd1099c244e36d09b14c3e131d703830e.zip
...
Diffstat (limited to 'FrontEnd/src/views/common/tab')
-rw-r--r--FrontEnd/src/views/common/tab/TabPages.tsx58
-rw-r--r--FrontEnd/src/views/common/tab/Tabs.tsx19
2 files changed, 77 insertions, 0 deletions
diff --git a/FrontEnd/src/views/common/tab/TabPages.tsx b/FrontEnd/src/views/common/tab/TabPages.tsx
new file mode 100644
index 00000000..b7a9fb36
--- /dev/null
+++ b/FrontEnd/src/views/common/tab/TabPages.tsx
@@ -0,0 +1,58 @@
+import React from "react";
+import { useTranslation } from "react-i18next";
+
+import { convertI18nText, I18nText, UiLogicError } from "@/common";
+
+export interface TabPage {
+ id: string;
+ tabText: I18nText;
+ page: React.ReactNode;
+}
+
+export interface TabPagesProps {
+ pages: TabPage[];
+ actions?: React.ReactNode;
+ className?: string;
+ style?: React.CSSProperties;
+ navClassName?: string;
+ navStyle?: React.CSSProperties;
+ pageContainerClassName?: string;
+ pageContainerStyle?: React.CSSProperties;
+}
+
+const TabPages: React.FC<TabPagesProps> = ({
+ pages,
+ actions,
+ className,
+ style,
+ navClassName,
+ navStyle,
+ pageContainerClassName,
+ pageContainerStyle,
+}) => {
+ // TODO:
+
+ if (pages.length === 0) {
+ throw new UiLogicError("Page list can't be empty.");
+ }
+
+ const { t } = useTranslation();
+
+ const [tab, setTab] = React.useState<string>(pages[0].id);
+
+ const currentPage = pages.find((p) => p.id === tab);
+
+ if (currentPage == null) {
+ throw new UiLogicError("Current tab value is bad.");
+ }
+
+ return (
+ <div className={className} style={style}>
+ <div className={pageContainerClassName} style={pageContainerStyle}>
+ {currentPage.page}
+ </div>
+ </div>
+ );
+};
+
+export default TabPages;
diff --git a/FrontEnd/src/views/common/tab/Tabs.tsx b/FrontEnd/src/views/common/tab/Tabs.tsx
new file mode 100644
index 00000000..29ebcbd8
--- /dev/null
+++ b/FrontEnd/src/views/common/tab/Tabs.tsx
@@ -0,0 +1,19 @@
+import React from "react";
+
+import { I18nText } from "@/common";
+
+export interface Tab {
+ name: string;
+ text: I18nText;
+ link?: string;
+ onClick?: () => void;
+}
+
+export interface TabsProps {
+ activeTabName?: string;
+ tabs: Tab[];
+}
+
+export default function Tabs(props: TabsProps): React.ReactElement | null {
+ return <div></div>;
+}