signal-desktop/ts/components/Tabs.tsx

25 lines
617 B
TypeScript
Raw Normal View History

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