Rev 2641 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
import React from 'react';
import { List, ListItem, ListItemButton, ListItemText, Typography } from '@mui/material';
import Widget from '../Widget';
const SideMenu = ({
items = [],
onChange = null,
title = '',
current = '',
defaultValue = '',
defaultLabel = ''
}) => {
const handleChange = (value) => onChange(value);
return (
<Widget>
<Widget.Body>
<Typography variant='h2'>{title}</Typography>
<List sx={{ mt: 1 }}>
<ListItemButton
sx={{ py: 0, display: defaultLabel ? 'initial' : 'none' }}
onClick={() => handleChange(defaultValue)}
>
<ListItemText
primary={defaultLabel}
slotProps={{
primary: {
sx: { fontWeight: current === defaultValue ? 'bold' : 'normal' }
}
}}
/>
</ListItemButton>
{items.map(({ value, label }) => (
<ListItem key={value} sx={{ p: 0 }}>
<ListItemButton sx={{ py: 0 }} onClick={() => handleChange(value)}>
<ListItemText id={value} primary={label} />
</ListItemButton>
</ListItem>
))}
</List>
</Widget.Body>
</Widget>
);
};
export default SideMenu;