Skip to content

Commit

Permalink
Improve providers list accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-slobodian committed May 24, 2024
1 parent c970d5a commit e444332
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<IProviderInfo, "id" | "name" | "isRemovable" | "readOnly">;
isSelected: boolean;
onClick: (id: string) => void;
}
Expand All @@ -20,15 +21,19 @@ export const CertificatesProvidersListItem: React.FunctionComponent<

return (
<li
tabIndex={0}
className={clsx(styles.list_item, {
[styles.current_list_item]: isSelected,
})}
onClick={() => {
onClick && onClick(provider.id);
onClick(provider.id);
}}
onKeyDown={(event) =>
["Enter"].includes(event.code) && onClick(provider.id)
}
>
<div className={styles.list_item_icon_wrapper}>
<ProviderIcon />
{provider.isRemovable ? <SmartcardIcon /> : <ProviderIcon />}
</div>
<div className={styles.list_item_name_wrapper}>
<Typography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
display: flex;
flex-direction: column;
justify-content: center;
color: var(--pv-color-gray-9);
svg {
width: var(--pv-size-base-6);
height: var(--pv-size-base-6);
Expand Down Expand Up @@ -39,11 +40,13 @@
background-color: var(--pv-color-primary-tint-5);
cursor: default;

.list_item_icon_wrapper svg circle {
fill: var(--pv-color-primary);
}
.list_item_icon_wrapper svg path {
stroke: var(--pv-color-primary);
.list_item_icon_wrapper {
color: var(--pv-color-primary);
}
}

&:focus-visible {
outline: 1px solid var(--pv-color-primary);
z-index: 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";
import { CertificatesProvidersList } from "./CertificatesProvidersList";

const meta: Meta<typeof CertificatesProvidersList> = {
title: "Components/CertificatesProvidersList",
component: CertificatesProvidersList,
};

export default meta;
type Story = StoryObj<typeof CertificatesProvidersList>;

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(),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Typography } from "@peculiar/react-components";
import styles from "./styles/index.module.scss";

interface CertificatesProvidersListProps {
providers: IProviderInfo[];
providers: Pick<IProviderInfo, "id" | "name" | "isRemovable" | "readOnly">[];
currentProviderId?: string;
onSelect?: (id: string) => void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/icons/provider.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/icons/smartcard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e444332

Please sign in to comment.