-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#216] use Accordion from MUI to improve user experience
- Loading branch information
Showing
3 changed files
with
42 additions
and
47 deletions.
There are no files selected for viewing
68 changes: 27 additions & 41 deletions
68
govtool/frontend/src/components/organisms/AutomatedVotingOptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,56 @@ | ||
import { useState } from "react"; | ||
import { Box } from "@mui/material"; | ||
import { | ||
Accordion, | ||
AccordionDetails, | ||
AccordionSummary, | ||
Box, | ||
} from "@mui/material"; | ||
|
||
import { Spacer, Typography } from "@atoms"; | ||
import { Typography } from "@atoms"; | ||
import { ICONS } from "@consts"; | ||
import { useTranslation } from "@hooks"; | ||
import { AutomatedVotingCard } from "@molecules"; | ||
|
||
export const AutomatedVotingOptions = () => { | ||
const [isOpen, setIsOpen] = useState<boolean>(false); | ||
const { t } = useTranslation(); | ||
|
||
const handleOpen = () => { | ||
setIsOpen((prev) => !prev); | ||
}; | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
bgcolor: "#D6E2FF80", | ||
border: "1px solid #F7F9FB", | ||
borderRadius: 3, | ||
boxShadow: `2px 2px 15px 0px #2F62DC47`, | ||
display: "flex", | ||
flexDirection: "column", | ||
padding: "12px 24px", | ||
}} | ||
<Accordion | ||
elevation={3} | ||
sx={(theme) => ({ | ||
bgcolor: `${theme.palette.lightBlue}80`, | ||
border: `1px solid ${theme.palette.neutralWhite}`, | ||
})} | ||
> | ||
<Box | ||
onClick={handleOpen} | ||
sx={{ | ||
alignItems: "center", | ||
cursor: "pointer", | ||
display: "flex", | ||
flex: 1, | ||
justifyContent: "space-between", | ||
}} | ||
<AccordionSummary | ||
expandIcon={<img alt="arrow" src={ICONS.arrowDownIcon} />} | ||
sx={{ borderRadius: 3, px: { xxs: 2, md: 3 } }} | ||
> | ||
<Typography>{t("dRepDirectory.automatedVotingOptions")}</Typography> | ||
<img | ||
alt="arrow" | ||
src={ICONS.arrowDownIcon} | ||
style={{ | ||
transform: `rotate(${isOpen ? "180deg" : "0"})`, | ||
</AccordionSummary> | ||
<AccordionDetails sx={{ p: { xxs: 2, md: 3 }, pt: { xxs: 0, md: 0 } }}> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: 2, | ||
}} | ||
/> | ||
</Box> | ||
{isOpen ? ( | ||
<> | ||
<Spacer y={2} /> | ||
> | ||
<AutomatedVotingCard | ||
description={t("dRepDirectory.abstainCardDescription")} | ||
onClickDelegate={() => {}} | ||
onClickInfo={() => {}} | ||
title={t("dRepDirectory.abstainCardTitle")} | ||
votingPower={"99,111,111"} | ||
/> | ||
<Spacer y={2} /> | ||
<AutomatedVotingCard | ||
description={t("dRepDirectory.noConfidenceDescription")} | ||
onClickDelegate={() => {}} | ||
onClickInfo={() => {}} | ||
title={t("dRepDirectory.noConfidenceTitle")} | ||
votingPower={"99,111,111"} | ||
/> | ||
</> | ||
) : null} | ||
</Box> | ||
</Box> | ||
</AccordionDetails> | ||
</Accordion> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters