Skip to content

Commit

Permalink
[#217] add dRep directory 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 29, 2024
1 parent 84ef6f0 commit 661a343
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 3 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.
6 changes: 6 additions & 0 deletions govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Dashboard,
DashboardGovernanceActionsCategory,
DelegateTodRep,
DRepDirectory,
ErrorPage,
GovernanceActionDetails,
GovernanceActions,
Expand Down Expand Up @@ -104,7 +105,12 @@ export default () => {
path={PATHS.dashboardGovernanceActionsCategory}
element={<DashboardGovernanceActionsCategory />}
/>
<Route
path={PATHS.dashboardDRepDirectory}
element={<DRepDirectory />}
/>
</Route>
<Route path={PATHS.dRepDirectory} element={<DRepDirectory />} />
<Route
path={PATHS.createGovernanceAction}
element={<CreateGovernanceAction />}
Expand Down
8 changes: 8 additions & 0 deletions govtool/frontend/src/components/atoms/ContentBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Box, BoxProps } from "@mui/material";
import { FC } from "react";

export const ContentBox: FC<BoxProps> = ({ children, ...props }) => (
<Box maxWidth={1290} mx="auto" {...props}>
{children}
</Box>
);
8 changes: 8 additions & 0 deletions govtool/frontend/src/components/atoms/PagePaddingBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Box, BoxProps } from "@mui/material";
import { FC } from "react";

export const PagePaddingBox: FC<BoxProps> = ({ children, ...props }) => (
<Box px={{ xxs: 2, md: 5 }} {...props}>
{children}
</Box>
);
2 changes: 2 additions & 0 deletions govtool/frontend/src/components/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from "./ActionRadio";
export * from "./Background";
export * from "./Button";
export * from "./Checkbox";
export * from "./ContentBox";
export * from "./CopyButton";
export * from "./DrawerLink";
export * from "./ExternalModalButton";
Expand All @@ -16,6 +17,7 @@ export * from "./modal/Modal";
export * from "./modal/ModalContents";
export * from "./modal/ModalHeader";
export * from "./modal/ModalWrapper";
export * from "./PagePaddingBox";
export * from "./Radio";
export * from "./ScrollToManage";
export * from "./ScrollToTop";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Box, Divider } from "@mui/material";

import { AutomatedVotingCardProps } from "./types";
import { Button, Spacer, Typography } from "@atoms";
import { useScreenDimension, useTranslation } from "@hooks";
import { AutomatedVotingCardProps } from "./types";

export const AutomatedVotingCard = ({
description,
Expand Down
24 changes: 24 additions & 0 deletions govtool/frontend/src/components/molecules/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useScreenDimension } from "@hooks";
import { FC } from "react";
import { Typography, PagePaddingBox, ContentBox } from "@/components/atoms";

interface PageTitleProps {
title: string;
}

export const PageTitle: FC<PageTitleProps> = ({ title }) => {
const { isMobile } = useScreenDimension();

return (
<PagePaddingBox
borderBottom={(theme) => `1px solid ${theme.palette.neutralWhite}`}
py={3}
>
<ContentBox>
<Typography variant={isMobile ? "title1" : "headline5"}>
{title}
</Typography>
</ContentBox>
</PagePaddingBox>
);
};
1 change: 1 addition & 0 deletions govtool/frontend/src/components/molecules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export * from "./Share";
export * from "./SliderArrow";
export * from "./SliderArrows";
export * from "./Step";
export * from "./PageTitle";
export * from "./VoteActionForm";
export * from "./VotesSubmitted";
export * from "./WalletInfoCard";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ export const AutomatedVotingOptions = () => {
onClickDelegate={() => {}}
onClickInfo={() => {}}
title={t("dRepDirectory.abstainCardTitle")}
votingPower={"99,111,111"}
votingPower="99,111,111"
/>
<Spacer y={2} />
<AutomatedVotingCard
description={t("dRepDirectory.noConfidenceDescription")}
onClickDelegate={() => {}}
onClickInfo={() => {}}
title={t("dRepDirectory.noConfidenceTitle")}
votingPower={"99,111,111"}
votingPower="99,111,111"
/>
</>
) : null}
Expand Down
17 changes: 17 additions & 0 deletions govtool/frontend/src/components/organisms/DRepDirectoryContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FC } from "react";

interface DRepDirectoryContentProps {
isConnected?: boolean;
}

export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
isConnected,
}) => (
<>
<p>DRepDirectory</p>
<p>
connected:
{String(!!isConnected)}
</p>
</>
);
1 change: 1 addition & 0 deletions govtool/frontend/src/components/organisms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from "./DelegateTodRepStepOne";
export * from "./DelegateTodRepStepTwo";
export * from "./Drawer";
export * from "./DrawerMobile";
export * from "./DRepDirectoryContent";
export * from "./EditDRepInfoSteps";
export * from "./ExternalLinkModal";
export * from "./Footer";
Expand Down
2 changes: 2 additions & 0 deletions govtool/frontend/src/consts/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const ICONS = {
dashboardIcon: "/icons/Dashboard.svg",
download: "/icons/Download.svg",
drawerIcon: "/icons/DrawerIcon.svg",
dRepDirectoryActiveIcon: "/icons/DRepDirectoryActive.svg",
dRepDirectoryIcon: "/icons/DRepDirectory.svg",
externalLinkIcon: "/icons/ExternalLink.svg",
faqsActiveIcon: "/icons/FaqsActive.svg",
faqsIcon: "/icons/Faqs.svg",
Expand Down
13 changes: 13 additions & 0 deletions govtool/frontend/src/consts/navItems.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import i18n from "@/i18n";
import { ICONS } from "./icons";
import { PATHS } from "./paths";

Expand All @@ -8,6 +9,11 @@ export const NAV_ITEMS = [
label: "Dashboard",
newTabLink: null,
},
{
dataTestId: "drep-directory-link",
navTo: PATHS.dRepDirectory,
label: i18n.t("dRepDirectory.title"),
},
{
dataTestId: "governance-actions-link",
navTo: PATHS.governanceActions,
Expand Down Expand Up @@ -37,6 +43,13 @@ export const CONNECTED_NAV_ITEMS = [
icon: ICONS.dashboardIcon,
newTabLink: null,
},
{
dataTestId: "drep-directory-link",
label: i18n.t("dRepDirectory.title"),
navTo: PATHS.dashboardDRepDirectory,
activeIcon: ICONS.dRepDirectoryActiveIcon,
icon: ICONS.dRepDirectoryIcon,
},
{
dataTestId: "governance-actions-link",
label: "Governance Actions",
Expand Down
2 changes: 2 additions & 0 deletions govtool/frontend/src/consts/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export const PATHS = {
dashboardGovernanceActionsAction: "/connected/governance_actions/:proposalId",
dashboardGovernanceActionsCategory:
"/connected/governance_actions/category/:category",
dashboardDRepDirectory: "/connected/drep_directory",
delegateTodRep: "/delegate",
dRepDirectory: "/drep_directory",
editDrepMetadata: "/edit_drep",
error: "/error",
faqs: "/faqs",
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export const en = {
noConfidenceDescription:
"Select this to signal no confidence in the current constitutional committee by voting NO on every proposal and voting YES to no confidence proposals",
noConfidenceTitle: "Signal No Confidence on Every Vote",
title: "DRep Directory",
votingPower: "Voting Power",
},
errorPage: {
Expand Down
33 changes: 33 additions & 0 deletions govtool/frontend/src/pages/DRepDirectory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { useTranslation } from "@hooks";
import { checkIsWalletConnected } from "@/utils";
import { Background, PagePaddingBox, ContentBox } from "@/components/atoms";
import { DRepDirectoryContent, TopNav } from "@/components/organisms";
import { PageTitle } from "@/components/molecules";

export const DRepDirectory = () => {
const { t } = useTranslation();

const isConnected = !checkIsWalletConnected();

if (isConnected) {
return (
<PagePaddingBox py={2}>
<DRepDirectoryContent isConnected />
</PagePaddingBox>
);
}

return (
<Background>
<TopNav />

<PageTitle title={t("dRepDirectory.title")} />

<PagePaddingBox py={2}>
<ContentBox>
<DRepDirectoryContent />
</ContentBox>
</PagePaddingBox>
</Background>
);
};
2 changes: 2 additions & 0 deletions govtool/frontend/src/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ export * from "./CreateGovernanceAction";
export * from "./Dashboard";
export * from "./DashboardGovernanceActionsCategory";
export * from "./DelegateTodRep";
export * from "./DRepDirectory";
export * from "./EditDRepMetadata";
export * from "./ErrorPage";
export * from "./GovernanceActionDetails";
export * from "./GovernanceActions";
export * from "./GovernanceActionsCategory";
export * from "./Home";
export * from "./RegisterAsSoleVoter";
export * from "./RegisterAsdRep";
export * from "./RegisterAsSoleVoter";
export * from "./RetireAsDrep";
Expand Down

0 comments on commit 661a343

Please sign in to comment.