Files
react-test/docs/data/material/components/transitions/SlideFromContainer.tsx
how2ice 005cf56baf
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
init project
2025-12-12 14:26:25 +09:00

54 lines
1.4 KiB
TypeScript

import * as React from 'react';
import Box from '@mui/material/Box';
import Switch from '@mui/material/Switch';
import Paper from '@mui/material/Paper';
import Slide from '@mui/material/Slide';
import FormControlLabel from '@mui/material/FormControlLabel';
const icon = (
<Paper sx={{ m: 1, width: 100, height: 100 }} elevation={4}>
<svg width="100" height="100">
<Box
component="polygon"
points="0,100 50,00, 100,100"
sx={(theme) => ({
fill: theme.palette.common.white,
stroke: theme.palette.divider,
strokeWidth: 1,
})}
/>
</svg>
</Paper>
);
export default function SlideFromContainer() {
const [checked, setChecked] = React.useState(false);
const containerRef = React.useRef<HTMLElement>(null);
const handleChange = () => {
setChecked((prev) => !prev);
};
return (
<Box
sx={{
width: 240,
borderRadius: 2,
border: '1px solid',
borderColor: 'divider',
backgroundColor: 'background.default',
}}
>
<Box sx={{ p: 2, height: 200, overflow: 'hidden' }} ref={containerRef}>
<FormControlLabel
control={<Switch checked={checked} onChange={handleChange} />}
label="Show from target"
/>
<Slide in={checked} container={containerRef.current}>
{icon}
</Slide>
</Box>
</Box>
);
}