Skip to content

Commit d96821e

Browse files
authored
[SR] Linear System - add screen reader support for Linear System interactive graph (#2030)
## Summary: Add the aria label and descriptions for the full graph and the interactive elements in the Linear System graph, based on the [SRUX doc](https://khanacademy.atlassian.net/wiki/spaces/LC/pages/3460366359/Linear+Systems). Issue: https://khanacademy.atlassian.net/browse/LEMS-1727 ## Test plan: `yarn jest packages/perseus/src/widgets/interactive-graphs/graphs/linear-system.test.tsx` Storybook - http://localhost:6006/iframe.html?globals=&args=&id=perseuseditor-widgets-interactive-graph--interactive-graph-linear-system&viewMode=story View Storybook publish in the checks below to try it yourself. https://github.com/user-attachments/assets/007a3418-5dcb-470f-a3fd-45479cc3c4d2 Author: nishasy Reviewers: catandthemachines, benchristel, nishasy, anakaren-rojas Required Reviewers: Approved By: anakaren-rojas, catandthemachines Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x) Pull Request URL: #2030
1 parent 5005a14 commit d96821e

File tree

9 files changed

+553
-56
lines changed

9 files changed

+553
-56
lines changed

.changeset/tidy-baboons-tie.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus": patch
3+
---
4+
5+
[SR] Linear System - add screen reader support for Linear System interactive graph

packages/perseus/src/strings.ts

+35
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,31 @@ export type PerseusStrings = {
260260
endingSideX: string;
261261
endingSideY: string;
262262
}) => string;
263+
srLinearSystemGraph: string;
264+
srLinearSystemPoints: ({
265+
lineNumber,
266+
point1X,
267+
point1Y,
268+
point2X,
269+
point2Y,
270+
}: {
271+
lineNumber: number;
272+
point1X: string;
273+
point1Y: string;
274+
point2X: string;
275+
point2Y: string;
276+
}) => string;
277+
srLinearSystemPoint({
278+
lineNumber,
279+
pointSequence,
280+
x,
281+
y,
282+
}: {
283+
lineNumber: number;
284+
pointSequence: number;
285+
x: string;
286+
y: string;
287+
}): string;
263288
// The above strings are used for interactive graph SR descriptions.
264289
};
265290

@@ -480,6 +505,11 @@ export const strings: {
480505
srAngleGraphAriaLabel: "An angle on a coordinate plane.",
481506
srAngleGraphAriaDescription:
482507
"The angle measure is %(angleMeasure)s degrees with a vertex at %(vertexX)s comma %(vertexY)s, a point on the starting side at %(startingSideX)s comma %(startingSideY)s and a point on the ending side at %(endingSideX)s comma %(endingSideY)s",
508+
srLinearSystemGraph: "Two lines on a coordinate plane.",
509+
srLinearSystemPoints:
510+
"Line %(lineNumber)s has two points, point 1 at %(point1X)s comma %(point1Y)s and point 2 at %(point2X)s comma %(point2Y)s.",
511+
srLinearSystemPoint:
512+
"Point %(pointSequence)s on line %(lineNumber)s at %(x)s comma %(y)s.",
483513
// The above strings are used for interactive graph SR descriptions.
484514
};
485515

@@ -697,6 +727,11 @@ export const mockStrings: PerseusStrings = {
697727
endingSideY,
698728
}) =>
699729
`The angle measure is ${angleMeasure} degrees with a vertex at ${vertexX} comma ${vertexY}, a point on the starting side at ${startingSideX} comma ${startingSideY} and a point on the ending side at ${endingSideX} comma ${endingSideY}.`,
730+
srLinearSystemGraph: "Two lines on a coordinate plane.",
731+
srLinearSystemPoints: ({lineNumber, point1X, point1Y, point2X, point2Y}) =>
732+
`Line ${lineNumber} has two points, point 1 at ${point1X} comma ${point1Y} and point 2 at ${point2X} comma ${point2Y}.`,
733+
srLinearSystemPoint: ({lineNumber, pointSequence, x, y}) =>
734+
`Point ${pointSequence} on line ${lineNumber} at ${x} comma ${y}.`,
700735
// The above strings are used for interactive graph SR descriptions.
701736
};
702737

packages/perseus/src/widgets/interactive-graphs/graphs/angle.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {vec} from "mafs";
22
import * as React from "react";
33

44
import {usePerseusI18n} from "../../../components/i18n-context";
5+
import a11y from "../../../util/a11y";
56
import {X, Y, calculateAngleInDegrees, getClockwiseAngle, polar} from "../math";
67
import {findIntersectionOfRays} from "../math/geometry";
78
import {actions} from "../reducer/interactive-graph-action";
@@ -215,7 +216,7 @@ function AngleGraph(props: AngleGraphProps) {
215216
}
216217
ariaLabel={initialSideAriaLabel}
217218
/>
218-
<g id="angle-description" style={{display: "hidden"}}>
219+
<g id="angle-description" style={a11y.srOnly}>
219220
{wholeAngleDescription}
220221
</g>
221222
</g>

packages/perseus/src/widgets/interactive-graphs/graphs/circle.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from "react";
33
import {useRef} from "react";
44

55
import {usePerseusI18n} from "../../../components/i18n-context";
6+
import a11y from "../../../util/a11y";
67
import {snap, X, Y} from "../math";
78
import {actions} from "../reducer/interactive-graph-action";
89
import {getRadius} from "../reducer/interactive-graph-state";
@@ -103,10 +104,10 @@ function CircleGraph(props: CircleGraphProps) {
103104
/>
104105
{/* Hidden elements to provide the descriptions for the
105106
circle and radius point's `aria-describedby` properties. */}
106-
<g id={radiusId} style={{display: "hidden"}}>
107+
<g id={radiusId} style={a11y.srOnly}>
107108
{srCircleRadius}
108109
</g>
109-
<g id={outerPointsId} style={{display: "hidden"}}>
110+
<g id={outerPointsId} style={a11y.srOnly}>
110111
{srCircleOuterPoints}
111112
</g>
112113
</g>

0 commit comments

Comments
 (0)