feat: updated `Tabs` component

pull/107/head
Samuel Rowe 3 years ago
parent 56c8998522
commit 3a8cb66157

@ -1,7 +1,10 @@
import { styled } from "@mui/joy"; import { styled } from "@mui/joy";
import { FunctionComponent, ReactElement, ReactNode } from "react"; import { FunctionComponent, ReactElement, ReactNode } from "react";
import { TabContext } from "../contexts";
export interface ITabsProps { export interface ITabsProps {
value: string;
onChange: (newValue: string) => void;
children: ReactNode; children: ReactNode;
} }
@ -30,11 +33,15 @@ const Nav = styled("nav")`
const Tabs: FunctionComponent<ITabsProps> = ( const Tabs: FunctionComponent<ITabsProps> = (
props: ITabsProps props: ITabsProps
): ReactElement => { ): ReactElement => {
const { children } = props; const { children, value, onChange } = props;
return ( return (
<Root> <Root>
<Nav aria-label="Tabs">{children}</Nav> <Nav>
<TabContext.Provider value={{ value, onChange }}>
{children}
</TabContext.Provider>
</Nav>
</Root> </Root>
); );
}; };

Loading…
Cancel
Save