Skip to content

Commit a2ac6cf

Browse files
author
Sine Jespersen
committed
modals described by
1 parent 4e2e258 commit a2ac6cf

File tree

8 files changed

+51
-9
lines changed

8 files changed

+51
-9
lines changed

src/stories/Library/Buttons/button-ui/ButtonUI.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type ButtonUIProps = {
1919
classes?: string;
2020
ariaLabel: string;
2121
onClick?: () => void;
22+
describe?: string;
2223
};
2324

2425
export const ButtonUI: React.FC<ButtonUIProps> = ({
@@ -27,6 +28,7 @@ export const ButtonUI: React.FC<ButtonUIProps> = ({
2728
children,
2829
onClick,
2930
ariaLabel,
31+
describe,
3032
}) => {
3133
const getChild = () => {
3234
if (content.kind === "LABEL") return content.label;
@@ -42,6 +44,7 @@ export const ButtonUI: React.FC<ButtonUIProps> = ({
4244
return (
4345
<button
4446
type="button"
47+
aria-describedby={describe}
4548
className={`btn-ui ${classes || ""}`}
4649
onClick={onClick}
4750
aria-label={ariaLabel}

src/stories/Library/Modals/ModalShared.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@ export function ModalFallbackButton({
2525
);
2626
}
2727

28-
export function ModalCloseButton({ toggleModal }: { toggleModal: () => void }) {
28+
export function ModalCloseButton({
29+
toggleModal,
30+
idAriaDescribedBy,
31+
}: {
32+
toggleModal: () => void;
33+
idAriaDescribedBy: string;
34+
}) {
2935
return (
3036
<ButtonUI
37+
describe={idAriaDescribedBy}
3138
onClick={toggleModal}
3239
classes="modal-btn-close"
3340
ariaLabel="close modal"

src/stories/Library/Modals/modal-cta/ModalCTA.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ export const ModalCTA: React.FC<ModalCTAProps> = ({ title, showModal }) => {
3131
shownModal ? "modal-show" : ""
3232
}`}
3333
>
34-
<ModalCloseButton toggleModal={toggleModal} />
34+
<div className="modal__screen-reader-description" id="describemodal">
35+
Denne modal dækker sidens indhold, og er en demo
36+
</div>
37+
<ModalCloseButton
38+
idAriaDescribedBy="describemodal"
39+
toggleModal={toggleModal}
40+
/>
3541
<div className="modal-cta__container">
3642
<h2 className="text-header-h2">{title}</h2>
3743
<div className="mt-48 color-secondary-gray">

src/stories/Library/Modals/modal-details/ModalDetails.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ export const ModalDetails: React.FC<ModalDetailsProps> = ({
125125
<div
126126
className={`modal modal-details ${shoudShowModal ? "modal-show" : ""}`}
127127
>
128-
<ModalCloseButton toggleModal={toggleModal} />
128+
<div className="modal__screen-reader-description" id="describemodal">
129+
Denne modal dækker sidens indhold, og er en demo
130+
</div>
131+
<ModalCloseButton
132+
idAriaDescribedBy="describemodal"
133+
toggleModal={toggleModal}
134+
/>
129135
<div className="modal-details__container">
130136
<div className="modal-details__header">
131137
<div className="modal-details__cover">

src/stories/Library/Modals/modal-loan/ModalLoan.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useEffect, useMemo, useState } from "react";
2-
32
import { ModalCloseButton, ModalFallbackButton } from "../ModalShared";
43
import { Button } from "../../Buttons/button/Button";
54
import { Checkbox } from "../../Forms/checkbox/Checkbox";
@@ -171,10 +170,13 @@ export const ModalLoan: React.FC<ModalLoanProps> = ({
171170
shoulShowModal ? "modal-show" : ""
172171
}`}
173172
>
174-
<div className="modal__screen-reader-description">
173+
<div className="modal__screen-reader-description" id="describemodal">
175174
Denne modal dækker sidens indhold, og er en demo
176175
</div>
177-
<ModalCloseButton toggleModal={toggleModal} />
176+
<ModalCloseButton
177+
idAriaDescribedBy="describemodal"
178+
toggleModal={toggleModal}
179+
/>
178180
<div className="modal-loan__container">
179181
<div className="modal-loan__header">
180182
{isExpired && (

src/stories/Library/Modals/modal-pause/ModalPause.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ export const ModalPause: React.FC<ModalPauseProps> = ({
3939
shouldShowModal ? "modal-show" : ""
4040
} modal-padding `}
4141
>
42-
<ModalCloseButton toggleModal={toggleModal} />
42+
<div className="modal__screen-reader-description" id="describemodal">
43+
Denne modal dækker sidens indhold, og er en demo
44+
</div>
45+
<ModalCloseButton
46+
idAriaDescribedBy="describemodal"
47+
toggleModal={toggleModal}
48+
/>
4349
<div className="modal-pause__container">
4450
<h3 className="text-header-h3">{title}</h3>
4551
<div className="mt-48 color-secondary-gray">

src/stories/Library/Modals/modal-search/ModalSearch.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ export const ModalSearch: React.FC<ModalSearchProps> = ({ showModal }) => {
2828
shouldShowModal ? "modal-show" : ""
2929
} modal-padding `}
3030
>
31-
<ModalCloseButton toggleModal={toggleModal} />
31+
<div className="modal__screen-reader-description" id="describemodal">
32+
Denne modal dækker sidens indhold, og er en demo
33+
</div>
34+
<ModalCloseButton
35+
idAriaDescribedBy="describemodal"
36+
toggleModal={toggleModal}
37+
/>
3238
<div className="modal-search__container">
3339
<h3 className="text-header-h3">Gem søgning</h3>
3440
<div className="mt-48 color-secondary-gray">

src/stories/Library/Modals/modal-text/ModalText.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ export const ModalText = (props: ModalTextProps) => {
4747
showModal ? "modal-show" : ""
4848
} modal-padding`}
4949
>
50-
<ModalCloseButton toggleModal={toggleModal} />
50+
<div className="modal__screen-reader-description" id="describemodal">
51+
Denne modal dækker sidens indhold, og er en demo
52+
</div>
53+
<ModalCloseButton
54+
idAriaDescribedBy="describemodal"
55+
toggleModal={toggleModal}
56+
/>
5157
<div className="modal-text__container color-secondary-gray">
5258
<h3 className="text-header-h3">{title}</h3>
5359

0 commit comments

Comments
 (0)