From ff72e55c8ff8efdff44f34d65136c39e497378a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B8egh?= Date: Wed, 10 Jan 2024 18:47:31 +0100 Subject: [PATCH 1/8] feat(AriaLive): add new component --- .../src/docs/EUFEMIA_CHANGELOG.mdx | 7 +- .../src/docs/uilib/components/aria-live.mdx | 15 ++ .../uilib/components/aria-live/Examples.tsx | 154 +++++++++++++++ .../docs/uilib/components/aria-live/demos.mdx | 15 ++ .../docs/uilib/components/aria-live/info.mdx | 52 +++++ .../uilib/components/aria-live/properties.mdx | 17 ++ .../src/docs/uilib/intro/03-accessibility.mdx | 1 + .../uilib/usage/accessibility/checklist.mdx | 1 + .../dnb-eufemia/src/components/AriaLive.ts | 14 ++ .../src/components/aria-live/AriaLive.tsx | 11 ++ .../aria-live/__tests__/AriaLive.test.tsx | 180 ++++++++++++++++++ .../aria-live/__tests__/useAriaLIve.test.ts | 36 ++++ .../src/components/aria-live/index.ts | 8 + .../aria-live/stories/AriaLive.stories.tsx | 147 ++++++++++++++ .../src/components/aria-live/types.ts | 52 +++++ .../src/components/aria-live/useAriaLive.tsx | 84 ++++++++ packages/dnb-eufemia/src/components/index.ts | 2 + packages/dnb-eufemia/src/components/lib.ts | 3 + packages/dnb-eufemia/src/index.ts | 2 + 19 files changed, 799 insertions(+), 2 deletions(-) create mode 100644 packages/dnb-design-system-portal/src/docs/uilib/components/aria-live.mdx create mode 100644 packages/dnb-design-system-portal/src/docs/uilib/components/aria-live/Examples.tsx create mode 100644 packages/dnb-design-system-portal/src/docs/uilib/components/aria-live/demos.mdx create mode 100644 packages/dnb-design-system-portal/src/docs/uilib/components/aria-live/info.mdx create mode 100644 packages/dnb-design-system-portal/src/docs/uilib/components/aria-live/properties.mdx create mode 100644 packages/dnb-eufemia/src/components/AriaLive.ts create mode 100644 packages/dnb-eufemia/src/components/aria-live/AriaLive.tsx create mode 100644 packages/dnb-eufemia/src/components/aria-live/__tests__/AriaLive.test.tsx create mode 100644 packages/dnb-eufemia/src/components/aria-live/__tests__/useAriaLIve.test.ts create mode 100644 packages/dnb-eufemia/src/components/aria-live/index.ts create mode 100644 packages/dnb-eufemia/src/components/aria-live/stories/AriaLive.stories.tsx create mode 100644 packages/dnb-eufemia/src/components/aria-live/types.ts create mode 100644 packages/dnb-eufemia/src/components/aria-live/useAriaLive.tsx diff --git a/packages/dnb-design-system-portal/src/docs/EUFEMIA_CHANGELOG.mdx b/packages/dnb-design-system-portal/src/docs/EUFEMIA_CHANGELOG.mdx index 84b9a8813a3..900c7e014c2 100644 --- a/packages/dnb-design-system-portal/src/docs/EUFEMIA_CHANGELOG.mdx +++ b/packages/dnb-design-system-portal/src/docs/EUFEMIA_CHANGELOG.mdx @@ -1,8 +1,11 @@ +## January, 18. 2024 + +- New component: [AriaLive](/uilib/components/aria-live) + ## May, 31. 2023 - [New major version 10](/uilib/about-the-lib/releases/eufemia/v10-info/) -- New components released: - - [SkipContent](/uilib/components/skip-content) +- New component: [SkipContent](/uilib/components/skip-content) - [GlobalError](/uilib/components/global-error) got new styles (without illustrations). - New [Icons](/icons/secondary): - `handshake` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/aria-live.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/aria-live.mdx new file mode 100644 index 00000000000..d966b2d928b --- /dev/null +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/aria-live.mdx @@ -0,0 +1,15 @@ +--- +title: 'AriaLive' +description: 'AriaLive is a React component and hook that helps make your web app more accessible by announcing dynamic changes to screen readers.' +showTabs: true +hideTabs: + - title: Events +theme: 'sbanken' +status: 'new' +--- + +import AriaLiveInfo from 'Docs/uilib/components/aria-live/info' +import AriaLiveDemos from 'Docs/uilib/components/aria-live/demos' + + + diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/aria-live/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/aria-live/Examples.tsx new file mode 100644 index 00000000000..13208a0181e --- /dev/null +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/aria-live/Examples.tsx @@ -0,0 +1,154 @@ +/** + * UI lib Component Example + * + */ + +import React from 'react' +import { Field, FieldBlock, Form } from '@dnb/eufemia/src/extensions/forms' +import ComponentBox from '../../../../shared/tags/ComponentBox' +import { AriaLive, Button, Flex, P } from '@dnb/eufemia/src' + +export const AriaLivePlayground = () => ( + + {() => { + const priorities = ['low', 'high'] + const contents = { + default: 'This is a default announcement', + second: 'And a second one', + third: 'A third one', + fourth: 'And a fourth one', + } + const priority: 'low' | 'high' = 'low' + const defaultData = { + enabled: false, + content: contents.default, + priority, + } + + function AriaLiveExample() { + const { data } = Form.useData('aria-live-playground', defaultData) + + return ( + + + + + {priorities.map((content) => { + return ( + + ) + })} + + + + {Object.entries(contents).map(([key, value]) => { + return ( + + ) + })} + + + + + + Output:{' '} + + Message: {data.content} + + + + + ) + } + + return + }} + +) + +export const AriaLiveAdditions = () => ( + + {() => { + const defaultData = { + enabled: false, + content: [

Line 1

], + } + + function AriaLiveExample() { + const { data, update } = Form.useData( + 'aria-live-additions', + defaultData, + ) + + return ( + + + + + + +