-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathCustomAnimation.js
55 lines (50 loc) · 1.85 KB
/
CustomAnimation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as React from 'react';
import Box from '@mui/material/Box';
import Collapse from '@mui/material/Collapse';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeItem } from '@mui/x-tree-view/TreeItem';
import { useSpring, animated } from '@react-spring/web';
function TransitionComponent(props) {
const style = useSpring({
to: {
opacity: props.in ? 1 : 0,
transform: `translate3d(${props.in ? 0 : 20}px,0,0)`,
},
});
return (
// @ts-expect-error
<animated.div style={style}>
<Collapse {...props} />
</animated.div>
);
}
const CustomTreeItem = React.forwardRef((props, ref) => (
<TreeItem
{...props}
slots={{ groupTransition: TransitionComponent, ...props.slots }}
ref={ref}
/>
));
export default function CustomAnimation() {
return (
<Box sx={{ minHeight: 352, minWidth: 250 }}>
<SimpleTreeView defaultExpandedItems={['grid']}>
<CustomTreeItem itemId="grid" label="Data Grid">
<CustomTreeItem itemId="grid-community" label="@mui/x-data-grid" />
<CustomTreeItem itemId="grid-pro" label="@mui/x-data-grid-pro" />
<CustomTreeItem itemId="grid-premium" label="@mui/x-data-grid-premium" />
</CustomTreeItem>
<CustomTreeItem itemId="pickers" label="Date and Time Pickers">
<CustomTreeItem itemId="pickers-community" label="@mui/x-date-pickers" />
<CustomTreeItem itemId="pickers-pro" label="@mui/x-date-pickers-pro" />
</CustomTreeItem>
<CustomTreeItem itemId="charts" label="Charts">
<CustomTreeItem itemId="charts-community" label="@mui/x-charts" />
</CustomTreeItem>
<CustomTreeItem itemId="tree-view" label="Tree View">
<CustomTreeItem itemId="tree-view-community" label="@mui/x-tree-view" />
</CustomTreeItem>
</SimpleTreeView>
</Box>
);
}