-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#216] add Automated Voting Options component
- Loading branch information
Showing
7 changed files
with
195 additions
and
1 deletion.
There are no files selected for viewing
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
100 changes: 100 additions & 0 deletions
100
govtool/frontend/src/components/molecules/AutomatedVotingCard.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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Box, Divider } from "@mui/material"; | ||
|
||
import { AutomatedVotingCardProps } from "./types"; | ||
import { Button, Spacer, Typography } from "@atoms"; | ||
import { useScreenDimension, useTranslation } from "@hooks"; | ||
|
||
export const AutomatedVotingCard = ({ | ||
description, | ||
onClickDelegate, | ||
onClickInfo, | ||
title, | ||
votingPower, | ||
}: AutomatedVotingCardProps) => { | ||
const { isMobile, screenWidth } = useScreenDimension(); | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
alignItems: "center", | ||
bgcolor: "#FFFFFF4D", | ||
borderRadius: 4, | ||
boxShadow: `0px 4px 15px 0px #DDE3F5`, | ||
display: "flex", | ||
flex: 1, | ||
flexDirection: screenWidth < 1440 ? "column" : "row", | ||
justifyContent: "space-between", | ||
padding: "18px 24px", | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
flex: 1, | ||
mb: screenWidth < 1440 ? 1.5 : 0, | ||
width: screenWidth < 1440 ? "100%" : "auto", | ||
}} | ||
> | ||
<Typography>{title}</Typography> | ||
<Typography fontWeight={400} sx={{ mt: 0.5 }} variant="body2"> | ||
{description} | ||
</Typography> | ||
</Box> | ||
<Divider | ||
flexItem | ||
orientation={screenWidth < 1440 ? "horizontal" : "vertical"} | ||
sx={{ ml: screenWidth < 1440 ? 0 : 1 }} | ||
variant={screenWidth < 1440 ? "fullWidth" : "middle"} | ||
/> | ||
<Box | ||
sx={{ | ||
alignContent: "flex-start", | ||
display: "flex", | ||
flexDirection: "column", | ||
px: screenWidth < 1440 ? 0 : 4.25, | ||
py: screenWidth < 1440 ? 1 : 0, | ||
width: screenWidth < 1440 ? "100%" : "auto", | ||
}} | ||
> | ||
<Typography color="neutralGray" fontWeight={500} variant="caption"> | ||
{t("dRepDirectory.votingPower")} | ||
</Typography> | ||
<Typography sx={{ display: "flex", flexDirection: "row", mt: 0.5 }}> | ||
<Typography fontWeight={400}>₳</Typography> | ||
{votingPower} | ||
</Typography> | ||
</Box> | ||
<Divider | ||
flexItem | ||
orientation={screenWidth < 1440 ? "horizontal" : "vertical"} | ||
sx={{ mr: screenWidth < 1440 ? 0 : 1 }} | ||
variant={screenWidth < 1440 ? "fullWidth" : "middle"} | ||
/> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
flexDirection: "row", | ||
mt: screenWidth < 1440 ? 3 : 0, | ||
width: screenWidth < 1440 ? "100%" : "auto", | ||
}} | ||
> | ||
<Button | ||
onClick={onClickInfo} | ||
size={isMobile ? "medium" : "large"} | ||
sx={{ flex: screenWidth < 768 ? 1 : undefined }} | ||
variant="outlined" | ||
> | ||
{t("info")} | ||
</Button> | ||
<Spacer x={2.5} /> | ||
<Button | ||
onClick={onClickDelegate} | ||
size={isMobile ? "medium" : "large"} | ||
sx={{ flex: screenWidth < 768 ? 1 : undefined }} | ||
> | ||
{t("delegate")} | ||
</Button> | ||
</Box> | ||
</Box> | ||
); | ||
}; |
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
70 changes: 70 additions & 0 deletions
70
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { useState } from "react"; | ||
import { Box } from "@mui/material"; | ||
|
||
import { Spacer, 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", | ||
}} | ||
> | ||
<Box | ||
onClick={handleOpen} | ||
sx={{ | ||
alignItems: "center", | ||
cursor: "pointer", | ||
display: "flex", | ||
flex: 1, | ||
justifyContent: "space-between", | ||
}} | ||
> | ||
<Typography>{t("dRepDirectory.automatedVotingOptions")}</Typography> | ||
<img | ||
alt="arrow" | ||
src={ICONS.arrowDownIcon} | ||
style={{ | ||
transform: `rotate(${isOpen ? "180deg" : "0"})`, | ||
}} | ||
/> | ||
</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> | ||
); | ||
}; |
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