forked from SteamDeckHomebrew/decky-frontend-lib
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Tabs): initial tabs component, props, docs
- Loading branch information
1 parent
621e47c
commit abbd3cd
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<TabsProps>; |