From e444332cf87ed267d811cb8996f28012cf603216 Mon Sep 17 00:00:00 2001 From: alex-slobodian Date: Fri, 24 May 2024 13:34:08 +0300 Subject: [PATCH] Improve providers list accessibility --- .../CertificatesProvidersListItem.tsx | 11 ++++-- .../styles/index.module.scss | 13 ++++--- .../CertificatesProvidersList.stories.tsx | 38 +++++++++++++++++++ .../CertificatesProvidersList.tsx | 2 +- .../styles/index.module.scss | 2 +- src/icons/provider.svg | 6 +-- src/icons/smartcard.svg | 4 ++ 7 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 src/components/certificates-providers-list/CertificatesProvidersList.stories.tsx create mode 100644 src/icons/smartcard.svg diff --git a/src/components/certificates-providers-list-item/CertificatesProvidersListItem.tsx b/src/components/certificates-providers-list-item/CertificatesProvidersListItem.tsx index 07a3c763..6dd9b6bd 100644 --- a/src/components/certificates-providers-list-item/CertificatesProvidersListItem.tsx +++ b/src/components/certificates-providers-list-item/CertificatesProvidersListItem.tsx @@ -4,10 +4,11 @@ import { useTranslation } from "react-i18next"; import clsx from "clsx"; import { Typography } from "@peculiar/react-components"; import ProviderIcon from "../../icons/provider.svg?react"; +import SmartcardIcon from "../../icons/smartcard.svg?react"; import styles from "./styles/index.module.scss"; interface CertificatesProvidersListItemProps { - provider: IProviderInfo; + provider: Pick; isSelected: boolean; onClick: (id: string) => void; } @@ -20,15 +21,19 @@ export const CertificatesProvidersListItem: React.FunctionComponent< return (
  • { - onClick && onClick(provider.id); + onClick(provider.id); }} + onKeyDown={(event) => + ["Enter"].includes(event.code) && onClick(provider.id) + } >
    - + {provider.isRemovable ? : }
    = { + title: "Components/CertificatesProvidersList", + component: CertificatesProvidersList, +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + currentProviderId: "1", + providers: [ + { + id: "1", + name: "Provider 1", + isRemovable: false, + readOnly: true, + }, + { + id: "2", + name: "Provider 2", + isRemovable: false, + readOnly: true, + }, + { + id: "3", + name: "Smartcard", + isRemovable: true, + readOnly: true, + }, + ], + onSelect: fn(), + }, +}; diff --git a/src/components/certificates-providers-list/CertificatesProvidersList.tsx b/src/components/certificates-providers-list/CertificatesProvidersList.tsx index e693fa2c..d3e20375 100644 --- a/src/components/certificates-providers-list/CertificatesProvidersList.tsx +++ b/src/components/certificates-providers-list/CertificatesProvidersList.tsx @@ -7,7 +7,7 @@ import { Typography } from "@peculiar/react-components"; import styles from "./styles/index.module.scss"; interface CertificatesProvidersListProps { - providers: IProviderInfo[]; + providers: Pick[]; currentProviderId?: string; onSelect?: (id: string) => void; } diff --git a/src/components/certificates-providers-list/styles/index.module.scss b/src/components/certificates-providers-list/styles/index.module.scss index 54404243..f709e8db 100644 --- a/src/components/certificates-providers-list/styles/index.module.scss +++ b/src/components/certificates-providers-list/styles/index.module.scss @@ -9,7 +9,7 @@ } .list_wrapper { - padding: 0 var(--pv-size-base-2); + padding: 1px var(--pv-size-base-2); max-height: 100%; overflow-y: scroll; .list { diff --git a/src/icons/provider.svg b/src/icons/provider.svg index 07ccd137..e2852400 100644 --- a/src/icons/provider.svg +++ b/src/icons/provider.svg @@ -1,5 +1,5 @@ - - - + + + diff --git a/src/icons/smartcard.svg b/src/icons/smartcard.svg new file mode 100644 index 00000000..998b62d8 --- /dev/null +++ b/src/icons/smartcard.svg @@ -0,0 +1,4 @@ + + + +