From 6751838388b8f5f7f8c752e8b1bb72854dd40c6d Mon Sep 17 00:00:00 2001 From: Helena Standaert Date: Tue, 26 Mar 2024 13:11:13 +0100 Subject: [PATCH] Optmize accessibility --- src/assets/content/newsItems.ts | 33 ++++++++++------- src/assets/icons/index.ts | 1 + src/assets/icons/linkedin.tsx | 36 +++++++++++++++++++ src/components/Button.tsx | 3 +- src/components/Container.tsx | 6 +++- src/components/Footer.tsx | 46 +++++++++++++++++++++--- src/components/Header.tsx | 6 ++++ src/components/Input.tsx | 12 +++++-- src/components/Layout.tsx | 10 +++++- src/components/Navigation.tsx | 50 ++++++++++++++------------ src/components/NewsTeaser.tsx | 49 ++++++++++++++++++++----- src/components/Switch.tsx | 20 +++++++++-- src/hooks/useForm.ts | 7 +++- src/index.css | 8 +++++ src/pages/Landing/Contact.tsx | 26 ++++++++------ src/pages/Landing/Landing.tsx | 2 +- src/pages/Landing/MissionStatement.tsx | 10 +++++- tailwind.config.js | 4 ++- 18 files changed, 259 insertions(+), 70 deletions(-) create mode 100644 src/assets/icons/linkedin.tsx diff --git a/src/assets/content/newsItems.ts b/src/assets/content/newsItems.ts index cf00818..05aef53 100644 --- a/src/assets/content/newsItems.ts +++ b/src/assets/content/newsItems.ts @@ -1,6 +1,7 @@ export type NewsItem = { key: string; image: string; + altText: string; title: string; summary: string; href: string; @@ -9,38 +10,44 @@ export type NewsItem = { const newsItems: NewsItem[] = [ { key: "0", - title: "Distinguishing between ARIA and native HTML attributes", + title: + "TinyMCE 7 - Revision History, Document Converters, Markdown and more!", summary: - "As a developer, you want to create more inclusive and accessible digital experiences for your users. Great! It’s possible, however, that you might be feeling a bit confused or overwhelmed by the element attributes that can affect the usability for users of assistive technology.", - href: "https://www.deque.com/blog/distinguishing-between-aria-and-native-html-attributes/", + "The latest version of TinyMCE is out and we have several highly requested features including Markdown, Revision History, and Document Converters.", + href: "https://dev.to/tinymce/tinymce-7-revision-history-document-converters-markdown-and-more-551n", image: "https://images.unsplash.com/photo-1556484687-30636164638b?q=80&w=3474&auto=format&fit=crop", + altText: "Hands of multiple people", }, { key: "1", - title: - "Uber Must Pay Wheelchair User $35,000, Provide Accessible Rides: B.C. Human Rights Tribunal", + title: "Accessibility tips from an accessibility engineer", summary: - "It was the first time a ride-hailing app in Canada has been the subject of a human rights tribunal, the ruling said Author of the article:Susan Lazaruk", - href: "https://www.accessibilitynewsinternational.com/uber-must-pay-wheelchair-user-35000-provide-accessible-rides-b-c-human-rights-tribunal/", + "I am a blind accessibility engineer and programmer and I thought I would write an article detailing some of the common things I see in my day job.", + href: "https://dev.to/westbrookc16/accessibility-tips-from-an-accessibility-engineer-4kl8", image: "https://images.unsplash.com/photo-1505243542579-da5adfe8338f?q=80&w=3540&auto=format&fit=crop", + altText: "Two people giving each other a handshake", }, { key: "2", - title: "E-inclusion demo", - summary: "This is a demo of the E-inclusion project.", - href: "", + title: "Using Aria States To Toggle Tailwind Classes", + summary: + "I maintain an internal UI library for a number of large sites. It's got a number of JavaScript interactions for menus, search buttons and similar.", + href: "https://dev.to/endymion1818/using-aria-states-to-toggle-tailwind-classes-1lef", image: "https://images.unsplash.com/photo-1522071820081-009f0129c71c?q=80&w=1740&auto=format&fit=crop", + altText: "A group of people sitting at a table with laptops and notebooks", }, { key: "3", - title: "E-inclusion demo", - summary: "This is a demo of the E-inclusion project.", - href: "", + title: "Responsive design and cross-device testing", + summary: + 'The so-called "browser wars" long before current web standards like HTML 5 made some web developers add badges like "best viewed with Netscape" or "best viewed with Internet Explorer"', + href: "https://dev.to/ingosteinke/responsive-design-and-cross-device-testing-1hoe", image: "https://images.unsplash.com/photo-1476703993599-0035a21b17a9?q=80&w=1740&auto=format&fit=crop", + altText: "A mother with her 2 kids", }, ]; diff --git a/src/assets/icons/index.ts b/src/assets/icons/index.ts index e0f03a6..3ed8716 100644 --- a/src/assets/icons/index.ts +++ b/src/assets/icons/index.ts @@ -1,3 +1,4 @@ export { default as ArrowRight } from "./arrowRight.tsx"; export { default as IcappsLogo } from "./icappsLogo.tsx"; export { default as Exclamation } from "./exclamation.tsx"; +export { default as LinkedIn } from "./linkedin.tsx"; diff --git a/src/assets/icons/linkedin.tsx b/src/assets/icons/linkedin.tsx new file mode 100644 index 0000000..76ffdad --- /dev/null +++ b/src/assets/icons/linkedin.tsx @@ -0,0 +1,36 @@ +import type { SvgIcon } from "./types"; + +function exclamation({ title, width = 24, height = 24, ...props }: SvgIcon) { + return ( + + {title} + + + + + + + ); +} + +export default exclamation; diff --git a/src/components/Button.tsx b/src/components/Button.tsx index b35f830..d984bb6 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -4,7 +4,7 @@ import { twMerge } from "tailwind-merge"; export type ButtonProps = PropsWithChildren & ButtonHTMLAttributes; -function Button({ type = "button", ...props }: ButtonProps) { +function Button({ type = "button", className, ...props }: ButtonProps) { return ( + ); diff --git a/src/components/NewsTeaser.tsx b/src/components/NewsTeaser.tsx index c5a72ec..b043008 100644 --- a/src/components/NewsTeaser.tsx +++ b/src/components/NewsTeaser.tsx @@ -5,14 +5,50 @@ import { Typography } from "."; type NewsTeaserProps = Omit; -function NewsTeaser({ image, title, summary }: NewsTeaserProps) { +function NewsTeaser({ image, title, summary, href, altText }: NewsTeaserProps) { const { isCompliant } = useAppState(); - return ( + return isCompliant ? ( + + ) : (
{isCompliant
@@ -20,15 +56,12 @@ function NewsTeaser({ image, title, summary }: NewsTeaserProps) {

{summary}

- {isCompliant && ( - Read more about "{title}" - )} - +
diff --git a/src/components/Switch.tsx b/src/components/Switch.tsx index 8401e54..a4861c7 100644 --- a/src/components/Switch.tsx +++ b/src/components/Switch.tsx @@ -1,5 +1,5 @@ import { useAppState } from "@/providers/AppStateProvider"; -import type { HTMLAttributes } from "react"; +import { type HTMLAttributes, useId } from "react"; import { twMerge } from "tailwind-merge"; type SwitchProps = Omit, "onChange"> & { @@ -9,6 +9,7 @@ type SwitchProps = Omit, "onChange"> & { }; function Switch({ label, value, onChange, className, ...props }: SwitchProps) { + const id = useId(); const { isCompliant } = useAppState(); const handleChange = (e: React.ChangeEvent) => { @@ -25,12 +26,14 @@ function Switch({ label, value, onChange, className, ...props }: SwitchProps) { )} > +
- {label} + {isCompliant ? ( + + ) : ( + {label} + )} ); } diff --git a/src/hooks/useForm.ts b/src/hooks/useForm.ts index ee15333..e8112ad 100644 --- a/src/hooks/useForm.ts +++ b/src/hooks/useForm.ts @@ -10,7 +10,7 @@ const formErrors: Record = { tooLong: "Please shorten this text.", tooShort: "Please lengthen this text.", typeMismatch: "Please match the requested format.", - valueMissing: "Please fill out this field.", + valueMissing: "Please fill in this field.", valid: "", }; @@ -34,6 +34,11 @@ function useForm(formRef: RefObject) { if (!isValid) { if (!formRef.current?.checkValidity()) { e.preventDefault(); + ( + formRef.current?.querySelector("input:invalid, textarea:invalid") as + | HTMLInputElement + | HTMLTextAreaElement + )?.focus(); return false; } } diff --git a/src/index.css b/src/index.css index c6a1834..1d2aedf 100644 --- a/src/index.css +++ b/src/index.css @@ -14,4 +14,12 @@ body.compliant p { @apply max-w-[60ch]; } + + body.compliant button, + body.compliant a, + body.compliant input, + body.compliant select, + body.compliant textarea { + @apply focus:outline-none focus:ring focus:ring-outlineColor; + } } diff --git a/src/pages/Landing/Contact.tsx b/src/pages/Landing/Contact.tsx index 78957b4..30e5b9e 100644 --- a/src/pages/Landing/Contact.tsx +++ b/src/pages/Landing/Contact.tsx @@ -9,7 +9,6 @@ function Contact() { const { validate, errors } = useForm(formRef); const handleSubmit = (e: FormEvent) => { - if (!isCompliant) return; if (!formRef.current) return; const isValid = validate(e); @@ -36,33 +35,30 @@ function Contact() { return ( - - Contact + + {isCompliant ? "Contacteer ons" : "Contact"} -
+ {isCompliant ? ( <> +