Skip to content

Commit

Permalink
feat: integrate ui design and merge
Browse files Browse the repository at this point in the history
  • Loading branch information
kittybest committed Jul 1, 2024
1 parent e1d8ee3 commit 7b0a77d
Show file tree
Hide file tree
Showing 12 changed files with 1,530 additions and 1,401 deletions.
2,741 changes: 1,392 additions & 1,349 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions public/arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/arrow-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions src/components/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,19 @@ export const Info = ({ size, showVotingInfo = false }: InfoProps): JSX.Element =
</div>
)}

{steps.map((step) => (
<InfoCard
key={step.label}
end={step.end}
start={step.start}
state={defineState({ start: step.start, end: step.end })}
title={step.label}
/>
))}
{steps.map(
(step) =>
step.start &&
step.end && (
<InfoCard
key={step.label}
end={step.end}
start={step.start}
state={defineState({ start: step.start, end: step.end })}
title={step.label}
/>
),
)}
</InfoContainer>
</div>
);
Expand Down
7 changes: 0 additions & 7 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@ export const config = {
// TODO: temp solution until we come up with solid one
// https://github.com/privacy-scaling-explorations/maci-rpgf/issues/31
voteLimit: 50,
<<<<<<< HEAD
startsAt: parseDate(process.env.NEXT_PUBLIC_START_DATE),
registrationEndsAt: parseDate(process.env.NEXT_PUBLIC_REGISTRATION_END_DATE),
reviewEndsAt: parseDate(process.env.NEXT_PUBLIC_REVIEW_END_DATE),
resultsAt: parseDate(process.env.NEXT_PUBLIC_RESULTS_DATE),
=======
startsAt: new Date(process.env.NEXT_PUBLIC_START_DATE!),
registrationEndsAt: new Date(process.env.NEXT_PUBLIC_REGISTRATION_END_DATE!),
reviewEndsAt: new Date(process.env.NEXT_PUBLIC_REVIEW_END_DATE!),
resultsAt: new Date(process.env.NEXT_PUBLIC_RESULTS_DATE!),
>>>>>>> 1e2d2ee (feat: fix bugs after rebase)
skipApprovedVoterCheck: ["true", "1"].includes(process.env.NEXT_PUBLIC_SKIP_APPROVED_VOTER_CHECK!),
tokenName: process.env.NEXT_PUBLIC_TOKEN_NAME!,
eventName: process.env.NEXT_PUBLIC_EVENT_NAME ?? "MACI-RPGF",
Expand Down
2 changes: 1 addition & 1 deletion src/features/ballot/components/BallotConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const BallotConfirmation = (): JSX.Element => {
</div>

<Notice
content={format(config.resultsAt, "d MMM yyyy hh:mm")}
content={config.resultsAt ? format(config.resultsAt, "d MMM yyyy hh:mm") : "The date would be announced soon."}
title="Results will be available after tallying."
variant="block"
/>
Expand Down
31 changes: 31 additions & 0 deletions src/features/signup/components/FaqItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import clsx from "clsx";
import Image from "next/image";
import { useState, useCallback } from "react";

import type { FAQItemProps } from "../types";

export const FAQItem = ({ title, description }: FAQItemProps): JSX.Element => {
const [isOpen, setIsOpen] = useState<boolean>(false);

const openDescription = useCallback(() => {
setIsOpen(!isOpen);
}, [isOpen, setIsOpen]);

return (
<div className="flex w-3/5 flex-col gap-4 border-b border-b-black py-6">
<button className="flex cursor-pointer justify-between" type="button" onClick={openDescription}>
<p className="font-mono text-2xl uppercase">{title}</p>

<Image
alt="arrow-down"
className={clsx(isOpen && "origin-center rotate-180")}
height="24"
src="/arrow-down.svg"
width="24"
/>
</button>

{isOpen && <div className="text-black">{description}</div>}
</div>
);
};
36 changes: 36 additions & 0 deletions src/features/signup/components/FaqList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { FAQItem } from "./FaqItem";

export const FAQList = (): JSX.Element => (
<div className="mt-28 flex flex-col items-center justify-center">
<h1 className="mb-8">FAQ</h1>

<FAQItem
description="(Please enter the main focus and description of this round.)"
title="what is the focus of this round?"
/>

<FAQItem
description="(This is related to what gatekeeper is used.)"
title="Who are the requirements for participation?"
/>

<FAQItem
description={
<div className="flex flex-col gap-4">
<p>Minimal Anti-Collusion Infrastructure (MACI) is a private, on-chain, voting system.</p>

<p>
MACI is an open-source cryptographic protocol designed to facilitate secure, anonymous voting systems while
minimizing the potential for collusion, manipulation and bribery using zero-knowledge proofs.
</p>
</div>
}
title="What is MACI?"
/>

<FAQItem
description="Join our Telegram group or Discord channel to learn more!"
title="Do you have any other questions?"
/>
</div>
);
6 changes: 6 additions & 0 deletions src/features/signup/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { ReactNode } from "react";

export interface FAQItemProps {
title: string;
description: ReactNode;
}
41 changes: 24 additions & 17 deletions src/layouts/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,31 @@ import {
useCallback,
useMemo,
} from "react";
import { tv } from "tailwind-variants";
import { useAccount } from "wagmi";

import { Footer } from "~/components/Footer";
import { createComponent } from "~/components/ui";
import { metadata } from "~/config";

const Context = createContext({ eligibilityCheck: false, showBallot: false });

const MainContainer = createComponent(
"div",
tv({
base: "w-full flex-1 2xl:container md:flex",
variants: {
type: {
default: "mt-12 pl-2 pr-6",
home: "mt-0 pl-0 pr-0",
},
},
defaultVariants: {
type: "default",
},
}),
);

export const useLayoutOptions = (): { eligibilityCheck: boolean; showBallot: boolean } => useContext(Context);

const Sidebar = ({ side = undefined, ...props }: { side?: "left" | "right" } & PropsWithChildren) => (
Expand All @@ -36,6 +54,7 @@ export interface LayoutProps {
requireAuth?: boolean;
eligibilityCheck?: boolean;
showBallot?: boolean;
type?: string;
}

export const BaseLayout = ({
Expand All @@ -46,6 +65,7 @@ export const BaseLayout = ({
requireAuth = false,
eligibilityCheck = false,
showBallot = false,
type = undefined,
children = null,
}: PropsWithChildren<
{
Expand Down Expand Up @@ -104,29 +124,16 @@ export const BaseLayout = ({
<meta content={metadata.image} name="twitter:image" />
</Head>

<div
className={clsx(" flex h-full min-h-screen flex-1 flex-col bg-white dark:bg-gray-900 dark:text-white", theme)}
>
<div className={clsx("flex h-full min-h-screen flex-1 flex-col bg-white", theme)}>
{header}

<div
className={clsx(
"mx-auto w-full flex-1 pt-12 2xl:container md:flex",
router.asPath === "/signup" && "bg-blue-50",
)}
>
<MainContainer type={type}>
{sidebar === "left" ? wrappedSidebar : null}

<div
className={clsx("w-full min-w-0 px-2 pb-24", {
"mx-auto max-w-5xl": !sidebar,
})}
>
{children}
</div>
<div className="w-full min-w-0 pb-24">{children}</div>

{sidebar === "right" ? wrappedSidebar : null}
</div>
</MainContainer>

<Footer />
</div>
Expand Down
28 changes: 14 additions & 14 deletions src/layouts/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ import { EAppState } from "~/utils/types";

import { BaseLayout, type LayoutProps } from "./BaseLayout";

type Props = PropsWithChildren<
{
sidebar?: "left" | "right";
sidebarComponent?: ReactNode;
showInfo?: boolean;
showSubmitButton?: boolean;
} & LayoutProps
>;

export const Layout = ({ children = null, ...props }: Props): JSX.Element => {
interface ILayoutProps extends PropsWithChildren<LayoutProps> {
sidebar?: "left" | "right";
sidebarComponent?: ReactNode;
showInfo?: boolean;
showSubmitButton?: boolean;
}

export const Layout = ({ children = null, ...props }: ILayoutProps): JSX.Element => {
const { address } = useAccount();
const appState = useAppState();
const { ballot } = useBallot();
Expand Down Expand Up @@ -80,21 +78,23 @@ export const Layout = ({ children = null, ...props }: Props): JSX.Element => {
);
};

export const LayoutWithSidebar = ({ ...props }: Props): JSX.Element => {
export const LayoutWithSidebar = ({ ...props }: ILayoutProps): JSX.Element => {
const { isRegistered } = useMaci();
const { address } = useAccount();
const { ballot } = useBallot();

const { showInfo, showBallot, showSubmitButton } = props;

return (
<Layout
sidebar="left"
sidebarComponent={
<div>
{props.showInfo && <Info showVotingInfo size="sm" />}
{showInfo && <Info showVotingInfo size="sm" />}

{props.showBallot && address && isRegistered && <BallotOverview />}
{showBallot && address && isRegistered && <BallotOverview />}

{props.showSubmitButton && ballot.votes.length > 0 && (
{showSubmitButton && ballot.votes.length > 0 && (
<div className="flex flex-col gap-4">
<SubmitBallotButton />

Expand Down
11 changes: 7 additions & 4 deletions src/pages/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@ import { JoinButton } from "~/components/JoinButton";
import { Button } from "~/components/ui/Button";
import { config } from "~/config";
import { useMaci } from "~/contexts/Maci";
import { FAQList } from "~/features/signup/components/FaqList";
import { Layout } from "~/layouts/DefaultLayout";

const SignupPage = (): JSX.Element => {
const { isConnected } = useAccount();
const { isRegistered } = useMaci();

return (
<Layout>
<Layout type="home">
<EligibilityDialog />

<div className="flex flex-col items-center justify-center gap-4">
<div className="flex h-[90vh] w-screen flex-col items-center justify-center gap-4 bg-blue-50">
<h1 className="max-w-screen-lg text-center font-mono">{config.eventName.toUpperCase()}</h1>

<h2 className="max-w-screen-lg text-center font-mono">{config.roundId.toUpperCase()}</h2>

<p className="flex max-w-screen-md gap-2 text-center text-xl">
<span>{format(config.startsAt, "d MMMM, yyyy")}</span>
<span>{config.startsAt && format(config.startsAt, "d MMMM, yyyy")}</span>

<span>-</span>

<span>{format(config.resultsAt, "d MMMM, yyyy")}</span>
<span>{config.resultsAt && format(config.resultsAt, "d MMMM, yyyy")}</span>
</p>

{isConnected && isRegistered && (
Expand All @@ -46,6 +47,8 @@ const SignupPage = (): JSX.Element => {
<Info size="default" />
</div>
</div>

<FAQList />
</Layout>
);
};
Expand Down

0 comments on commit 7b0a77d

Please sign in to comment.