KeyOverwriteCard improvements

master
Tudor Stanciu 2021-06-25 14:44:35 +03:00
parent 4dc2b3e25e
commit 22d96b69f1
2 changed files with 27 additions and 14 deletions

View File

@ -21,6 +21,7 @@ const ExpandableCard = ({
title, title,
subtitle, subtitle,
smallHeader, smallHeader,
expandable,
Summary, Summary,
Content Content
}) => { }) => {
@ -45,6 +46,8 @@ const ExpandableCard = ({
</Avatar> </Avatar>
} }
action={ action={
<>
{expandable && (
<IconButton <IconButton
className={clsx(classes.expand, { className={clsx(classes.expand, {
[classes.expandOpen]: expanded [classes.expandOpen]: expanded
@ -56,24 +59,33 @@ const ExpandableCard = ({
> >
<ExpandMoreIcon /> <ExpandMoreIcon />
</IconButton> </IconButton>
)}
</>
} }
title={<strong>{title}</strong>} title={<strong>{title}</strong>}
subheader={subtitle} subheader={subtitle}
/> />
{Summary && <CardContent>{Summary}</CardContent>} {Summary && <CardContent>{Summary}</CardContent>}
{expandable && (
<Collapse in={expanded} timeout="auto" unmountOnExit> <Collapse in={expanded} timeout="auto" unmountOnExit>
<CardContent>{Content}</CardContent> <CardContent>{Content}</CardContent>
</Collapse> </Collapse>
)}
</Card> </Card>
); );
}; };
ExpandableCard.defaultProps = {
expandable: true
};
ExpandableCard.propTypes = { ExpandableCard.propTypes = {
Icon: PropTypes.node.isRequired, Icon: PropTypes.node.isRequired,
iconVariant: PropTypes.oneOf(["circle", "circular", "rounded", "square"]), iconVariant: PropTypes.oneOf(["circle", "circular", "rounded", "square"]),
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
subtitle: PropTypes.string, subtitle: PropTypes.string,
smallHeader: PropTypes.bool, smallHeader: PropTypes.bool,
expandable: PropTypes.bool,
Summary: PropTypes.node, Summary: PropTypes.node,
Content: PropTypes.node.isRequired Content: PropTypes.node.isRequired
}; };

View File

@ -14,6 +14,7 @@ const KeyOverwriteCard = ({ data }) => {
Icon={<FindReplaceIcon />} Icon={<FindReplaceIcon />}
title={t("Forward.Options.KeyOverwrite.Label")} title={t("Forward.Options.KeyOverwrite.Label")}
subtitle={t("Forward.Options.KeyOverwrite.Tooltip")} subtitle={t("Forward.Options.KeyOverwrite.Tooltip")}
expandable={data.advancedSettings}
Summary={<KeyOverwriteSummary data={data} />} Summary={<KeyOverwriteSummary data={data} />}
Content={<AdvancedSettingsComponent data={data.advancedSettings} />} Content={<AdvancedSettingsComponent data={data.advancedSettings} />}
/> />