Skip to content

Commit de98934

Browse files
committed
Design improvements
1 parent 497e3f4 commit de98934

File tree

16 files changed

+141
-274
lines changed

16 files changed

+141
-274
lines changed

src/components/ConnectButton.tsx

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Image from "next/image";
22
import Link from "next/link";
3-
import { type ComponentPropsWithRef } from "react";
3+
import { type PropsWithChildren, type ComponentPropsWithRef } from "react";
44
import { type Address, useEnsAvatar, useEnsName } from "wagmi";
55
import { FaListCheck } from "react-icons/fa6";
66

@@ -12,10 +12,11 @@ import { Chip } from "./ui/Chip";
1212
import { useBallot } from "~/features/ballot/hooks/useBallot";
1313
import { EligibilityDialog } from "./EligibilityDialog";
1414
import { useLayoutOptions } from "~/layouts/BaseLayout";
15+
import { useCurrentDomain } from "~/features/rounds/hooks/useRound";
1516

1617
const useBreakpoint = createBreakpoint({ XL: 1280, L: 768, S: 350 });
1718

18-
export const ConnectButton = () => {
19+
export const ConnectButton = ({ children }: PropsWithChildren) => {
1920
const breakpoint = useBreakpoint();
2021
const isMobile = breakpoint === "S";
2122

@@ -63,15 +64,18 @@ export const ConnectButton = () => {
6364
}
6465

6566
if (chain.unsupported) {
67+
return <Button onClick={openChainModal}>Change network</Button>;
6668
return <Chip onClick={openChainModal}>Wrong network</Chip>;
6769
}
6870

6971
return (
70-
<ConnectedDetails
71-
account={account}
72-
openAccountModal={openAccountModal}
73-
isMobile={isMobile}
74-
/>
72+
children ?? (
73+
<ConnectedDetails
74+
account={account}
75+
openAccountModal={openAccountModal}
76+
isMobile={isMobile}
77+
/>
78+
)
7579
);
7680
})()}
7781
</div>
@@ -92,17 +96,17 @@ const ConnectedDetails = ({
9296
}) => {
9397
const { data: ballot } = useBallot();
9498
const ballotSize = (ballot?.votes ?? []).length;
95-
99+
const domain = useCurrentDomain();
96100
const { eligibilityCheck, showBallot } = useLayoutOptions();
97101
return (
98102
<div>
99-
<div className="flex gap-2 text-white">
103+
<div className="flex gap-2">
100104
{!showBallot ? null : ballot?.publishedAt ? (
101105
<Chip>Already submitted</Chip>
102106
) : (
103-
<Chip className="gap-2" as={Link} href={"/ballot"}>
107+
<Chip className="gap-2" as={Link} href={`/${domain}/ballot`}>
104108
{isMobile ? <FaListCheck className="h-4 w-4" /> : `View Ballot`}
105-
<div className="flex h-6 w-6 items-center justify-center rounded-full bg-gray-800 text-xs">
109+
<div className="flex size-6 items-center justify-center rounded-full bg-gray-200 text-xs font-bold">
106110
{ballotSize}
107111
</div>
108112
</Chip>
@@ -134,7 +138,7 @@ const UserInfo = ({
134138
{avatar.data ? (
135139
<Image width={24} height={24} alt={name!} src={avatar.data} />
136140
) : (
137-
<div className="h-full bg-gray-200" />
141+
<div className="h-full bg-gray-700" />
138142
)}
139143
</div>
140144
{children}

src/components/Header.tsx

+10-13
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { Menu, X } from "lucide-react";
1010
import dynamic from "next/dynamic";
1111

1212
const Logo = () => (
13-
<div className="h-12">
14-
<div className="flex h-full items-center justify-center rounded-full border-2 border-white px-4 text-base font-medium tracking-wider text-white hover:bg-gray-700">
13+
<div className="">
14+
<div className="flex h-full items-center justify-center rounded-full border-2 border-white bg-gray-800 px-4 py-2 text-base font-medium tracking-wider text-white hover:bg-gray-700">
1515
{metadata.title}
1616
</div>
1717
</div>
@@ -23,9 +23,9 @@ const NavLink = ({
2323
}: { isActive: boolean } & ComponentPropsWithRef<typeof Link>) => (
2424
<Link
2525
className={clsx(
26-
"flex h-full items-center border-b-[3px] border-transparent p-4 text-lg font-semibold tracking-wider text-gray-300 hover:text-white",
26+
"hover:bg-primary-100 hover:text-primary-800 flex items-center rounded-full border-b-[3px] border-transparent px-6 py-2 font-semibold text-gray-600 transition-colors",
2727
{
28-
["!border-white !text-white"]: isActive,
28+
["bg-primary-100 !border-white text-primary-700"]: isActive,
2929
},
3030
)}
3131
{...props}
@@ -38,9 +38,9 @@ export const Header = ({ navLinks }: { navLinks: NavLink[] }) => {
3838
const [isOpen, setOpen] = useState(false);
3939

4040
return (
41-
<header className="relative z-[100] bg-gray-900 shadow-md dark:shadow-none">
42-
<div className="container mx-auto flex h-[72px] max-w-screen-2xl items-center px-2">
43-
<div className="mr-4 flex items-center md:mr-16">
41+
<header className="relative z-[100]">
42+
<div className="container mx-auto flex h-[72px] max-w-screen-2xl items-center justify-between px-2">
43+
<div className="flex items-center">
4444
<IconButton
4545
icon={isOpen ? X : Menu}
4646
variant="ghost"
@@ -51,7 +51,7 @@ export const Header = ({ navLinks }: { navLinks: NavLink[] }) => {
5151
<Logo />
5252
</Link>
5353
</div>
54-
<div className="hidden h-full items-center gap-4 overflow-x-auto md:flex">
54+
<div className="hidden h-full items-center gap-2 overflow-x-auto md:flex">
5555
{navLinks?.map((link) => (
5656
<NavLink
5757
isActive={asPath.startsWith(link.href)}
@@ -62,10 +62,7 @@ export const Header = ({ navLinks }: { navLinks: NavLink[] }) => {
6262
</NavLink>
6363
))}
6464
</div>
65-
<div className="flex-1 md:ml-8"></div>
66-
<div className="ml-4 flex gap-4 md:ml-8 xl:ml-32">
67-
<ConnectButton />
68-
</div>
65+
<ConnectButton />
6966
<MobileMenu isOpen={isOpen} navLinks={navLinks} />
7067
</div>
7168
</header>
@@ -89,7 +86,7 @@ const MobileMenu = ({
8986
>
9087
{navLinks.map((link) => (
9188
<Link
92-
className={clsx("block p-4 text-2xl font-semibold")}
89+
className={clsx("block p-4 text-2xl font-semibold")}
9390
key={link.href}
9491
{...link}
9592
/>

src/components/ui/Button.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const button = tv({
2424
},
2525
size: {
2626
sm: "px-3 py-2 h-10 min-w-[40px]",
27-
deafult: "px-4 py-2 h-12",
27+
md: "px-6 py-2 h-12",
28+
lg: "px-6 py-3 text-lg",
2829
icon: "h-12 w-12",
2930
},
3031
disabled: {
@@ -33,7 +34,7 @@ const button = tv({
3334
},
3435
defaultVariants: {
3536
variant: "default",
36-
size: "deafult",
37+
size: "md",
3738
},
3839
});
3940

src/components/ui/Chip.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { tv } from "tailwind-variants";
22
import { createComponent } from ".";
33

44
const chip = tv({
5-
base: "border border-gray-700 rounded-full min-w-[42px] px-2 md:px-3 py-2 cursor-pointer inline-flex justify-center items-center whitespace-nowrap text-neutral-200 hover:text-neutral-100",
5+
base: "border border-gray-700 rounded-full min-w-[42px] px-2 md:px-3 py-2 cursor-pointer inline-flex justify-center items-center whitespace-nowrap text-gray-600 hover:text-gray-800",
66
variants: {},
77
});
88

src/features/applications/components/ApplicationForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function CreateApplicationButton({
317317
{!session && <div>You must connect wallet to create a list</div>}
318318
{!isCorrectNetwork && (
319319
<div className="flex items-center gap-2">
320-
You must be connected to {correctNetwork.name}
320+
You must be connected to {correctNetwork?.name}
321321
</div>
322322
)}
323323
</div>

src/features/applications/components/ApplicationsToApprove.tsx

+2-11
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@ import { useFormContext } from "react-hook-form";
55

66
import { Button } from "~/components/ui/Button";
77
import { Checkbox, Form, FormSection } from "~/components/ui/Form";
8-
import { Markdown } from "~/components/ui/Markdown";
98
import { useMetadata } from "~/hooks/useMetadata";
109
import { useApplications } from "~/features/applications/hooks/useApplications";
1110
import { ProjectAvatar } from "~/features/projects/components/ProjectAvatar";
1211
import { type Application } from "~/features/applications/types";
1312
import { type Attestation } from "~/utils/fetchAttestations";
1413
import { Badge } from "~/components/ui/Badge";
1514
import { useApproveApplication } from "../hooks/useApproveApplication";
16-
import { useIsAdmin } from "~/hooks/useIsAdmin";
1715
import { Skeleton } from "~/components/ui/Skeleton";
1816
import { Spinner } from "~/components/ui/Spinner";
1917
import { EmptyState } from "~/components/EmptyState";
2018
import { formatDate } from "~/utils/time";
2119
import { ClockIcon } from "lucide-react";
22-
import { useIsCorrectNetwork } from "~/hooks/useIsCorrectNetwork";
2320
import { useApprovedApplications } from "../hooks/useApprovedApplications";
2421
import { Alert } from "~/components/ui/Alert";
2522

@@ -186,24 +183,18 @@ function SelectAllButton({
186183
}
187184

188185
function ApproveButton({ isLoading = false }) {
189-
const isAdmin = useIsAdmin();
190-
const { isCorrectNetwork, correctNetwork } = useIsCorrectNetwork();
191186
const form = useFormContext<ApplicationsToApprove>();
192187
const selectedCount = Object.values(form.watch("selected") ?? {}).filter(
193188
Boolean,
194189
).length;
195190
return (
196191
<Button
197192
suppressHydrationWarning
198-
disabled={!selectedCount || !isAdmin || isLoading || !isCorrectNetwork}
193+
disabled={!selectedCount || isLoading}
199194
variant="primary"
200195
type="submit"
201196
>
202-
{!isCorrectNetwork
203-
? `Connect to ${correctNetwork.name}`
204-
: isAdmin
205-
? `Approve ${selectedCount} applications`
206-
: "You must be an admin"}
197+
Approve {selectedCount} applications
207198
</Button>
208199
);
209200
}

src/features/applications/components/ApproveButton.tsx

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Button } from "~/components/ui/Button";
22
import { useApproveApplication } from "~/features/applications/hooks/useApproveApplication";
3-
import { useIsAdmin } from "~/hooks/useIsAdmin";
43
import dynamic from "next/dynamic";
54
import { type PropsWithChildren } from "react";
65
import { useApprovedApplications } from "../hooks/useApprovedApplications";
@@ -10,7 +9,6 @@ function ApproveButton({
109
children = "Approve project",
1110
projectIds = [],
1211
}: PropsWithChildren<{ projectIds: string[] }>) {
13-
const isAdmin = useIsAdmin();
1412
const approvals = useApprovedApplications(projectIds);
1513

1614
const approve = useApproveApplication();
@@ -21,15 +19,13 @@ function ApproveButton({
2119
</Badge>
2220
);
2321
return (
24-
isAdmin && (
25-
<Button
26-
variant="primary"
27-
disabled={approve.isLoading}
28-
onClick={() => approve.mutate(projectIds)}
29-
>
30-
{children}
31-
</Button>
32-
)
22+
<Button
23+
variant="primary"
24+
disabled={approve.isLoading}
25+
onClick={() => approve.mutate(projectIds)}
26+
>
27+
{children}
28+
</Button>
3329
);
3430
}
3531

src/features/ballot/components/BallotOverview.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,32 @@ import { formatNumber } from "~/utils/formatNumber";
1515
import { Dialog } from "~/components/ui/Dialog";
1616
import { VotingEndsIn } from "./VotingEndsIn";
1717
import { useProjectCount } from "~/features/projects/hooks/useProjects";
18-
import { config } from "~/config";
1918
import { useIsMutating } from "@tanstack/react-query";
2019
import { getQueryKey } from "@trpc/react-query";
2120
import { api } from "~/utils/api";
2221
import { getAppState } from "~/utils/state";
2322
import dynamic from "next/dynamic";
23+
import { useRoundToken } from "~/features/distribute/hooks/useAlloPool";
24+
import { useCurrentRound } from "~/features/rounds/hooks/useRound";
2425

2526
function BallotOverview() {
2627
const router = useRouter();
2728

2829
const { data: ballot } = useBallot();
2930
const isSaving = useIsMutating(getQueryKey(api.ballot.save));
3031

32+
const round = useCurrentRound();
33+
const token = useRoundToken();
3134
const sum = sumBallot(ballot?.votes);
3235

3336
const allocations = ballot?.votes ?? [];
34-
const canSubmit = router.route === "/ballot" && allocations.length;
37+
const canSubmit = router.route.includes("ballot") && allocations.length;
3538

3639
const { data: projectCount } = useProjectCount();
3740

41+
const tokenName = token.data?.symbol;
42+
const maxVotesTotal = round.data?.maxVotesTotal ?? 0;
43+
3844
const appState = getAppState();
3945
if (appState === "RESULTS")
4046
return (
@@ -84,22 +90,22 @@ function BallotOverview() {
8490
<BallotSection
8591
title={
8692
<div className="flex justify-between">
87-
{config.tokenName} allocated:
93+
{tokenName} allocated:
8894
<div
8995
className={clsx("text-gray-900 dark:text-gray-300", {
90-
["text-primary-500"]: sum > config.votingMaxTotal,
96+
["text-primary-500"]: sum > maxVotesTotal,
9197
})}
9298
>
93-
{formatNumber(sum)} {config.tokenName}
99+
{formatNumber(sum)} {tokenName}
94100
</div>
95101
</div>
96102
}
97103
>
98-
<Progress value={sum} max={config.votingMaxTotal} />
104+
<Progress value={sum} max={maxVotesTotal} />
99105
<div className="flex justify-between text-xs">
100106
<div>Total</div>
101107
<div>
102-
{formatNumber(config.votingMaxTotal ?? 0)} {config.tokenName}
108+
{formatNumber(maxVotesTotal ?? 0)} {tokenName}
103109
</div>
104110
</div>
105111
</BallotSection>
@@ -112,7 +118,7 @@ function BallotOverview() {
112118
Adding to ballot...
113119
</Button>
114120
) : canSubmit ? (
115-
<SubmitBallotButton disabled={sum > config.votingMaxTotal} />
121+
<SubmitBallotButton disabled={sum > maxVotesTotal} />
116122
) : allocations.length ? (
117123
<Button className="w-full" variant="primary" as={Link} href={"/ballot"}>
118124
View ballot

0 commit comments

Comments
 (0)