1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-18 11:14:57 +02:00
unleash.unleash/frontend/src/component/common/VerticalTabs/VerticalTabs.tsx
Nuno Góis 4167a60588
feat: biome lint frontend (#4903)
Follows up on https://github.com/Unleash/unleash/pull/4853 to add Biome
to the frontend as well.


![image](https://github.com/Unleash/unleash/assets/14320932/1906faf1-fc29-4172-a4d4-b2716d72cd65)

Added a few `biome-ignore` to speed up the process but we may want to
check and fix them in the future.
2023-10-02 13:25:46 +01:00

67 lines
1.5 KiB
TypeScript

import { styled } from '@mui/material';
import { VerticalTab } from './VerticalTab/VerticalTab';
const StyledTabPage = styled('div')(({ theme }) => ({
display: 'flex',
gap: theme.spacing(3),
[theme.breakpoints.down('md')]: {
flexDirection: 'column',
},
}));
const StyledTabPageContent = styled('div')(() => ({
flexGrow: 1,
display: 'flex',
flexDirection: 'column',
}));
const StyledTabs = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
gap: theme.spacing(1),
width: theme.spacing(30),
flexShrink: 0,
[theme.breakpoints.down('md')]: {
width: '100%',
},
}));
export interface ITab {
id: string;
label: string;
path?: string;
hidden?: boolean;
icon?: React.ReactNode;
}
interface IVerticalTabsProps {
tabs: ITab[];
value: string;
onChange: (tab: ITab) => void;
children: React.ReactNode;
}
export const VerticalTabs = ({
tabs,
value,
onChange,
children,
}: IVerticalTabsProps) => (
<StyledTabPage>
<StyledTabs>
{tabs
.filter((tab) => !tab.hidden)
.map((tab) => (
<VerticalTab
key={tab.id}
label={tab.label}
selected={tab.id === value}
onClick={() => onChange(tab)}
icon={tab.icon}
/>
))}
</StyledTabs>
<StyledTabPageContent>{children}</StyledTabPageContent>
</StyledTabPage>
);