From 02dc22d3ad6aeb0a8258633b44df582ac1f87d04 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Tue, 29 Oct 2024 02:53:54 +0100 Subject: [PATCH 1/7] InputFieldGroup: hide if all rows are invisible --- .../InputFields/InputFieldGroup.tsx | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/frontend/src/components/InputFields/InputFieldGroup.tsx b/frontend/src/components/InputFields/InputFieldGroup.tsx index b63c6f6..1218dfd 100644 --- a/frontend/src/components/InputFields/InputFieldGroup.tsx +++ b/frontend/src/components/InputFields/InputFieldGroup.tsx @@ -29,35 +29,36 @@ export const InputFieldGroup: FC = ({ fields, alignRight, expandHorizontally = true, -}) => ( -
- {fields.map((row, index) => - Array.isArray(row) ? ( - controls.visible), - name: `group-${index}`, - containerClassName: StringUtils.clsx( - alignRight ? classes.fieldRowRight : classes.fieldRow, - expandHorizontally ? classes.fieldRowExpand : classes.fieldRowCompact, - ), - expandHorizontally: expandHorizontally, - }} - padding={false} - > - {row.map(field => ( - - ))} - - ) : ( - } /> - ), - )} -
-) +}) => + fields.some(row => (Array.isArray(row) ? row.some(col => col.visible) : row.visible)) ? ( +
+ {fields.map((row, index) => + Array.isArray(row) ? ( + controls.visible), + name: `group-${index}`, + containerClassName: StringUtils.clsx( + alignRight ? classes.fieldRowRight : classes.fieldRow, + expandHorizontally ? classes.fieldRowExpand : classes.fieldRowCompact, + ), + expandHorizontally: expandHorizontally, + }} + padding={false} + > + {row.map(field => ( + + ))} + + ) : ( + } /> + ), + )} +
+ ) : undefined From 78e45c7eb0905c563dab853202d316d557ceaade Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Tue, 29 Oct 2024 02:54:42 +0100 Subject: [PATCH 2/7] Label: if value is "", consider it invisible --- frontend/src/components/InputFields/useLabel.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/components/InputFields/useLabel.ts b/frontend/src/components/InputFields/useLabel.ts index 4529c2e..b37a7fd 100644 --- a/frontend/src/components/InputFields/useLabel.ts +++ b/frontend/src/components/InputFields/useLabel.ts @@ -76,11 +76,13 @@ export function useLabel(props: LabelProps): ) const renderedContent = renderer(value, tagName) + const visible = controls.visible && controls.value !== '' return { ...controls, value, classnames: getAsArray(classnames), renderedContent, + visible, } } From 5d1b8982e996efd684aabdc70c3ffac9ff237a4a Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Tue, 29 Oct 2024 02:57:58 +0100 Subject: [PATCH 3/7] Vote page: don't show gasless status when lacking permission --- frontend/src/pages/PollPage/hook.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/pages/PollPage/hook.ts b/frontend/src/pages/PollPage/hook.ts index 100b8f4..7fbf487 100644 --- a/frontend/src/pages/PollPage/hook.ts +++ b/frontend/src/pages/PollPage/hook.ts @@ -161,6 +161,7 @@ export const usePollData = (pollId: string) => { const gaslessLabel = useLabel({ name: 'gaslessIndicator', value: gaslessPossible, + visible: getVerdict(permissions.canVote, false), renderer: showGaslessPossible, }) From c772a048e4e47d75bcd828372bae3a386b339f84 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Tue, 29 Oct 2024 02:58:35 +0100 Subject: [PATCH 4/7] Tweak how we display voting permission issues --- frontend/src/pages/PollPage/ActivePoll.tsx | 73 +++++++++----------- frontend/src/pages/PollPage/index.module.css | 9 +++ 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/frontend/src/pages/PollPage/ActivePoll.tsx b/frontend/src/pages/PollPage/ActivePoll.tsx index 9bf9397..a48a609 100644 --- a/frontend/src/pages/PollPage/ActivePoll.tsx +++ b/frontend/src/pages/PollPage/ActivePoll.tsx @@ -8,13 +8,14 @@ import { ConnectWallet } from '../../components/ConnectWallet' import { Card } from '../../components/Card' import { SocialShares } from '../../components/SocialShares' import { getVerdict, getReason, InputFieldGroup } from '../../components/InputFields' -import { WarningCircleIcon } from '../../components/icons/WarningCircleIcon' import { PollAccessIndicatorWrapper } from '../../components/PollCard/PollAccessIndicator' import { designDecisions, nativeTokenSymbol } from '../../constants/config' import { SpinnerIcon } from '../../components/icons/SpinnerIcon' import { AnimatePresence } from 'framer-motion' import { MotionDiv } from '../../components/Animations' import { MarkdownBlock } from '../../components/Markdown' +import { StringUtils } from '../../utils/string.utils' +import { MaybeWithTooltip } from '../../components/Tooltip/MaybeWithTooltip' export const ActivePoll: FC = ({ hasWallet, @@ -75,6 +76,7 @@ export const ActivePoll: FC = ({ const { canVote: canAclVote, explanation: aclExplanation } = permissions + const canVote = getVerdict(canAclVote, false) // console.log("selected:", selectedChoice, "can select?", canSelect, "can Vote?", canVote, "voting?", isVoting) return ( @@ -102,7 +104,12 @@ export const ActivePoll: FC = ({ exit={{ opacity: 0, height: 0 }} transition={{ duration: 0.5 }} key={`choice-${index}`} - className={`${classes.choice} ${classes.darkChoice} ${canSelect ? classes.activeChoice : ''} ${selectedChoice?.toString() === index.toString() ? classes.selectedChoice : ''}`} + className={StringUtils.clsx( + classes.choice, + classes.darkChoice, + canSelect ? classes.activeChoice : undefined, + selectedChoice?.toString() === index.toString() ? classes.selectedChoice : undefined, + )} onClick={() => handleSelect(index)} >
{choice}
@@ -116,49 +123,35 @@ export const ActivePoll: FC = ({ fields={[walletLabel, remainingTimeLabel, publishVotesLabel, publishVotersLabel, resultsLabel]} expandHorizontally={false} /> - {hasWallet && !getVerdict(canAclVote, false) ? ( + {hasWallet && !canVote ? ( - { - if (correctiveAction) { - console.log('Retrying') - correctiveAction() - } else { - console.log('no corrective action') - } - }} - > - {permissionsPending ? ( - - ) : ( - - )} - - - - + +
{ + if (correctiveAction) { + console.log('Retrying') + correctiveAction() + } else { + console.log('no corrective action') + } + }} + > + {permissionsPending && } + +
+
) : ( aclExplanation && ( - <> +
- {getVerdict(canAclVote, false) &&

You have access.

} - + {canVote &&

You have access.

} +
) )} Date: Tue, 29 Oct 2024 03:01:52 +0100 Subject: [PATCH 5/7] When can't vote, render choices differently --- frontend/src/pages/PollPage/ActivePoll.tsx | 2 +- frontend/src/pages/PollPage/index.module.css | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/PollPage/ActivePoll.tsx b/frontend/src/pages/PollPage/ActivePoll.tsx index a48a609..3095f93 100644 --- a/frontend/src/pages/PollPage/ActivePoll.tsx +++ b/frontend/src/pages/PollPage/ActivePoll.tsx @@ -107,7 +107,7 @@ export const ActivePoll: FC = ({ className={StringUtils.clsx( classes.choice, classes.darkChoice, - canSelect ? classes.activeChoice : undefined, + canSelect ? classes.activeChoice : classes.disabledChoice, selectedChoice?.toString() === index.toString() ? classes.selectedChoice : undefined, )} onClick={() => handleSelect(index)} diff --git a/frontend/src/pages/PollPage/index.module.css b/frontend/src/pages/PollPage/index.module.css index c34c259..0b15924 100644 --- a/frontend/src/pages/PollPage/index.module.css +++ b/frontend/src/pages/PollPage/index.module.css @@ -75,6 +75,11 @@ box-shadow: 0 7px 7px 0 rgba(0, 0, 0, 0.17); } +.disabledChoice { + cursor: not-allowed; + color: #abadb5; +} + .countdownContainer { display: flex; flex-direction: row; From c28bb6d79a965a84c0d2b6867fa56852c5961266 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Tue, 29 Oct 2024 03:19:33 +0100 Subject: [PATCH 6/7] Move layout variant CSS definitions to the right CSS module ... and reference them via import --- .../src/components/Layout/index.module.css | 23 +++++++++++++++++++ frontend/src/components/Layout/index.tsx | 8 +++---- frontend/src/index.css | 23 ------------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/frontend/src/components/Layout/index.module.css b/frontend/src/components/Layout/index.module.css index 965ec2a..f86db6c 100644 --- a/frontend/src/components/Layout/index.module.css +++ b/frontend/src/components/Layout/index.module.css @@ -1,3 +1,26 @@ +.dark-layout { + background: #130fff; + color: white; +} + +.light-layout { + background: white; + color: var(--navy-blue); +} + +.dashboard-layout { + background: linear-gradient(180deg, #e6e5ff 0%, #d2d1ff 100%); +} + +.landing-layout { + height: 100dvh; + background-image: url('background.svg'); + background-size: 2000px 2000px; + background-position: center center; + background-repeat: no-repeat; + color: var(--navy-blue); +} + .header { display: flex; justify-content: space-between; diff --git a/frontend/src/components/Layout/index.tsx b/frontend/src/components/Layout/index.tsx index 47ba5cf..c980254 100644 --- a/frontend/src/components/Layout/index.tsx +++ b/frontend/src/components/Layout/index.tsx @@ -13,10 +13,10 @@ import { Link, useLocation } from 'react-router-dom' type LayoutVariation = 'landing' | 'dashboard' | 'light' | 'dark' const layoutClasses: Partial> = { - landing: 'landing-layout', - dashboard: 'dashboard-layout', - dark: 'dark-layout', - light: 'light-layout', + landing: classes.landingLayout, + dashboard: classes.dashboardLayout, + dark: classes.darkLayout, + light: classes.lightLayout, } const logoColor: Record = { diff --git a/frontend/src/index.css b/frontend/src/index.css index ac42489..a14a2e5 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -81,29 +81,6 @@ h3 { } } -.landing-layout { - height: 100dvh; - background-image: url('background.svg'); - background-size: 2000px 2000px; - background-position: center center; - background-repeat: no-repeat; - color: var(--navy-blue); -} - -.dashboard-layout { - background: linear-gradient(180deg, #e6e5ff 0%, #d2d1ff 100%); -} - -.dark-layout { - background: #130fff; - color: white; -} - -.light-layout { - background: white; - color: var(--navy-blue); -} - .niceLine, .niceLineWide { display: flex; From 7dc7ee36dccb0c5903110c023b33ed4413f37829 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Tue, 29 Oct 2024 03:21:13 +0100 Subject: [PATCH 7/7] Tune layout of poll page on mobile --- frontend/src/components/Card/index.module.css | 4 ++++ frontend/src/components/LayoutBase/index.module.css | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Card/index.module.css b/frontend/src/components/Card/index.module.css index 38859ec..f61ce65 100644 --- a/frontend/src/components/Card/index.module.css +++ b/frontend/src/components/Card/index.module.css @@ -48,10 +48,14 @@ @media screen and (max-width: 1000px) { .card { + border-radius: 0; + border: none; position: unset; padding: 1.375rem; min-width: unset; max-width: unset; + width: 100%; + height: 2000px; margin-bottom: 1.25rem; } } diff --git a/frontend/src/components/LayoutBase/index.module.css b/frontend/src/components/LayoutBase/index.module.css index df3d6f0..7064f88 100644 --- a/frontend/src/components/LayoutBase/index.module.css +++ b/frontend/src/components/LayoutBase/index.module.css @@ -40,7 +40,15 @@ @media screen and (max-width: 1000px) { .layout { - padding: 0 1.5rem 0.25rem; + padding: 0; + } + + .main { + max-width: unset; + } + + header { + padding: 0 1rem } .footer {