import SpaIcon from '@mui/icons-material/Spa'; import { Avatar, Paper, Typography, useTheme } from '@mui/material'; import { always, cond, equals, has, T } from 'ramda'; import type { ChildrenProps } from '..'; import type { ComplexData, SimpleData } from './datas'; export const SimpleContent = ({ node, depth, isExpanded, nodeSize, expandCollapseNode }: ChildrenProps): JSX.Element => { const theme = useTheme(); const fillColor = cond([ [equals('critical'), always(theme.palette.error.main)], [equals('warning'), always(theme.palette.warning.main)], [T, always(theme.palette.success.main)] ])(node.data.status); if (equals(depth, 0)) { return (
{node.data.name}
); } return ( { expandCollapseNode(node); }} sx={{ alignItems: 'center', backgroundColor: fillColor, cursor: node.children ? 'pointer' : 'default', display: 'flex', flexDirection: 'column', height: nodeSize.height, justifyContent: 'center', p: 1, position: 'relative', width: nodeSize.width }} > {!node.children && ( )} {node.data.name} {node.children && ( {isExpanded ? 'Expanded' : 'Collapsed'} )} ); }; export const ComplexContent = ({ node, depth, nodeSize, expandCollapseNode, onMouseDown, onMouseUp }: ChildrenProps): JSX.Element => { const theme = useTheme(); const fillColor = cond([ [equals('critical'), always(theme.palette.error.main)], [equals('warning'), always(theme.palette.warning.main)], [T, always(theme.palette.success.main)] ])(node.data.status); if (equals(depth, 0)) { return ( {node.data.name} ); } if (has('count', node.data)) { return (
expandCollapseNode(node))} sx={{ backgroundColor: fillColor, color: theme.palette.text.primary, cursor: 'pointer' }} > {node.data.count}
); } return ( {!node.children && ( )} {node.data.name} ); };