From 3f9ca65cb6b4defabb5c018a68dd4959007ae1e1 Mon Sep 17 00:00:00 2001 From: Aram <37216945+alimpens@users.noreply.github.com> Date: Tue, 16 Jan 2024 12:41:27 +0100 Subject: [PATCH] Add Signals demo (#29) * Add signals demo * Change footer cell * Add menu, return skiplink * Align with current v2 design * Use react router for nav * Start content on correct column * Include Signalen in list on homepage * Fix link on logo * Add entry to index, fix type * Fix logo link * Add onSubmit navigation * Replace back button with back link * Update src/shared/components/Link.tsx Co-authored-by: Vincent Smedinga * Remove fixed TODO comment * Use signalen scoped class instead of generic one --------- Co-authored-by: Vincent Smedinga --- src/main.tsx | 2 + src/shared/components/Link.tsx | 41 ++++++++++ src/shared/pages/RootPage.tsx | 5 ++ .../signalen/components/FormNavigation.tsx | 23 ++++++ src/sites/signalen/components/SiteFooter.tsx | 44 +++++++++++ src/sites/signalen/components/SiteHeader.tsx | 22 ++++++ src/sites/signalen/components/signalen.css | 15 ++++ src/sites/signalen/constants.ts | 3 + src/sites/signalen/pages/Add.tsx | 51 +++++++++++++ src/sites/signalen/pages/Contact.tsx | 60 +++++++++++++++ src/sites/signalen/pages/Describe.tsx | 50 +++++++++++++ src/sites/signalen/pages/SignalenRootPage.tsx | 15 ++++ src/sites/signalen/pages/Summary.tsx | 75 +++++++++++++++++++ src/sites/signalen/pages/Thanks.tsx | 27 +++++++ src/sites/signalen/routes.tsx | 36 +++++++++ 15 files changed, 469 insertions(+) create mode 100644 src/shared/components/Link.tsx create mode 100644 src/sites/signalen/components/FormNavigation.tsx create mode 100644 src/sites/signalen/components/SiteFooter.tsx create mode 100644 src/sites/signalen/components/SiteHeader.tsx create mode 100644 src/sites/signalen/components/signalen.css create mode 100644 src/sites/signalen/constants.ts create mode 100644 src/sites/signalen/pages/Add.tsx create mode 100644 src/sites/signalen/pages/Contact.tsx create mode 100644 src/sites/signalen/pages/Describe.tsx create mode 100644 src/sites/signalen/pages/SignalenRootPage.tsx create mode 100644 src/sites/signalen/pages/Summary.tsx create mode 100644 src/sites/signalen/pages/Thanks.tsx create mode 100644 src/sites/signalen/routes.tsx diff --git a/src/main.tsx b/src/main.tsx index 2f897dc..8e2fe6c 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -7,6 +7,7 @@ import { RootPage } from './shared/pages/RootPage' import { routes as amopisRoutes } from './sites/amopis/routes' import { routes as amsterdamRoutes } from './sites/amsterdam/routes' +import { routes as signalenRoutes } from './sites/signalen/routes' import '@amsterdam/design-system-tokens/dist/root.css' import '@amsterdam/design-system-assets/font/index.css' @@ -21,6 +22,7 @@ const router = createBrowserRouter([ }, amopisRoutes, amsterdamRoutes, + signalenRoutes, ]) ReactDOM.createRoot(document.getElementById('root')!).render( diff --git a/src/shared/components/Link.tsx b/src/shared/components/Link.tsx new file mode 100644 index 0000000..43eeeb9 --- /dev/null +++ b/src/shared/components/Link.tsx @@ -0,0 +1,41 @@ +import type { LinkProps as LinkComponentProps } from '@amsterdam/design-system-react' +import { Link as LinkComponent } from '@amsterdam/design-system-react' +import { ForwardedRef, forwardRef, HTMLAttributeAnchorTarget, MouseEvent, PropsWithChildren } from 'react' +import { useHref, useLinkClickHandler } from 'react-router-dom' + +type LinkProps = LinkComponentProps & { + to: string + target?: HTMLAttributeAnchorTarget + replace?: boolean + state?: unknown + onClick?: (event: MouseEvent) => void +} + +export const Link = forwardRef( + ( + // TODO: Remove `PropsWithChildren` when using @amsterdam/design-system-react ^0.4.0 + { children, onClick, replace = false, state, target, to, ...rest }: PropsWithChildren, + ref: ForwardedRef, + ) => { + const href = useHref(to) + const handleClick = useLinkClickHandler(to, { replace, state, target }) + + return ( + { + window.scrollTo(0, 0) + onClick?.(event) + if (!event.defaultPrevented) { + handleClick(event) + } + }} + ref={ref} + target={target} + > + {children} + + ) + }, +) diff --git a/src/shared/pages/RootPage.tsx b/src/shared/pages/RootPage.tsx index 93adca6..69f2c6b 100644 --- a/src/shared/pages/RootPage.tsx +++ b/src/shared/pages/RootPage.tsx @@ -1,6 +1,7 @@ import { Grid, Heading, Link, PageHeading, Screen, UnorderedList } from '@amsterdam/design-system-react' import { siteUrl as amopisSiteUrl } from '../../sites/amopis/constants' import { siteUrl as amsterdamSiteUrl } from '../../sites/amsterdam/constants' +import { siteUrl as signalenSiteUrl } from '../../sites/signalen/constants' type Site = { label: string @@ -16,6 +17,10 @@ const sites: Site[] = [ label: 'Amopis', href: amopisSiteUrl, }, + { + label: 'Signalen', + href: `${signalenSiteUrl}beschrijf`, + }, ] export const RootPage = () => ( diff --git a/src/sites/signalen/components/FormNavigation.tsx b/src/sites/signalen/components/FormNavigation.tsx new file mode 100644 index 0000000..563c054 --- /dev/null +++ b/src/sites/signalen/components/FormNavigation.tsx @@ -0,0 +1,23 @@ +import { Button } from '@amsterdam/design-system-react' +import { Link } from '../../../shared/components/Link' + +const FormNavigation = ({ + firstPage, + lastPage, + backlinkUrl, +}: { + firstPage?: boolean + lastPage?: boolean + backlinkUrl?: string +}) => ( +
+ {!firstPage && backlinkUrl && ( + + Vorige + + )} + +
+) + +export default FormNavigation diff --git a/src/sites/signalen/components/SiteFooter.tsx b/src/sites/signalen/components/SiteFooter.tsx new file mode 100644 index 0000000..b27ffa7 --- /dev/null +++ b/src/sites/signalen/components/SiteFooter.tsx @@ -0,0 +1,44 @@ +import { Footer, Grid, Heading, Link, PageMenu, Paragraph, VisuallyHidden } from '@amsterdam/design-system-react' + +export const SiteFooter = () => ( +
+ + + Colofon + + + +
+ + Contact + + + Lukt het niet om een melding te doen? Bel het telefoonnummer{' '} + + 14 020 + + . + + + Wij zijn bereikbaar van maandag tot en met vrijdag van 08.00 tot 18.00 uur. + +
+
+
+
+ + + Over deze website + + + + + Over deze site + Privacy + Toegankelijkheid + + + + +
+) diff --git a/src/sites/signalen/components/SiteHeader.tsx b/src/sites/signalen/components/SiteHeader.tsx new file mode 100644 index 0000000..c616f6a --- /dev/null +++ b/src/sites/signalen/components/SiteHeader.tsx @@ -0,0 +1,22 @@ +import { Grid, Header, PageMenu, SkipLink } from '@amsterdam/design-system-react' +import { siteUrl } from '../constants' +import { PageMenuLink } from '../../../shared/components/PageMenuLink' + +export const SiteHeader = () => ( + + + Direct naar inhoud +
+ Doe een melding + Meldingenkaart + Mijn meldingen + + } + /> + + +) diff --git a/src/sites/signalen/components/signalen.css b/src/sites/signalen/components/signalen.css new file mode 100644 index 0000000..e935152 --- /dev/null +++ b/src/sites/signalen/components/signalen.css @@ -0,0 +1,15 @@ +.signalen-form-navigation { + align-items: center; + display: flex; + gap: 1rem; + justify-content: space-between; +} + +.signalen-summary-heading { + display: flex; + justify-content: space-between; +} + +.signalen-back-link svg { + transform: rotate(180deg); +} diff --git a/src/sites/signalen/constants.ts b/src/sites/signalen/constants.ts new file mode 100644 index 0000000..e3002bb --- /dev/null +++ b/src/sites/signalen/constants.ts @@ -0,0 +1,3 @@ +import { rootUrl } from '../../shared/constants' + +export const siteUrl = `${rootUrl}signalen/` diff --git a/src/sites/signalen/pages/Add.tsx b/src/sites/signalen/pages/Add.tsx new file mode 100644 index 0000000..a7ee791 --- /dev/null +++ b/src/sites/signalen/pages/Add.tsx @@ -0,0 +1,51 @@ +import { FormEvent } from 'react' +import { useNavigate } from 'react-router-dom' +import { FormLabel, Grid, Heading, Paragraph } from '@amsterdam/design-system-react' +import FormNavigation from '../components/FormNavigation' +import { siteUrl } from '../constants' + +export const Add = () => { + const navigate = useNavigate() + + const handleSubmit = async (event: FormEvent) => { + event.preventDefault() + + navigate(`${siteUrl}contact`) + } + + return ( + + +
+ Doe een melding + + Locatie en vragen + +
+ Waar is het? + KAART SELECTOR +
+ +
+ Wanneer was het? +
+ + +
+
+ + +
+
+ +
+ Waar komt het afval vandaan, denkt u? (niet verplicht) +