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 committed Mar 8, 2024
1 parent f19bf69 commit df6fc10
Show file tree
Hide file tree
Showing 18 changed files with 169 additions and 7 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 @@ -22,6 +22,7 @@ import {
GovernanceActionsCategory,
DashboardGovernanceActionsCategory,
RetireAsSoleVoter,
DRepDirectory,
} from "@pages";
import {
callAll,
Expand Down Expand Up @@ -115,7 +116,12 @@ export default function App() {
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 @@ -3,6 +3,7 @@ export * from "./Background";
export * from "./Button";
export * from "./Checkbox";
export * from "./ClickOutside";
export * from "./ContentBox";
export * from "./CopyButton";
export * from "./DrawerLink";
export * from "./FormErrorMessage";
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
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 { Typography, PagePaddingBox, ContentBox } from "@/components/atoms";
import { FC } from "react";

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 @@ -14,6 +14,7 @@ export * from "./GovernanceVotedOnCard";
export * from "./LinkWithIcon";
export * from "./OrderActionsChip";
export * from "./Step";
export * from "./PageTitle";
export * from "./VoteActionForm";
export * from "./VotesSubmitted";
export * from "./WalletInfoCard";
Expand Down
16 changes: 16 additions & 0 deletions govtool/frontend/src/components/organisms/DRepDirectoryContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FC } from "react";

interface DRepDirectoryContentProps {
isConnected?: boolean;
}

export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({
isConnected,
}) => {
return (
<>
<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 @@ -17,6 +17,7 @@ export * from "./DelegateTodRepStepOne";
export * from "./DelegateTodRepStepTwo";
export * from "./Drawer";
export * from "./DrawerMobile";
export * from "./DRepDirectoryContent";
export * from "./ExternalLinkModal";
export * from "./Footer";
export * from "./GovernanceActionDetailsCard";
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 @@ -13,6 +13,8 @@ export const ICONS = {
dashboardActiveIcon: "/icons/DashboardActive.svg",
dashboardIcon: "/icons/Dashboard.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 @@ -4,8 +4,10 @@ export const PATHS = {
dashboardGovernanceActionsCategory:
"/connected/governance_actions/category/:category",
dashboardGovernanceActions: "/connected/governance_actions",
dashboardDRepDirectory: "/connected/drep_directory",
dashboard: "/dashboard",
delegateTodRep: "/delegate",
dRepDirectory: "/drep_directory",
error: "/error",
faqs: "/faqs",
governanceActions: "/governance_actions",
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 @@ -189,6 +189,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
32 changes: 32 additions & 0 deletions govtool/frontend/src/pages/DRepDirectory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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>
);
};
13 changes: 6 additions & 7 deletions govtool/frontend/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useLocation, Outlet, useNavigate } from "react-router-dom";
import { Box } from "@mui/material";

import { Background, ScrollToManage } from "@atoms";
import { PATHS } from "@consts";
import { CONNECTED_NAV_ITEMS, PATHS } from "@consts";
import { useCardano } from "@context";
import { useScreenDimension, useTranslation } from "@hooks";
import { DashboardTopNav, Drawer, Footer } from "@organisms";
Expand All @@ -18,12 +18,11 @@ export const Dashboard = () => {
const { t } = useTranslation();

const getPageTitle = (pathname: string) => {
if (pathname === PATHS.dashboard) {
return t("dashboard.title");
} else if (pathname.includes(PATHS.dashboardGovernanceActions)) {
return t("dashboard.govActions.title");
}
return "";
if (pathname === PATHS.dashboard) return t("dashboard.title");
return (
Object.values(CONNECTED_NAV_ITEMS).find(({ navTo }) => navTo === pathname)
?.label ?? ""
);
};

useEffect(() => {
Expand Down
3 changes: 3 additions & 0 deletions govtool/frontend/src/pages/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from "./ChooseStakeKey";
export * from "./CreateGovernanceAction";
export * from "./DRepDirectory";
export * from "./Dashboard";
export * from "./DashboardGovernanceActionsCategory";
export * from "./DelegateTodRep";
Expand All @@ -7,6 +9,7 @@ export * from "./GovernanceActionDetails";
export * from "./GovernanceActions";
export * from "./GovernanceActionsCategory";
export * from "./Home";
export * from "./RegisterAsSoleVoter";
export * from "./RegisterAsdRep";
export * from "./RetireAsSoleVoter";
export * from "./UpdatedRepMetadata";
18 changes: 18 additions & 0 deletions govtool/frontend/src/theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { createTheme } from "@mui/material/styles";

declare module "@mui/material/styles" {
interface BreakpointOverrides {
xxs: true;
xs: true;
sm: true;
md: true;
lg: true;
xl: true;
}
interface Palette {
accentOrange: string;
accentYellow: string;
Expand Down Expand Up @@ -50,6 +58,16 @@ declare module "@mui/material/styles" {
export type Theme = typeof theme;

export const theme = createTheme({
breakpoints: {
values: {
xxs: 0,
xs: 375,
sm: 425,
md: 768,
lg: 1024,
xl: 1440,
},
},
components: {
MuiInputBase: {
styleOverrides: {
Expand Down

0 comments on commit df6fc10

Please sign in to comment.