Skip to content

Commit

Permalink
Merge pull request #79 from aragon/f/responsive-check
Browse files Browse the repository at this point in the history
Responsive fixes
  • Loading branch information
carlosgj94 authored Mar 3, 2024
2 parents 1f96191 + 5074bbc commit 85f282e
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 42 deletions.
4 changes: 2 additions & 2 deletions components/alert/alert-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const AlertContainer: FC = () => {
const { alerts } = useAlertContext();

return (
<div className="fixed bottom-0 right-0 w-96 m-10">
<div className="fixed top-0 right-0 w-72 md:w-96 m-4 z-50">
{alerts.map((alert: IAlert) => (
<AlertCard
className="mt-4 drop-shadow-lg"
className="drop-shadow-lg mb-4"
key={alert.id}
message={alert.message}
description={resolveDescription(alert)}
Expand Down
26 changes: 18 additions & 8 deletions context/AlertContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,26 @@ export const AlertProvider: React.FC<{ children: React.ReactNode }> = ({

// Add a new alert to the list
const addAlert = (message: string, alertOptions?: AlertOptions) => {
const newAlertList = ([] as IAlert[]).concat(alerts);

// Clean duplicates
const idx = alerts.findIndex((a) => {
if (a.message !== message) return false;
else if (a.description !== alertOptions?.description) return false;
else if (a.type !== alertOptions?.type) return false;

return true;
});
if (idx >= 0) removeAlert(idx);
if (idx >= 0) {
const [prevAlert] = newAlertList.splice(idx, 1);
clearTimeout(prevAlert.dismissTimeout);
const timeout = alertOptions?.timeout ?? DEFAULT_ALERT_TIMEOUT;
prevAlert.dismissTimeout = setTimeout(
() => removeAlert(prevAlert.id),
timeout
);
setAlerts(newAlertList.concat(prevAlert));
return;
}

const newAlert: IAlert = {
id: Date.now(),
Expand All @@ -48,13 +59,12 @@ export const AlertProvider: React.FC<{ children: React.ReactNode }> = ({
newAlert.explorerLink =
client.chain.blockExplorers?.default.url + "/tx/" + alertOptions.txHash;
}
setAlerts(alerts.concat(newAlert));

// Schedule the clean-up
const timeout = alertOptions?.timeout ?? DEFAULT_ALERT_TIMEOUT;
setTimeout(() => {
removeAlert(newAlert.id);
}, timeout);
newAlert.dismissTimeout = setTimeout(
() => removeAlert(newAlert.id),
timeout
);
setAlerts(newAlertList.concat(newAlert));
};

// Function to remove an alert
Expand Down
10 changes: 4 additions & 6 deletions plugins/dualGovernance/components/proposal/description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ export default function ProposalDescription(proposal: Proposal) {
<h2 className="flex-grow text-2xl text-neutral-900 font-semibold pt-10 pb-3">
Actions
</h2>
<div className="grid gap-3">
<div className="">
<If not={proposal.actions.length}>
<p className="pt-2">The proposal has no actions</p>
</If>
{proposal.actions?.map?.((action, i) => (
<ActionCard
key={`${i}-${action.to}-${action.data}`}
action={action}
idx={i}
/>
<div className="mb-3" key={`${i}-${action.to}-${action.data}`}>
<ActionCard action={action} idx={i} />
</div>
))}
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions plugins/dualGovernance/components/vote/vetoes-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Blockies from "react-blockies";
import { VetoCastEvent } from "@/plugins/dualGovernance/utils/types";
import { formatUnits } from "viem";
import { AddressText } from "@/components/text/address";
import { Card, Tag } from "@aragon/ods";
import { Card } from "@aragon/ods";
import { compactNumber } from "@/utils/numbers";
import { If } from "@/components/if";

Expand Down Expand Up @@ -40,7 +40,6 @@ const VetoCard = function ({ veto }: { veto: VetoCastEvent }) {
</p>
</div>
</div>
<Tag className="!text-sm" variant="critical" label="Veto" />
</div>
</Card>
);
Expand Down
16 changes: 7 additions & 9 deletions plugins/dualGovernance/pages/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default function Create() {
className="pt-2"
value={summary}
onChange={setSummary}
placeholder="A detailed description for what the proposal is all about"
placeholder="A description for what the proposal is all about"
/>
</div>
<div className="mb-6">
Expand Down Expand Up @@ -291,16 +291,14 @@ export default function Create() {
<p className="flex-grow text-lg text-neutral-900 font-semibold pb-3">
Actions
</p>
<div className="grid gap-3 mb-10">
<If not={actions.length}>
<p className="pt-2">The proposal has no actions</p>
</If>
<div className="mb-10">
{actions?.map?.((action, i) => (
<ActionCard
<div
className="mb-3"
key={`${i}-${action.to}-${action.data}`}
action={action}
idx={i}
/>
>
<ActionCard action={action} idx={i} />
</div>
))}
</div>
</Else>
Expand Down
1 change: 1 addition & 0 deletions plugins/dualGovernance/pages/proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function ProposalDetail({ id: proposalId }: { id: string }) {
{bottomSection === "description" ? "Description" : "Vetoes"}
</h2>
<ToggleGroup
className="justify-end"
value={bottomSection}
isMultiSelect={false}
onChange={(val: string | undefined) =>
Expand Down
10 changes: 4 additions & 6 deletions plugins/tokenVoting/components/proposal/description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ export default function ProposalDescription(proposal: Proposal) {
<h2 className="flex-grow text-2xl text-neutral-900 font-semibold pt-10 pb-3">
Actions
</h2>
<div className="grid gap-3">
<div className="">
<If not={proposal.actions.length}>
<p className="pt-2">The proposal has no actions</p>
</If>
{proposal.actions?.map?.((action, i) => (
<ActionCard
key={`${i}-${action.to}-${action.data}`}
action={action}
idx={i}
/>
<div className="mb-3" key={`${i}-${action.to}-${action.data}`}>
<ActionCard action={action} idx={i} />
</div>
))}
</div>
</div>
Expand Down
16 changes: 7 additions & 9 deletions plugins/tokenVoting/pages/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default function Create() {
className="pt-2"
value={summary}
onChange={setSummary}
placeholder="A detailed description for what the proposal is all about"
placeholder="A description for what the proposal is all about"
/>
</div>
<div className="mb-6">
Expand Down Expand Up @@ -290,16 +290,14 @@ export default function Create() {
<p className="flex-grow text-lg text-neutral-900 font-semibold pb-3">
Actions
</p>
<div className="grid gap-3 mb-10">
<If not={actions.length}>
<p className="pt-2">The proposal has no actions</p>
</If>
<div className="mb-10">
{actions?.map?.((action, i) => (
<ActionCard
<div
className="mb-3"
key={`${i}-${action.to}-${action.data}`}
action={action}
idx={i}
/>
>
<ActionCard action={action} idx={i} />
</div>
))}
</div>
</Else>
Expand Down
1 change: 1 addition & 0 deletions plugins/tokenVoting/pages/proposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export default function ProposalDetail({ id: proposalId }: { id: string }) {
{bottomSection === "description" ? "Description" : "Votes"}
</h2>
<ToggleGroup
className="justify-end"
value={bottomSection}
isMultiSelect={false}
onChange={(val: string | undefined) =>
Expand Down
1 change: 1 addition & 0 deletions utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface IAlert {
message: string;
description?: string;
explorerLink?: string;
dismissTimeout?: ReturnType<typeof setTimeout>;
}

0 comments on commit 85f282e

Please sign in to comment.