diff options
| author | 2023-11-03 21:13:33 +0800 | |
|---|---|---|
| committer | 2023-11-03 21:13:33 +0800 | |
| commit | 9f0d43fe099a95ab1516ae951dcb60a89e76a5a5 (patch) | |
| tree | 51614fe47bff8bb11028a07d4a35c34c9ff6594a /docs/components/Tabs.tsx | |
| parent | 8f135707d069c900e055dae71e69909d6b9a41bb (diff) | |
| download | HydroRoll-9f0d43fe099a95ab1516ae951dcb60a89e76a5a5.tar.gz HydroRoll-9f0d43fe099a95ab1516ae951dcb60a89e76a5a5.zip | |
chore: delete useless codes
Diffstat (limited to 'docs/components/Tabs.tsx')
| -rw-r--r-- | docs/components/Tabs.tsx | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/docs/components/Tabs.tsx b/docs/components/Tabs.tsx deleted file mode 100644 index f75019a..0000000 --- a/docs/components/Tabs.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import type { FC, ReactElement } from "react"; - -import { Tabs as NextraTabs, Tab } from "nextra-theme-docs"; -import useSWR from "swr"; - -export { Tab }; - -export const Tabs: FC<{ - storageKey?: string; - items: string[]; - children: ReactElement; -}> = function ({ storageKey = "tab-index", items, children = null, ...props }) { - // Use SWR so all tabs with the same key can sync their states. - const { data, mutate } = useSWR(storageKey, (key) => { - try { - return JSON.parse(localStorage.getItem(key)); - } catch (e) { - return null; - } - }); - - const selectedIndex = items.indexOf(data); - - return ( - <NextraTabs - onChange={(index) => { - localStorage.setItem(storageKey, JSON.stringify(items[index])); - mutate(items[index], false); - }} - selectedIndex={selectedIndex === -1 ? undefined : selectedIndex} - items={items} - {...props} - > - {children} - </NextraTabs> - ); -}; |
