Skip to content

Commit 024ca5f

Browse files
authored
feat: general ui fixes (#61)
1 parent e1286e5 commit 024ca5f

File tree

9 files changed

+105
-47
lines changed

9 files changed

+105
-47
lines changed

components/WalletContainer.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ const WalletContainer = () => {
3838
query: { enabled: !!ensName },
3939
});
4040

41+
if (!isConnected) {
42+
return (
43+
<button
44+
className="cursor:pointer flex h-[48px] min-w-[112px] flex-row items-center justify-center gap-1 rounded-xl border border-primary-400 bg-primary-400 text-base font-semibold leading-tight text-neutral-0 outline-none transition-all hover:border-primary-500 hover:bg-primary-500 hover:shadow-primary-md focus:outline-none focus-visible:ring focus-visible:ring-primary focus-visible:ring-offset active:border-primary-800 active:bg-primary-800 aria-disabled:border-primary-100 aria-disabled:bg-primary-100 aria-disabled:text-primary-300"
45+
onClick={() => open()}
46+
>
47+
Connect
48+
</button>
49+
);
50+
}
51+
4152
return (
4253
<button
4354
className={classNames(
@@ -55,7 +66,7 @@ const WalletContainer = () => {
5566
</div>
5667
)}
5768

58-
{!isConnected && <span>Connect</span>}
69+
{!isConnected && <button>Connect</button>}
5970
</button>
6071
);
6172
};

components/nav/navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const Navbar: React.FC = () => {
2828
<Link
2929
href="/"
3030
className={classNames(
31-
"flex items-center gap-x-3 rounded-full md:rounded-lg",
31+
"flex cursor-pointer items-center gap-x-3 rounded-full md:rounded-lg",
3232
"outline-none focus:outline-none focus-visible:ring focus-visible:ring-primary focus-visible:ring-offset" // focus styles
3333
)}
3434
>

components/proposalAction/proposalAction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const ActionItem = ({ index, rawAction }: { index: number; rawAction: RawAction
8686
</Link>
8787
</div>
8888
</div>
89-
<span className="hidden text-sm leading-tight text-neutral-500 sm:block md:text-base">{title}</span>
89+
<span className="hidden text-sm leading-tight text-neutral-500 md:text-base">{title}</span>
9090
</div>
9191
</AccordionItemHeader>
9292

plugins/maciVoting/components/VoteResultCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const VoteResultCard = ({ results }: VoteResultCardProps) => {
100100
</div>
101101
</div>
102102

103-
<div className="grid grid-cols-3 gap-2">
103+
<div className="grid grid-cols-1 gap-2 lg:grid-cols-3">
104104
<div className={`p-4 text-center ${bgClass("yes")} rounded-xl border`}>
105105
<CheckCircle className={classNames(`mx-auto h-5 w-5`, textClass("yes"))} />
106106
<div

plugins/maciVoting/components/proposal/header.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { type ReactNode } from "react";
1616
import { Publisher } from "@/components/publisher";
1717
import { getSimpleRelativeTimeFromDate } from "@/utils/dates";
1818
import { unixTimestampToDate } from "../../utils/formatPollDate";
19+
import Link from "next/link";
1920

2021
interface ProposalHeaderProps {
2122
proposalNumber: number;
@@ -36,6 +37,15 @@ const ProposalHeader: React.FC<ProposalHeaderProps> = ({ proposal, proposalMetad
3637
<div className="flex w-full justify-center bg-neutral-0">
3738
{/* Wrapper */}
3839
<MainSection className="flex flex-col gap-y-6 md:px-16 md:py-10">
40+
<Link className="mr-auto flex cursor-pointer items-center gap-2" href="/plugins/maci-voting">
41+
<svg width="20" height="21" viewBox="0 0 20 21" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
42+
<path
43+
d="M6.52268 9.78578L10.9927 5.31578L9.81435 4.13745L3.33268 10.6191L9.81435 17.1008L10.9927 15.9225L6.52268 11.4525H16.666V9.78578H6.52268Z"
44+
fill="currentColor"
45+
/>
46+
</svg>
47+
<span className="text-base">Back</span>
48+
</Link>
3949
{/* Title & description */}
4050
<div className="flex w-full flex-col gap-y-2">
4151
<div className="flex w-full items-center gap-x-4">

plugins/maciVoting/components/proposal/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ export default function ProposalCard(props: ProposalInputs) {
5151
const winningOption = getWinningOption(proposal?.tally as Tally);
5252

5353
if (!proposal && showLoading) {
54-
return (
55-
<section className="mb-4 w-full">
56-
<Card className="p-4">
57-
<span className="xs:px-10 px-4 py-5 md:px-6 lg:px-7">
58-
<PleaseWaitSpinner fullMessage="Loading proposal..." />
59-
</span>
60-
</Card>
61-
</section>
62-
);
54+
return <Card className="mb-4 min-h-[120px] animate-pulse bg-slate p-4" />;
6355
} else if (!proposalMetadata?.title && !proposalMetadata?.summary) {
6456
// We have the proposal but no metadata yet
6557
return (

plugins/maciVoting/pages/new.tsx

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { NEXT_MINIMUM_START_DELAY_IN_SECONDS, PUBLIC_CHAIN, PUBLIC_MACI_VOTING_P
1515
import { ActionCard } from "@/components/actions/action";
1616
import { useMutation } from "@tanstack/react-query";
1717
import classNames from "classnames";
18+
import Link from "next/link";
1819

1920
enum ActionType {
2021
Signaling,
@@ -38,6 +39,15 @@ export default function Create() {
3839
const { writeContract: createProposalWrite, data: createTxHash, status, error } = useWriteContract();
3940
const { isLoading: isConfirming, isSuccess: isConfirmed } = useWaitForTransactionReceipt({ hash: createTxHash });
4041
const [actionType, setActionType] = useState<ActionType>(ActionType.Signaling);
42+
const [errors, setErrors] = useState<{
43+
title?: string;
44+
summary?: string;
45+
description?: string;
46+
startDate?: string;
47+
endDate?: string;
48+
withdrawal?: string;
49+
custom?: string;
50+
}>({});
4151

4252
const changeActionType = (actionType: ActionType) => {
4353
setActions([]);
@@ -82,20 +92,21 @@ export default function Create() {
8292
}, [status, createTxHash, isConfirming, isConfirmed, error, push]);
8393

8494
const submitProposal = async () => {
95+
let formErrors = {};
8596
try {
8697
// Check metadata
8798
if (!title.trim()) {
88-
return addAlert("Invalid proposal details", {
89-
description: "Please, enter a title",
90-
type: "error",
91-
});
99+
formErrors = {
100+
...formErrors,
101+
title: "Please, enter a title",
102+
};
92103
}
93104

94105
if (!summary.trim()) {
95-
return addAlert("Invalid proposal details", {
96-
description: "Please, enter a summary of what the proposal is about",
97-
type: "error",
98-
});
106+
formErrors = {
107+
...formErrors,
108+
summary: "Please, enter a summary of what the proposal is about",
109+
};
99110
}
100111

101112
// Check the action
@@ -104,18 +115,18 @@ export default function Create() {
104115
break;
105116
case ActionType.Withdrawal:
106117
if (!actions.length) {
107-
return addAlert("Invalid proposal details", {
108-
description: "Please ensure that the withdrawal address and the amount to transfer are valid",
109-
type: "error",
110-
});
118+
formErrors = {
119+
...formErrors,
120+
withdrawal: "Please ensure that the withdrawal address and the amount to transfer are valid",
121+
};
111122
}
112123
break;
113124
default:
114125
if (!actions.length || !actions[0].data || actions[0].data === "0x") {
115-
return addAlert("Invalid proposal details", {
116-
description: "Please ensure that the values of the action to execute are complete and correct",
117-
type: "error",
118-
});
126+
formErrors = {
127+
...formErrors,
128+
custom: "Please ensure that the values of the action to execute are complete and correct",
129+
};
119130
}
120131
}
121132

@@ -132,21 +143,20 @@ export default function Create() {
132143
const ipfsPin = await uploadToPinata(blob);
133144

134145
if (!startDate || !endDate) {
135-
addAlert("You need to specify the start date and end date of the voting period", {
136-
timeout: 4 * 1000,
137-
});
138-
return null;
146+
formErrors = {
147+
...formErrors,
148+
startDate: "You need to specify the start date and end date of the voting period",
149+
};
139150
}
140151

141152
const currentTime = Math.floor(Date.now() / 1000);
142153
const startDateTime = Math.floor(new Date(`${startDate}T${startTime ? startTime : "00:00:00"}`).getTime() / 1000);
143154

144155
if (startDateTime - currentTime < NEXT_MINIMUM_START_DELAY_IN_SECONDS) {
145-
addAlert(`The start date must be at least ${NEXT_MINIMUM_START_DELAY_IN_SECONDS} seconds in the future`, {
146-
timeout: 4 * 1000,
147-
type: "error",
148-
});
149-
return null;
156+
formErrors = {
157+
...formErrors,
158+
startDate: `The start date must be at least ${NEXT_MINIMUM_START_DELAY_IN_SECONDS} seconds in the future`,
159+
};
150160
}
151161

152162
const endDateTime = Math.floor(new Date(`${endDate}T${endTime ? endTime : "00:00:00"}`).getTime() / 1000);
@@ -160,6 +170,11 @@ export default function Create() {
160170
tryEarlyExecution,
161171
]);
162172

173+
if (Object.keys(formErrors).length > 0) {
174+
setErrors(formErrors);
175+
return;
176+
}
177+
163178
if (chainId !== PUBLIC_CHAIN.id) await switchChainAsync({ chainId: PUBLIC_CHAIN.id });
164179
createProposalWrite({
165180
chainId: PUBLIC_CHAIN.id,
@@ -199,11 +214,20 @@ export default function Create() {
199214
const isDisabled = submitProposalMutation.isPending || isConfirming;
200215
return (
201216
<section className="container flex w-screen flex-col items-center pt-4 lg:pt-10">
217+
<Link className="mb-6 mr-auto flex cursor-pointer items-center gap-2" href="/plugins/maci-voting">
218+
<svg width="20" height="21" viewBox="0 0 20 21" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
219+
<path
220+
d="M6.52268 9.78578L10.9927 5.31578L9.81435 4.13745L3.33268 10.6191L9.81435 17.1008L10.9927 15.9225L6.52268 11.4525H16.666V9.78578H6.52268Z"
221+
fill="currentColor"
222+
/>
223+
</svg>
224+
<span className="text-base">Back</span>
225+
</Link>
202226
<div className="mb-6 w-full content-center justify-between">
203227
<h1 className="mb-10 text-3xl font-semibold text-neutral-900">Create Proposal</h1>
204228
<div className="mb-6">
205229
<InputText
206-
label="Title"
230+
label="Title *"
207231
wrapperClassName={inputWrapperClassName}
208232
maxLength={100}
209233
placeholder="A short title that describes the main purpose"
@@ -216,7 +240,7 @@ export default function Create() {
216240
<div className="mb-6">
217241
<InputText
218242
wrapperClassName={inputWrapperClassName}
219-
label="Summary"
243+
label="Summary *"
220244
maxLength={240}
221245
placeholder="A short summary that describes the main purpose"
222246
variant="default"
@@ -227,7 +251,7 @@ export default function Create() {
227251
</div>
228252
<div className="mb-6">
229253
<TextAreaRichText
230-
label="Description"
254+
label="Description *"
231255
wrapperClassName={inputWrapperClassName}
232256
className="pt-2"
233257
value={description}
@@ -241,7 +265,7 @@ export default function Create() {
241265
<InputDate
242266
wrapperClassName={inputWrapperClassName}
243267
className="w-full"
244-
label="Start date"
268+
label="Start date *"
245269
variant="default"
246270
value={startDate}
247271
onChange={(e) => setStartDate(e.target.value)}
@@ -260,7 +284,7 @@ export default function Create() {
260284
<InputDate
261285
wrapperClassName={inputWrapperClassName}
262286
className="w-full"
263-
label="End date"
287+
label="End date *"
264288
variant="default"
265289
value={endDate}
266290
onChange={(e) => setEndDate(e.target.value)}
@@ -341,6 +365,14 @@ export default function Create() {
341365
</div>
342366
</div>
343367

368+
<div className="flex flex-col gap-2">
369+
{Object.entries(errors).map(([key, value]) => (
370+
<div key={key} className="text-danger">
371+
{value}
372+
</div>
373+
))}
374+
</div>
375+
344376
<If condition={showLoading}>
345377
<Then>
346378
<div className="mb-6 mt-14">

plugins/maciVoting/pages/proposal.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,20 @@ export default function ProposalDetail({ id: proposalId }: { id: string }) {
2323

2424
if (!proposal || !proposalMetadata || !creator || showProposalLoading) {
2525
return (
26-
<section className="justify-left items-left flex w-screen min-w-full max-w-full">
27-
<PleaseWaitSpinner />
28-
</section>
26+
<div className="flex w-full flex-col gap-10">
27+
<div className="h-[250px] w-full bg-slate"></div>
28+
<div className="mx-auto grid w-full max-w-screen-xl grid-cols-3 gap-12">
29+
<div className="col-span-2 flex flex-col gap-6">
30+
<div className="h-[200px] w-full rounded-xl bg-slate"></div>
31+
<div className="h-[200px] w-full rounded-xl bg-slate"></div>
32+
<div className="h-[200px] w-full rounded-xl bg-slate"></div>
33+
</div>
34+
<div className="flex flex-col gap-6">
35+
<div className="aspect-video w-full rounded-xl bg-slate"></div>
36+
<div className="h-[140px] w-full rounded-xl bg-slate"></div>
37+
</div>
38+
</div>
39+
</div>
2940
);
3041
}
3142

@@ -41,7 +52,7 @@ export default function ProposalDetail({ id: proposalId }: { id: string }) {
4152
/>
4253

4354
<div className="mx-auto w-full max-w-screen-xl px-4 py-6 md:px-16 md:pb-20 md:pt-10">
44-
<div className="flex w-full flex-col gap-x-12 gap-y-6 md:flex-row">
55+
<div className="mg:gap-y-6 flex w-full flex-col gap-6 md:flex-row md:gap-x-12">
4556
<div className="flex flex-col gap-y-6 md:w-[63%] md:shrink-0">
4657
<BodySection body={proposalMetadata?.description || "No description was provided"} />
4758
<If condition={canFinalize && finalizeStatus !== "submitted"}>

tailwind.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const config: Config = {
1111
theme: {
1212
extend: {
1313
colors: {
14+
slate: "#CBD5E1",
15+
danger: "#e7000b",
1416
voting: {
1517
yes: "#10b981",
1618
no: "#dc2626",

0 commit comments

Comments
 (0)