From abbd3cddae24039cbc9b7d955924431e8fbacf94 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Fri, 7 Oct 2022 22:04:00 -0400 Subject: [PATCH] feat(Tabs): initial tabs component, props, docs --- src/deck-components/Tabs.tsx | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/deck-components/Tabs.tsx diff --git a/src/deck-components/Tabs.tsx b/src/deck-components/Tabs.tsx new file mode 100644 index 0000000..fecbffc --- /dev/null +++ b/src/deck-components/Tabs.tsx @@ -0,0 +1,47 @@ +import { FC, ReactNode } from 'react'; +import { findModule } from '../webpack'; +import { FooterLegendProps } from './FooterLegend'; + +/** + * Individual tab objects for the Tabs component + * + * @property id ID of this tab, can be used with activeTab to auto-focus a given tab + * @property title Title shown in the header bar + * @property renderTabAddon Return a {@link ReactNode} to render it next to the tab title, i.e. the counts for each tab on the Media page + * @property content Content of the tab + * @property footer Sets up button handlers and labels + */ +export interface Tab { + id: string; + title: string; + renderTabAddon?: () => ReactNode; + content: ReactNode; + footer?: FooterLegendProps; +} + +/** + * Props for the {@link Tabs} + * + * @property tabs array of {@link Tab} + * @property activeTab tab to automatically focus, {@link Tab.id} + * @property onShowTab Currently unknown. + * @property autoFocusContents Whether to automatically focus the tab contents or not. + * @property footer Sets up button handlers and labels + */ +export interface TabsProps { + tabs: Tab[]; + activeTab?: string; + onShowTab?: (...args: unknown[]) => void; + autoFocusContents?: boolean; +} + +/** + * Tabs component as used in the library and media tabs. See {@link TabsProps} + */ +export const Tabs = Object.values(findModule((m) => { + if (typeof m !== 'object') return false; + for (let prop in m) { + if (m[prop]?.Unbleed) return true; + } + return false; +})).find((x: any) => x?.type?.toString()?.includes("((function(){")) as FC; \ No newline at end of file