Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#216] use Accordion from MUI to improve user experience #438

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";
import { AutomatedVotingOptions } from ".";

interface DRepDirectoryContentProps {
isConnected?: boolean;
Expand All @@ -7,10 +8,5 @@ interface DRepDirectoryContentProps {
export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
isConnected,
}) => {
return (
<>
<p>DRepDirectory</p>
<p>connected: {String(!!isConnected)}</p>
</>
);
return <>{isConnected && <AutomatedVotingOptions />}</>;
};
13 changes: 13 additions & 0 deletions govtool/frontend/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ export const theme = createTheme({
},
},
components: {
MuiAccordion: {
styleOverrides: {
root: {
borderRadius: `12px !important`,
}
}
},
MuiInputBase: {
styleOverrides: {
root: {
Expand Down Expand Up @@ -126,3 +133,9 @@ export const theme = createTheme({
textGray: "#525252",
},
});

theme.shadows[1] = "0px 1px 2px 0px rgba(0, 51, 173, 0.08), 0px 1px 6px 1px rgba(0, 51, 173, 0.15)";
theme.shadows[2] = "0px 1px 2px 0px rgba(0, 51, 173, 0.08), 0px 2px 10px 2px rgba(0, 51, 173, 0.15)";
theme.shadows[3] = "0px 1px 3px 0px rgba(0, 51, 173, 0.08), 0px 4px 12px 3px rgba(0, 51, 173, 0.15)";
theme.shadows[4] = "0px 2px 3px 0px rgba(0, 51, 173, 0.08), 0px 6px 14px 4px rgba(0, 51, 173, 0.15)";
theme.shadows[5] = "0px 4px 4px 0px rgba(0, 51, 173, 0.08), 0px 8px 20px 6px rgba(0, 51, 173, 0.15)";