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
|
|
|
|
|
|
|
export const Tabs = ({
|
|
|
|
children,
|
|
|
|
initialSelectedTab,
|
|
|
|
moduleClassName,
|
|
|
|
onTabChange,
|
|
|
|
tabs,
|
|
|
|
}: PropsType): JSX.Element => {
|
2022-03-04 21:14:52 +00:00
|
|
|
const { selectedTab, tabsHeaderElement } = useTabs({
|
|
|
|
initialSelectedTab,
|
|
|
|
moduleClassName,
|
|
|
|
onTabChange,
|
|
|
|
tabs,
|
|
|
|
});
|
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 })}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|