Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
144 lines
3.4 KiB
JavaScript
144 lines
3.4 KiB
JavaScript
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { useTheme } from '@mui/material/styles';
|
|
import AppBar from '@mui/material/AppBar';
|
|
import Tabs from '@mui/material/Tabs';
|
|
import Tab from '@mui/material/Tab';
|
|
import Typography from '@mui/material/Typography';
|
|
import Zoom from '@mui/material/Zoom';
|
|
import Fab from '@mui/material/Fab';
|
|
import AddIcon from '@mui/icons-material/Add';
|
|
import EditIcon from '@mui/icons-material/Edit';
|
|
import UpIcon from '@mui/icons-material/KeyboardArrowUp';
|
|
import { green } from '@mui/material/colors';
|
|
import Box from '@mui/material/Box';
|
|
|
|
function TabPanel(props) {
|
|
const { children, value, index, ...other } = props;
|
|
|
|
return (
|
|
<Typography
|
|
component="div"
|
|
role="tabpanel"
|
|
hidden={value !== index}
|
|
id={`action-tabpanel-${index}`}
|
|
aria-labelledby={`action-tab-${index}`}
|
|
{...other}
|
|
>
|
|
{value === index && <Box sx={{ p: 3 }}>{children}</Box>}
|
|
</Typography>
|
|
);
|
|
}
|
|
|
|
TabPanel.propTypes = {
|
|
children: PropTypes.node,
|
|
index: PropTypes.number.isRequired,
|
|
value: PropTypes.number.isRequired,
|
|
};
|
|
|
|
function a11yProps(index) {
|
|
return {
|
|
id: `action-tab-${index}`,
|
|
'aria-controls': `action-tabpanel-${index}`,
|
|
};
|
|
}
|
|
|
|
const fabStyle = {
|
|
position: 'absolute',
|
|
bottom: 16,
|
|
right: 16,
|
|
};
|
|
|
|
const fabGreenStyle = {
|
|
color: 'common.white',
|
|
bgcolor: green[500],
|
|
'&:hover': {
|
|
bgcolor: green[600],
|
|
},
|
|
};
|
|
|
|
export default function FloatingActionButtonZoom() {
|
|
const theme = useTheme();
|
|
const [value, setValue] = React.useState(0);
|
|
|
|
const handleChange = (event, newValue) => {
|
|
setValue(newValue);
|
|
};
|
|
|
|
const transitionDuration = {
|
|
enter: theme.transitions.duration.enteringScreen,
|
|
exit: theme.transitions.duration.leavingScreen,
|
|
};
|
|
|
|
const fabs = [
|
|
{
|
|
color: 'primary',
|
|
sx: fabStyle,
|
|
icon: <AddIcon />,
|
|
label: 'Add',
|
|
},
|
|
{
|
|
color: 'secondary',
|
|
sx: fabStyle,
|
|
icon: <EditIcon />,
|
|
label: 'Edit',
|
|
},
|
|
{
|
|
color: 'inherit',
|
|
sx: { ...fabStyle, ...fabGreenStyle },
|
|
icon: <UpIcon />,
|
|
label: 'Expand',
|
|
},
|
|
];
|
|
|
|
return (
|
|
<Box
|
|
sx={{
|
|
bgcolor: 'background.paper',
|
|
width: 500,
|
|
position: 'relative',
|
|
minHeight: 200,
|
|
}}
|
|
>
|
|
<AppBar position="static" color="default">
|
|
<Tabs
|
|
value={value}
|
|
onChange={handleChange}
|
|
indicatorColor="primary"
|
|
textColor="primary"
|
|
variant="fullWidth"
|
|
aria-label="action tabs example"
|
|
>
|
|
<Tab label="Item One" {...a11yProps(0)} />
|
|
<Tab label="Item Two" {...a11yProps(1)} />
|
|
<Tab label="Item Three" {...a11yProps(2)} />
|
|
</Tabs>
|
|
</AppBar>
|
|
<TabPanel value={value} index={0} dir={theme.direction}>
|
|
Item One
|
|
</TabPanel>
|
|
<TabPanel value={value} index={1} dir={theme.direction}>
|
|
Item Two
|
|
</TabPanel>
|
|
<TabPanel value={value} index={2} dir={theme.direction}>
|
|
Item Three
|
|
</TabPanel>
|
|
{fabs.map((fab, index) => (
|
|
<Zoom
|
|
key={fab.color}
|
|
in={value === index}
|
|
timeout={transitionDuration}
|
|
style={{
|
|
transitionDelay: `${value === index ? transitionDuration.exit : 0}ms`,
|
|
}}
|
|
unmountOnExit
|
|
>
|
|
<Fab sx={fab.sx} aria-label={fab.label} color={fab.color}>
|
|
{fab.icon}
|
|
</Fab>
|
|
</Zoom>
|
|
))}
|
|
</Box>
|
|
);
|
|
}
|