import React, { useState, memo } from 'react'; import styled from 'styled-components'; import isBoolean from 'lodash/isBoolean'; import ExpansionPanel from '@material-ui/core/ExpansionPanel'; import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import './Panel.css'; const CustomExpansionPanel = styled(ExpansionPanel)` && { ${(props) => props.error && 'border-color: red !important;'} ${(props) => props.isGhost && ` box-shadow: none; border-width: 0; `} } `; const CustomExpansionPanelDetails = styled(ExpansionPanelDetails)` && { display: block; padding: 0; } `; export function Panel({ expanded, header, children, collapsible, ...rest }) { const [isExpanded, changeExpandedState] = useState( isBoolean(expanded) ? expanded : true ); return ( {header && (collapsible ? ( collapsible && changeExpandedState(!isExpanded)} expandIcon={} > {header} ) : (
{header}
))} {children}
); } export default memo(Panel);