diff --git a/apps/site/src/app/design-system/[brand]/[...component]/components/content-tabs/components/accessibility-content/accessibility-content.component.tsx b/apps/site/src/app/design-system/[brand]/[...component]/components/content-tabs/components/accessibility-content/accessibility-content.component.tsx index a09d459f8..213500870 100644 --- a/apps/site/src/app/design-system/[brand]/[...component]/components/content-tabs/components/accessibility-content/accessibility-content.component.tsx +++ b/apps/site/src/app/design-system/[brand]/[...component]/components/content-tabs/components/accessibility-content/accessibility-content.component.tsx @@ -1,99 +1,26 @@ 'use client'; import { DocumentRenderer } from '@keystatic/core/renderer'; -import { Grid, GridItem, Select } from '@westpac/ui'; -import { useId, useState } from 'react'; import { Container } from '@/app/design-system/components'; import { Colors } from '@/components/component-blocks/colors/colors.component'; +import { AccessibilityDemo } from '@/components/component-blocks/components/accessibility-demo'; import { ShortCode } from '@/components/component-blocks/components/short-code'; import { foundationBlocksComponents } from '@/components/component-blocks/foundation-blocks'; import { Section } from '@/components/content-blocks/section'; -import { Link, Text } from '@/components/content-blocks/typography'; -import { Code, Heading } from '@/components/document-renderer'; -import { VisionFilter, VisionFilterProps } from '@/components/vision-filter'; +import { Heading } from '@/components/document-renderer'; import { DOCUMENT_RENDERERS } from '../document-renderer'; import { AccessibilityContentProps } from '.'; -const FILTERS = [ - { text: 'No filter', value: '' }, - { text: 'Achromatomaly', value: 'achromatomaly' }, - { text: 'Achromatopsia', value: 'achromatopsia' }, - { text: 'Deuteranomaly', value: 'deuteranomaly' }, - { text: 'Deuteranopia', value: 'deuteranopia' }, - { text: 'Protanomaly', value: 'protanomaly' }, - { text: 'Protanopia', value: 'protanopia' }, - { text: 'Tritanomaly', value: 'tritanomaly' }, - { text: 'Tritanopia', value: 'tritanopia' }, - { text: 'Low contrast', value: 'low-contrast' }, -] as const; - export function AccessibilityContent({ accessibilitySections, accessibilityDemo, shortCodes, }: AccessibilityContentProps) { - const [filter, setFilter] = useState(); - const id = useId(); - return ( <> - {accessibilityDemo && ( -
- - - Colour impairment demonstration - - - - - All components are designed and tested to ensure colour contrast ratios comply with the WCAG 2.1 AA - specification. Select a filter from the list below to see how this component would appear to someone - with a:{' '} - colour vision impairment. - - - -
- - -
- - , - }, - }} - componentBlocks={{ - ...foundationBlocksComponents, - shortCode: props => { - return ; - }, - }} - /> - -
-
- )} {accessibilitySections?.map(({ title, content }) => { const id = title.toLowerCase().split(' ').join('-'); return ( @@ -106,8 +33,13 @@ export function AccessibilityContent({ componentBlocks={{ ...foundationBlocksComponents, colors: props => , + accessibilityDemo: () => , shortCode: props => { - return ; + return ( +
+ +
+ ); }, }} /> diff --git a/apps/site/src/app/design-system/[brand]/[...component]/page.tsx b/apps/site/src/app/design-system/[brand]/[...component]/page.tsx index dd658d954..033c0a2b1 100644 --- a/apps/site/src/app/design-system/[brand]/[...component]/page.tsx +++ b/apps/site/src/app/design-system/[brand]/[...component]/page.tsx @@ -72,6 +72,7 @@ export default async function ComponentPage({ return shortCode.entry.content().then(content => { return resolve({ ...shortCode.entry, + slug: shortCode.slug, content, }); }); diff --git a/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.component.tsx b/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.component.tsx new file mode 100644 index 000000000..0d69dcdd5 --- /dev/null +++ b/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.component.tsx @@ -0,0 +1,63 @@ +'use client'; + +import { DocumentRenderer } from '@keystatic/core/renderer'; +import { Select } from '@westpac/ui'; +import { useId, useState } from 'react'; + +import { DOCUMENT_RENDERERS } from '@/app/articles/[article]/components/document-renderer'; +import { Code } from '@/components/code'; +import { VisionFilter, VisionFilterProps } from '@/components/vision-filter'; + +import { type AccessibilityDemoProps } from './accessibility-demo.types'; + +const FILTERS = [ + { text: 'No filter', value: '' }, + { text: 'Achromatomaly', value: 'achromatomaly' }, + { text: 'Achromatopsia', value: 'achromatopsia' }, + { text: 'Deuteranomaly', value: 'deuteranomaly' }, + { text: 'Deuteranopia', value: 'deuteranopia' }, + { text: 'Protanomaly', value: 'protanomaly' }, + { text: 'Protanopia', value: 'protanopia' }, + { text: 'Tritanomaly', value: 'tritanomaly' }, + { text: 'Tritanopia', value: 'tritanopia' }, + { text: 'Low contrast', value: 'low-contrast' }, +] as const; + +export const AccessibilityDemo = ({ content }: AccessibilityDemoProps) => { + const [filter, setFilter] = useState(); + const id = useId(); + + return ( + <> +
+ + +
+ + , + }, + }} + /> + + + ); +}; diff --git a/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.preview.tsx b/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.preview.tsx new file mode 100644 index 000000000..637f3a52c --- /dev/null +++ b/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.preview.tsx @@ -0,0 +1,24 @@ +import { component, fields } from '@keystatic/core'; + +import { AccessibilityDemo } from '.'; + +// Apparently the document field is not possible be implemented on a component. +export const accessibilityDemo = component({ + label: 'Accessibility Demo', + preview: ({ fields }) => { + return

Accessibility Demo

; + // return ; + }, + schema: { + // content: fields.document({ + // label: 'Content', + // componentBlocks: {}, + // formatting: { + // blockTypes: { + // blockquote: true, + // code: true, + // }, + // }, + // }), + }, +}); diff --git a/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.types.ts b/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.types.ts new file mode 100644 index 000000000..a51f9fb1a --- /dev/null +++ b/apps/site/src/components/component-blocks/components/accessibility-demo/accessibility-demo.types.ts @@ -0,0 +1,5 @@ +import { DocumentElement } from '@keystatic/core'; + +export type AccessibilityDemoProps = { + content: DocumentElement[]; +}; diff --git a/apps/site/src/components/component-blocks/components/accessibility-demo/index.ts b/apps/site/src/components/component-blocks/components/accessibility-demo/index.ts new file mode 100644 index 000000000..13a35dd69 --- /dev/null +++ b/apps/site/src/components/component-blocks/components/accessibility-demo/index.ts @@ -0,0 +1,2 @@ +export * from './accessibility-demo.component'; +export * from './accessibility-demo.types'; diff --git a/apps/site/src/components/component-blocks/components/short-code/short-code.component.tsx b/apps/site/src/components/component-blocks/components/short-code/short-code.component.tsx index ec251a6c1..3f49c5784 100644 --- a/apps/site/src/components/component-blocks/components/short-code/short-code.component.tsx +++ b/apps/site/src/components/component-blocks/components/short-code/short-code.component.tsx @@ -8,7 +8,7 @@ import { foundationBlocksComponents } from '../../foundation-blocks'; import { type ShortCodeProps } from './short-code.types'; export const ShortCode = ({ name, shortCodes }: ShortCodeProps) => { - const shortCode = useMemo(() => shortCodes.find(shortCode => shortCode.name === name), [name, shortCodes]); + const shortCode = useMemo(() => shortCodes.find(shortCode => shortCode.slug === name), [name, shortCodes]); return shortCode?.content ? ( - flexible, consistent message system for common user interactions. namedExport: discriminant: false +excludeFromNavbar: false design: - title: name: Alert boxes @@ -26,6 +27,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/badge/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/badge/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/badge/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/badge/index.yaml b/apps/site/src/content/design-system/components/badge/index.yaml index b9954475b..2b258b974 100644 --- a/apps/site/src/content/design-system/components/badge/index.yaml +++ b/apps/site/src/content/design-system/components/badge/index.yaml @@ -24,6 +24,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/button/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/button/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/button/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/button/index.yaml b/apps/site/src/content/design-system/components/button/index.yaml index 63a298d35..dc2264688 100644 --- a/apps/site/src/content/design-system/components/button/index.yaml +++ b/apps/site/src/content/design-system/components/button/index.yaml @@ -31,6 +31,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/compacta/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/compacta/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/compacta/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/compacta/index.yaml b/apps/site/src/content/design-system/components/compacta/index.yaml index a75690507..7a970b4aa 100644 --- a/apps/site/src/content/design-system/components/compacta/index.yaml +++ b/apps/site/src/content/design-system/components/compacta/index.yaml @@ -22,6 +22,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility notes slug: accessibility-notes diff --git a/apps/site/src/content/design-system/components/date-picker/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/date-picker/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/date-picker/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/date-picker/index.yaml b/apps/site/src/content/design-system/components/date-picker/index.yaml index 4d496bcc1..7ca64418a 100644 --- a/apps/site/src/content/design-system/components/date-picker/index.yaml +++ b/apps/site/src/content/design-system/components/date-picker/index.yaml @@ -30,6 +30,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/input-group/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/input-group/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/input-group/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/input-group/index.yaml b/apps/site/src/content/design-system/components/input-group/index.yaml index 71dee869b..d219a9cad 100644 --- a/apps/site/src/content/design-system/components/input-group/index.yaml +++ b/apps/site/src/content/design-system/components/input-group/index.yaml @@ -32,6 +32,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/link/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/link/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/link/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/link/index.yaml b/apps/site/src/content/design-system/components/link/index.yaml index 707e6fc21..163856b2d 100644 --- a/apps/site/src/content/design-system/components/link/index.yaml +++ b/apps/site/src/content/design-system/components/link/index.yaml @@ -24,6 +24,9 @@ design: slug: visual-design noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/progress-indicator/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/progress-indicator/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/progress-indicator/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/progress-indicator/index.yaml b/apps/site/src/content/design-system/components/progress-indicator/index.yaml index 643a6f3ac..dbdd79669 100644 --- a/apps/site/src/content/design-system/components/progress-indicator/index.yaml +++ b/apps/site/src/content/design-system/components/progress-indicator/index.yaml @@ -20,6 +20,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/progress-rope/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/progress-rope/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/progress-rope/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/progress-rope/index.yaml b/apps/site/src/content/design-system/components/progress-rope/index.yaml index 861dbd354..899e26d33 100644 --- a/apps/site/src/content/design-system/components/progress-rope/index.yaml +++ b/apps/site/src/content/design-system/components/progress-rope/index.yaml @@ -26,6 +26,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/radio-group/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/radio-group/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/radio-group/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/radio-group/index.yaml b/apps/site/src/content/design-system/components/radio-group/index.yaml index e53cb4e77..00b39114d 100644 --- a/apps/site/src/content/design-system/components/radio-group/index.yaml +++ b/apps/site/src/content/design-system/components/radio-group/index.yaml @@ -34,6 +34,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/design-system/components/table/accessibility/colour-impairment-demonstration/content.mdoc b/apps/site/src/content/design-system/components/table/accessibility/colour-impairment-demonstration/content.mdoc new file mode 100644 index 000000000..8cbe95006 --- /dev/null +++ b/apps/site/src/content/design-system/components/table/accessibility/colour-impairment-demonstration/content.mdoc @@ -0,0 +1,3 @@ +{% shortCode name="accessibility-colour-impairment" /%} + +{% accessibilityDemo /%} diff --git a/apps/site/src/content/design-system/components/table/index.yaml b/apps/site/src/content/design-system/components/table/index.yaml index c1f750998..da087515b 100644 --- a/apps/site/src/content/design-system/components/table/index.yaml +++ b/apps/site/src/content/design-system/components/table/index.yaml @@ -39,6 +39,9 @@ design: slug: dos-and-donts noTitle: false accessibility: + - title: + name: Colour impairment demonstration + slug: colour-impairment-demonstration - title: name: Accessibility features slug: accessibility-features diff --git a/apps/site/src/content/short-codes/accessibility-colour-impairment.yaml b/apps/site/src/content/short-codes/accessibility-colour-impairment.yaml new file mode 100644 index 000000000..0ea0ff334 --- /dev/null +++ b/apps/site/src/content/short-codes/accessibility-colour-impairment.yaml @@ -0,0 +1 @@ +name: Accessibility colour impairment diff --git a/apps/site/src/content/short-codes/accessibility-colour-impairment/content.mdoc b/apps/site/src/content/short-codes/accessibility-colour-impairment/content.mdoc new file mode 100644 index 000000000..e6b674343 --- /dev/null +++ b/apps/site/src/content/short-codes/accessibility-colour-impairment/content.mdoc @@ -0,0 +1 @@ +All components are designed and tested to ensure colour contrast ratios comply with the WCAG 2.1 AA specification. Select a filter from the list below to see how this component would appear to someone with a: [colour vision impairment](/design-system/accessibility/colour-vision-impairment). diff --git a/apps/site/src/types/short-code.types.ts b/apps/site/src/types/short-code.types.ts index 8bd7c35b7..4004d5531 100644 --- a/apps/site/src/types/short-code.types.ts +++ b/apps/site/src/types/short-code.types.ts @@ -3,4 +3,5 @@ import { DocumentElement } from '@keystatic/core'; export type ShortCode = { content: DocumentElement[]; name: string; + slug: string; }; diff --git a/packages/ui/src/components/breadcrumb/breadcrumb.component.tsx b/packages/ui/src/components/breadcrumb/breadcrumb.component.tsx index e3231ab24..ef639c379 100644 --- a/packages/ui/src/components/breadcrumb/breadcrumb.component.tsx +++ b/packages/ui/src/components/breadcrumb/breadcrumb.component.tsx @@ -5,12 +5,12 @@ import { useBreadcrumbs } from 'react-aria'; import { type BreadcrumbProps } from './breadcrumb.types.js'; -export function Breadcrumb({ className, children, ...props }: BreadcrumbProps) { +export function Breadcrumb({ className, children, 'aria-label': ariaLabel = 'Breadcrumb', ...props }: BreadcrumbProps) { const { navProps } = useBreadcrumbs(props); const childCount = Children.count(children); return ( -