mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
29 lines
742 B
TypeScript
29 lines
742 B
TypeScript
import { Tabs, useMediaQuery, useTheme } from '@mui/material';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import type { FC } from 'react';
|
|
|
|
import type { RequiredChildrenProps } from 'utils';
|
|
|
|
interface RouterTabsProps extends RequiredChildrenProps {
|
|
value: string | false;
|
|
}
|
|
|
|
const RouterTabs: FC<RouterTabsProps> = ({ value, children }) => {
|
|
const navigate = useNavigate();
|
|
|
|
const theme = useTheme();
|
|
const smallDown = useMediaQuery(theme.breakpoints.down('sm'));
|
|
|
|
const handleTabChange = (_event: any, path: string) => {
|
|
navigate(path);
|
|
};
|
|
|
|
return (
|
|
<Tabs value={value} onChange={handleTabChange} variant={smallDown ? 'scrollable' : 'fullWidth'}>
|
|
{children}
|
|
</Tabs>
|
|
);
|
|
};
|
|
|
|
export default RouterTabs;
|