From a1c1d47a0e4636ca6ee114d29d95a65d7eba4d79 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Guhur Date: Sun, 6 Nov 2022 17:09:55 +0100 Subject: [PATCH] fix: clean up responsive --- components/Button.tsx | 11 +- components/CopyField.tsx | 4 +- components/CreationSteps.tsx | 64 +++++--- components/DatePicker.tsx | 39 ++--- components/Error.tsx | 2 +- components/ListInput.tsx | 6 +- components/Switch.tsx | 4 +- components/admin/AccessResults.tsx | 27 ++-- components/admin/ButtonWithConfirm.tsx | 6 +- components/admin/CandidateField.tsx | 13 +- components/admin/CandidateModalDel.tsx | 36 ++--- components/admin/CandidateModalSet.tsx | 36 ++--- components/admin/CandidatesField.tsx | 22 ++- components/admin/ConfirmField.tsx | 22 ++- components/admin/GradeField.tsx | 2 +- components/admin/Grades.tsx | 26 ++- components/admin/LimitDate.tsx | 27 ++-- components/admin/ParamsField.tsx | 40 +++-- components/admin/Private.tsx | 57 ++++--- components/admin/TrashButton.tsx | 8 +- components/admin/VoteButtonWithConfirm.tsx | 2 +- components/banner/Facebook.tsx | 8 +- components/banner/Twitter.tsx | 8 +- components/layouts/Footer.tsx | 6 +- components/layouts/Header.tsx | 180 +++++++++++---------- components/layouts/HeaderMobile.tsx | 10 +- components/layouts/LanguageSelector.tsx | 4 +- pages/admin/confirm/[pid].tsx | 6 +- pages/admin/settings/index.tsx | 4 +- pages/faq.tsx | 2 +- pages/index.tsx | 3 +- pages/legal-notices.tsx | 2 +- pages/privacy-policy.tsx | 2 +- pages/result/[pid]/[[...tid]].tsx | 10 +- pages/settings/index.tsx | 8 +- pages/vote/[pid]/[[...tid]].tsx | 18 +-- pages/vote/[pid]/confirm.tsx | 8 +- public/locales/en/resource.json | 4 +- public/locales/fr/resource.json | 4 +- styles/scss/_admin.scss | 22 ++- styles/scss/_app.scss | 12 +- styles/scss/_bootstrap.scss | 8 +- styles/scss/_button.scss | 19 ++- styles/scss/_datepicker.scss | 3 +- styles/scss/_switch.scss | 6 +- 45 files changed, 443 insertions(+), 368 deletions(-) diff --git a/components/Button.tsx b/components/Button.tsx index f34a144..93ea9f7 100644 --- a/components/Button.tsx +++ b/components/Button.tsx @@ -1,3 +1,4 @@ +import { isValidElement } from 'react'; import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Row, Col, Button } from 'reactstrap'; @@ -5,33 +6,35 @@ import { Row, Col, Button } from 'reactstrap'; interface ButtonProps { children?: React.ReactNode; icon?: IconProp; + customIcon?: JSX.Element; position?: 'left' | 'right'; [props: string]: any; } const ButtonWithIcon = ({ icon, + customIcon, children, position = 'left', ...props }: ButtonProps) => { - if (icon && position === 'left') { + if ((icon || customIcon) && position === 'left') { return ( ); - } else if (icon && position === 'right') { + } else if ((icon || customIcon) && position === 'right') { return ( diff --git a/components/CopyField.tsx b/components/CopyField.tsx index 924bab2..e55bcbb 100644 --- a/components/CopyField.tsx +++ b/components/CopyField.tsx @@ -41,7 +41,7 @@ const CopyField = (props) => { className="btn btn-success" type="button" > - + {t("Go")} */} @@ -54,7 +54,7 @@ const CopyField = (props) => { type="button" > {text} - + diff --git a/components/CreationSteps.tsx b/components/CreationSteps.tsx index 3fe38e6..b6e7754 100644 --- a/components/CreationSteps.tsx +++ b/components/CreationSteps.tsx @@ -6,18 +6,17 @@ import { faArrowLeft, faCheck } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; const { Row, Col, Container } = require('reactstrap'); -const Step = ({ name, position, active, check, onClick }) => { +const DesktopStep = ({ name, position, active, checked, onClick }) => { const { t } = useTranslation(); - const disabled = !active && !check; + const disabled = !active && !checked ? ' disabled' : ''; + const activeClass = active ? 'bg-white text-primary' : 'bg-secondary'; return ( - - -
{check ? : position}
+ + + {checked ? : position} {t(`admin.step-${name}`)} @@ -25,6 +24,20 @@ const Step = ({ name, position, active, check, onClick }) => { ); }; +const MobileStep = ({ position, active, checked, onClick }) => { + const disabled = !active && !checked ? ' bg-secondary disabled' : ''; + const activeClass = active ? 'bg-white text-primary' : 'bg-secondary'; + return ( +
+ {checked ? : position} +
+ ); +}; + export const creationSteps = ['candidate', 'params', 'confirm']; interface GoToStep { @@ -56,26 +69,28 @@ export const ProgressSteps = ({ const gotosteps = [goToCandidates, goToParams]; return ( - - + + {step === 'candidate' ? null : ( - + - - {t('admin.candidates-back-step')} - + {t('admin.candidates-back-step')} )} - - + + {creationSteps.map((name, i) => ( - + + {creationSteps.map((name, i) => ( + + ))} + ); diff --git a/components/DatePicker.tsx b/components/DatePicker.tsx index 119de60..51dd6b7 100644 --- a/components/DatePicker.tsx +++ b/components/DatePicker.tsx @@ -15,34 +15,37 @@ interface InputProps { } export type ButtonRef = HTMLButtonElement; -const CustomDatePicker = ({ date, setDate }) => { +const CustomDatePicker = ({ date, setDate, className = '', ...props }) => { const { t } = useTranslation(); const ExampleCustomInput = forwardRef( ({ value, onClick }, ref) => ( - +
+ +
) ); return ( } onChange={(date) => setDate(date)} /> diff --git a/components/Error.tsx b/components/Error.tsx index d3bb8a8..d0ca17d 100644 --- a/components/Error.tsx +++ b/components/Error.tsx @@ -9,7 +9,7 @@ const Error = ({ msg }) => { - + logo diff --git a/components/ListInput.tsx b/components/ListInput.tsx index 280edd0..f3f4792 100644 --- a/components/ListInput.tsx +++ b/components/ListInput.tsx @@ -8,7 +8,7 @@ import Button from '@components/Button'; const InputField = ({ value, onDelete }) => { return ( { onDelete(); }} > - + {t('Yes')} diff --git a/components/admin/CandidateField.tsx b/components/admin/CandidateField.tsx index 3bad202..67bc68c 100644 --- a/components/admin/CandidateField.tsx +++ b/components/admin/CandidateField.tsx @@ -43,16 +43,16 @@ const CandidateField = ({ const toggleSet = () => setModalSet((m) => !m); const toggleDel = () => setModalDel((m) => !m); + const activeClass = active + ? 'bg-white text-secondary' + : 'border border-dashed border-2 border-light border-opacity-25'; + return ( - + setModalDel((m) => !m)} /> ) : ( diff --git a/components/admin/CandidateModalDel.tsx b/components/admin/CandidateModalDel.tsx index bef79e2..e49afcd 100644 --- a/components/admin/CandidateModalDel.tsx +++ b/components/admin/CandidateModalDel.tsx @@ -44,28 +44,20 @@ const CandidateModal = ({ isOpen, position, toggle }) => { {candidate.name ? (

{candidate.name}

) : null} - - - - - - - - +
+ + +
); diff --git a/components/admin/CandidateModalSet.tsx b/components/admin/CandidateModalSet.tsx index caed759..250ef00 100644 --- a/components/admin/CandidateModalSet.tsx +++ b/components/admin/CandidateModalSet.tsx @@ -141,28 +141,20 @@ const CandidateModal = ({ isOpen, position, toggle }) => { // maxLength="250" /> - - - - - - - - +
+ + +
diff --git a/components/admin/CandidatesField.tsx b/components/admin/CandidatesField.tsx index 0d2acb7..2287b88 100644 --- a/components/admin/CandidatesField.tsx +++ b/components/admin/CandidatesField.tsx @@ -29,18 +29,28 @@ const CandidatesField = ({ onSubmit }) => { }, [candidates]); return ( - +

{t('admin.add-candidates')}

- {candidates.map((candidate, index) => { - return ; - })} +
+ {candidates.map((candidate, index) => { + return ( + + ); + })} +
-
+ + -
+
); }; diff --git a/components/admin/ConfirmField.tsx b/components/admin/ConfirmField.tsx index 4db5ee7..7568208 100644 --- a/components/admin/ConfirmField.tsx +++ b/components/admin/ConfirmField.tsx @@ -46,7 +46,7 @@ const CandidatesField = () => { const { t } = useTranslation(); const election = useElection(); return ( - +
{t('admin.confirm-candidates')}
@@ -56,7 +56,11 @@ const CandidatesField = () => {
{election.candidates.map((_, i) => ( - + ))}
); @@ -71,16 +75,19 @@ const ConfirmField = ({ onSubmit, goToCandidates, goToParams }) => { fluid="xl" className="my-5 flex-column d-flex justify-content-center" > + +

{t('admin.confirm-title')}

+
- +

{t('common.the-vote')}

- - + +

{t('common.the-params')}

@@ -89,17 +96,18 @@ const ConfirmField = ({ onSubmit, goToCandidates, goToParams }) => {
-
+ -
+
); }; diff --git a/components/admin/GradeField.tsx b/components/admin/GradeField.tsx index 572698b..9c8e74f 100644 --- a/components/admin/GradeField.tsx +++ b/components/admin/GradeField.tsx @@ -45,7 +45,7 @@ const GradeField = ({ value }) => {
{grade.name} diff --git a/components/admin/Grades.tsx b/components/admin/Grades.tsx index 4682dce..5adaa5c 100644 --- a/components/admin/Grades.tsx +++ b/components/admin/Grades.tsx @@ -59,22 +59,16 @@ const Grades = () => { const dispatch = useElectionDispatch(); return ( - - - -

{t('common.grades')}

-

{t('admin.grades-desc')}

- - - - {grades.map((_, i) => ( - - - - ))} - {/* */} - - + +

{t('common.grades')}

+

{t('admin.grades-desc')}

+ + {grades.map((_, i) => ( + + + + ))} + {/* */}
); diff --git a/components/admin/LimitDate.tsx b/components/admin/LimitDate.tsx index da26091..57ad318 100644 --- a/components/admin/LimitDate.tsx +++ b/components/admin/LimitDate.tsx @@ -30,15 +30,15 @@ const LimitDate = () => { const remainingDays = Math.ceil((endDate.getTime() - now.getTime()) / oneDay); return ( - - - -

+ +
+
+

{t('admin.limit-duration')} {hasDate ? ( <> {' '} -
+
{`${t('admin.ending-in')} ${remainingDays} ${t( 'common.days' )}`} @@ -47,18 +47,15 @@ const LimitDate = () => { ) : null}

{desc === '' ? null :

{desc}

} - - +
+
- - +
+
{hasDate ? ( - - - - - - +
+ +
) : null}
); diff --git a/components/admin/ParamsField.tsx b/components/admin/ParamsField.tsx index 619dda8..f3adcf9 100644 --- a/components/admin/ParamsField.tsx +++ b/components/admin/ParamsField.tsx @@ -11,23 +11,29 @@ const ParamsField = ({ onSubmit }) => { const { t } = useTranslation(); return ( - -
- - - - -
-
- + + +

{t('admin.params-title')}

+
+
+
+ + + + +
+ + +
); diff --git a/components/admin/Private.tsx b/components/admin/Private.tsx index 25be3ff..7c33fce 100644 --- a/components/admin/Private.tsx +++ b/components/admin/Private.tsx @@ -44,34 +44,41 @@ const Private = () => { }; return ( - - - -

{t('admin.private-title')}

-

{t('admin.private-desc')}

- - + <> + +
+
+

{t('admin.private-title')}

+

+ {t('admin.private-desc')} +

+
- - +
+ {election.restrictVote ? ( + <> + + + + + + + {t('admin.private-tip')} + + + + ) : null} +
{election.restrictVote ? ( - <> - - - - - - - {t('admin.private-tip')} - - - + + {t('admin.access-results-desc')} + ) : null} -
+ ); }; diff --git a/components/admin/TrashButton.tsx b/components/admin/TrashButton.tsx index 361d91c..09182ef 100644 --- a/components/admin/TrashButton.tsx +++ b/components/admin/TrashButton.tsx @@ -12,11 +12,7 @@ const TrashButton = ({ className, label, onClick }) => { return (
- + { onClick(); }} > - + {t('Yes')} diff --git a/components/admin/VoteButtonWithConfirm.tsx b/components/admin/VoteButtonWithConfirm.tsx index 3012ead..0d5407b 100644 --- a/components/admin/VoteButtonWithConfirm.tsx +++ b/components/admin/VoteButtonWithConfirm.tsx @@ -18,7 +18,7 @@ const VoteButtonWithConfirm = ({ action }) => { onClick={toggle} >
- + {t('Submit my vote')}
diff --git a/components/banner/Facebook.tsx b/components/banner/Facebook.tsx index c8c5ce4..5396cee 100644 --- a/components/banner/Facebook.tsx +++ b/components/banner/Facebook.tsx @@ -16,13 +16,7 @@ const Facebook = (props) => { 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=700' ); }; - return ( - - ); + return ; }; export default Facebook; diff --git a/components/banner/Twitter.tsx b/components/banner/Twitter.tsx index 92ca66a..2505d73 100644 --- a/components/banner/Twitter.tsx +++ b/components/banner/Twitter.tsx @@ -16,13 +16,7 @@ const Twitter = (props) => { 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=700' ); }; - return ( - - ); + return ; }; export default Twitter; diff --git a/components/layouts/Footer.tsx b/components/layouts/Footer.tsx index a16f29b..42b38d1 100644 --- a/components/layouts/Footer.tsx +++ b/components/layouts/Footer.tsx @@ -39,11 +39,7 @@ const Footer = () => { ), }, { - component: ( -
- -
- ), + component: , }, ]; diff --git a/components/layouts/Header.tsx b/components/layouts/Header.tsx index 1235317..36ebe7d 100644 --- a/components/layouts/Header.tsx +++ b/components/layouts/Header.tsx @@ -1,9 +1,11 @@ /* eslint react/prop-types: 0 */ import { useState } from 'react'; -import { Collapse, Navbar, Nav, NavItem, Button } from 'reactstrap'; +import { Collapse, Nav, NavItem, Button } from 'reactstrap'; import Link from 'next/link'; +import Image from 'next/image'; import { useTranslation } from 'next-i18next'; import LanguageSelector from './LanguageSelector'; +import openMenuIcon from '../../public/open-menu-icon.svg'; const Header = () => { const [isOpen, setOpen] = useState(false); @@ -13,104 +15,106 @@ const Header = () => { const { t } = useTranslation('resource'); return ( -
- -
- -
+ <> + open menu icon - - - -
-
+
+
+

Partagez l’application Mieux voter

+ + + + + + +
+ + + + ); }; diff --git a/components/layouts/HeaderMobile.tsx b/components/layouts/HeaderMobile.tsx index 765f916..a0be675 100644 --- a/components/layouts/HeaderMobile.tsx +++ b/components/layouts/HeaderMobile.tsx @@ -2,11 +2,13 @@ import { useState } from 'react'; import { Collapse, Navbar, NavbarToggler, Nav, NavItem } from 'reactstrap'; import Link from 'next/link'; +import Image from 'next/image'; import Head from 'next/head'; import { useTranslation } from 'next-i18next'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faRocket } from '@fortawesome/free-solid-svg-icons'; import LanguageSelector from './LanguageSelector'; +import logoColor from '../public/logos/logo-color.svg'; const Header = () => { const [isOpen, setOpen] = useState(false); @@ -24,9 +26,9 @@ const Header = () => {
- logo + logo
-
+

{t('Voting platform')} @@ -38,11 +40,11 @@ const Header = () => { -