Skip to content

Commit

Permalink
#217 add DRepDirectory page and nav items
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dyczka authored and MSzalowski committed Mar 1, 2024
1 parent 1aacaed commit bf8af20
Show file tree
Hide file tree
Showing 15 changed files with 448 additions and 96 deletions.
13 changes: 13 additions & 0 deletions govtool/frontend/public/icons/DRepDirectory.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions govtool/frontend/public/icons/DRepDirectoryActive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
GovernanceActionsCategory,
DashboardGovernanceActionsCategory,
RetireAsSoleVoter,
DRepDirectory,
DRepDirectoryContent,
} from "@pages";
import {
callAll,
Expand Down Expand Up @@ -114,7 +116,12 @@ export default function App() {
path={PATHS.dashboard_governance_actions_category}
element={<DashboardGovernanceActionsCategory />}
/>
<Route
path={PATHS.dashboard_drep_directory}
element={<DRepDirectoryContent isConnected />}
/>
</Route>
<Route path={PATHS.drep_directory} element={<DRepDirectory />} />
<Route path={PATHS.delegateTodRep} element={<DelegateTodRep />} />
<Route path={PATHS.registerAsdRep} element={<RegisterAsdRep />} />
<Route
Expand All @@ -133,8 +140,8 @@ export default function App() {
handleClose={
!modals[modal.type].preventDismiss
? callAll(modals[modal.type]?.onClose, () =>
openModal({ type: "none", state: null })
)
openModal({ type: "none", state: null })
)
: undefined
}
>
Expand Down
186 changes: 98 additions & 88 deletions govtool/frontend/src/components/organisms/DashboardTopNav.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { Box, Grid, IconButton, SwipeableDrawer } from "@mui/material";
import { Box, BoxProps, Grid, IconButton, SwipeableDrawer } from "@mui/material";

import { Background, Link, VotingPowerChips, Typography } from "@atoms";
import { useScreenDimension, useTranslation } from "@hooks";
Expand All @@ -9,13 +9,14 @@ import { useCardano } from "@context";
import { DRepInfoCard, WalletInfoCard } from "@molecules";
import { openInNewTab } from "@utils";

type DashboardTopNavProps = {
export type DashboardTopNavProps = {
imageSRC?: string;
imageWidth?: number;
imageHeight?: number;
title: string;
isDrawer?: boolean;
isVotingPowerHidden?: boolean;
sx?: BoxProps["sx"];
};

const DRAWER_PADDING = 2;
Expand All @@ -27,6 +28,7 @@ export const DashboardTopNav = ({
imageWidth,
imageHeight,
isVotingPowerHidden,
sx
}: DashboardTopNavProps) => {
const { isMobile, screenWidth } = useScreenDimension();
const { voter } = useCardano();
Expand All @@ -40,7 +42,10 @@ export const DashboardTopNav = ({
py={3}
display={"flex"}
bgcolor={isMobile ? "#FBFBFF" : undefined}
sx={{ backdropFilter: "blur(10px)" }}
sx={{
backdropFilter: "blur(10px)",
...sx
}}
alignItems={"center"}
justifyContent={"space-between"}
borderBottom={1}
Expand Down Expand Up @@ -80,93 +85,98 @@ export const DashboardTopNav = ({
</IconButton>
)}
</Box>
{isMobile && (
<SwipeableDrawer
anchor="right"
open={isDrawerOpen}
onClose={() => setIsDrawerOpen(false)}
onOpen={() => setIsDrawerOpen(true)}
>
<Background>
<Box
flex={1}
px={DRAWER_PADDING}
pb={3}
display="flex"
flexDirection="column"
height={"100%"}
>
<Box flex={1}>
<Box
width={screenWidth - CALCULATED_DRAWER_PADDING}
display="flex"
flex={1}
py={3}
justifyContent="space-between"
>
<img src={ICONS.appLogoIcon} height={25} />
<IconButton
data-testid={"close-drawer-button"}
sx={{ padding: 0 }}
onClick={() => setIsDrawerOpen(false)}
{
isMobile && (
<SwipeableDrawer
anchor="right"
open={isDrawerOpen}
onClose={() => setIsDrawerOpen(false)}
onOpen={() => setIsDrawerOpen(true)}
>
<Background>
<Box
flex={1}
px={DRAWER_PADDING}
pb={3}
display="flex"
flexDirection="column"
height={"100%"}
>
<Box flex={1}>
<Box
width={screenWidth - CALCULATED_DRAWER_PADDING}
display="flex"
flex={1}
py={3}
justifyContent="space-between"
>
<img src={ICONS.closeDrawerIcon} />
</IconButton>
</Box>
<Grid container direction={"column"} rowGap={4} mt={6}>
<Grid item>
<Link
dataTestId="home-link"
navTo={PATHS.dashboard}
label={t("menu.myDashboard")}
size="big"
onClick={() => {
setIsDrawerOpen(false);
}}
isConnectWallet
/>
</Grid>
<Grid item>
<Link
dataTestId="governance-actions-link"
navTo={PATHS.dashboard_governance_actions}
label={t("menu.viewGovActions")}
size="big"
onClick={() => {
setIsDrawerOpen(false);
}}
isConnectWallet
/>
<img src={ICONS.appLogoIcon} height={25} />
<IconButton
data-testid={"close-drawer-button"}
sx={{ padding: 0 }}
onClick={() => setIsDrawerOpen(false)}
>
<img src={ICONS.closeDrawerIcon} />
</IconButton>
</Box>
<Grid container direction={"column"} rowGap={4} mt={6}>
<Grid item>
<Link
dataTestId="home-link"
navTo={PATHS.dashboard}
label={t("menu.myDashboard")}
size="big"
onClick={() => {
setIsDrawerOpen(false);
}}
isConnectWallet
/>
</Grid>
<Grid item>
<Link
dataTestId="governance-actions-link"
navTo={PATHS.dashboard_governance_actions}
label={t("menu.viewGovActions")}
size="big"
onClick={() => {
setIsDrawerOpen(false);
}}
isConnectWallet
/>
</Grid>
<Grid item>
<Link
dataTestId="guides-link"
navTo={""}
label={t("menu.guides")}
size="big"
onClick={() => {
openInNewTab(
"https://docs.sanchogov.tools/about/what-is-sanchonet-govtool"
);
setIsDrawerOpen(false);
}}
isConnectWallet
/>
</Grid>
<Grid item>
<Link
dataTestId="faqs-link"
navTo={""}
label={t("menu.faqs")}
size="big"
onClick={() => {
openInNewTab("https://docs.sanchogov.tools/faqs");
setIsDrawerOpen(false);
}}
isConnectWallet
/>
</Grid>
</Grid>
<Grid item>
<Link
dataTestId="guides-link"
navTo={""}
label={t("menu.guides")}
size="big"
onClick={() => {
openInNewTab(
"https://docs.sanchogov.tools/about/what-is-sanchonet-govtool"
);
setIsDrawerOpen(false);
}}
isConnectWallet
/>
</Grid>
<Grid item>
<Link
dataTestId="faqs-link"
navTo={""}
label={t("menu.faqs")}
size="big"
onClick={() => {
openInNewTab("https://docs.sanchogov.tools/faqs");
setIsDrawerOpen(false);
}}
isConnectWallet
/>
</Grid>
</Grid>
</Box>
{dRep?.isRegistered && <DRepInfoCard />}
<Box py={2} />
<WalletInfoCard />
</Box>
{(voter?.isRegisteredAsDRep ||
voter?.isRegisteredAsSoleVoter) && <DRepInfoCard />}
Expand Down
73 changes: 73 additions & 0 deletions govtool/frontend/src/components/organisms/MainLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Box } from "@mui/material";
import { ComponentProps, FC, PropsWithChildren } from "react";

import { ICONS } from "@consts";
import { Background, Typography } from "@atoms";
import { useScreenDimension } from "@hooks";
import { DashboardTopNav, DashboardTopNavProps, Drawer, Footer } from "@organisms";
import { NewTopNav } from "./NewTopNav";
import { theme } from "@/theme";

export type DashboardLayoutProps = PropsWithChildren
& Pick<DashboardTopNavProps, 'title'>
& ComponentProps<typeof Box> & {
isConnected: boolean;
hideDrawer?: boolean;
};

export const MainLayout: FC<DashboardLayoutProps> = ({
children,
sx,
title,
isConnected,
hideDrawer,
...boxProps
}) => {
const { isMobile } = useScreenDimension();

const showDrawer = !!isConnected && !isMobile && !hideDrawer;

return (
<Background opacity={0.7}>
<Box display={"flex"} flexDirection={"row"} position={"relative"}>
{showDrawer && <Drawer />}

<Box
flex={1}
height="100vh"
overflow="auto"
display="flex"
flexDirection="column"
>
{isConnected ? (
<DashboardTopNav
title={title}
imageSRC={isMobile ? ICONS.appLogoIcon : undefined}
imageHeight={24}
isDrawer={!hideDrawer}
sx={{ flexGrow: 0, position: "sticky", top: 0 }}
/>
) : (
<>
<NewTopNav />
{title && (
<Box
borderBottom={`1px solid ${theme.palette.neutralWhite}`}
px={{ xxs: 2, md: 5 }}
py={3}
>
<Typography variant="headline5">{title}</Typography>
</Box>
)}
</>
)}
<Box flex={1} px={5} py={1.5} {...boxProps}>
{children}
</Box>

<Footer />
</Box>
</Box>
</Background>
);
};
Loading

0 comments on commit bf8af20

Please sign in to comment.