signal-desktop/ts/components/Tabs.tsx

25 lines
612 B
TypeScript
Raw Normal View History

2023-01-03 11:55:46 -08:00
// Copyright 2021 Signal Messenger, LLC
2021-05-28 12:15:17 -04:00
// SPDX-License-Identifier: AGPL-3.0-only
2022-03-04 16:14:52 -05:00
import type { ReactNode } from 'react';
import React from 'react';
2021-05-28 12:15:17 -04:00
2022-03-04 16:14:52 -05:00
import type { TabsOptionsType } from '../hooks/useTabs';
import { useTabs } from '../hooks/useTabs';
2021-05-28 12:15:17 -04:00
type PropsType = {
children: (renderProps: { selectedTab: string }) => ReactNode;
2022-03-04 16:14:52 -05:00
} & TabsOptionsType;
2021-05-28 12:15:17 -04:00
2022-11-17 16:45:19 -08:00
export function Tabs(props: PropsType): JSX.Element {
2022-10-11 10:59:02 -07:00
const { children, ...options } = props;
const { selectedTab, tabsHeaderElement } = useTabs(options);
2021-05-28 12:15:17 -04:00
return (
<>
2022-03-04 16:14:52 -05:00
{tabsHeaderElement}
2021-05-28 12:15:17 -04:00
{children({ selectedTab })}
</>
);
2022-11-17 16:45:19 -08:00
}