Skip to content

Commit 22d108f

Browse files
feat(LEMS-1733): adds aria labels to line segment (#2032)
## Summary: - Adds aria label and description to whole line segment graph - Adds copy that distinguishes between single line segment on a coordinate plane and multiple line segments on a coordinate plane - Adds aria label for individual end points of line segment Issue: LEMS-1733 ## Test plan: 1. Navigate to [Chromatic](https://650db21c3f5d1b2f13c02952-crydbfdmmp.chromatic.com/?path=/docs/perseuseditor-editorpage--docs) 2. Select Line Segment Interactive Graph from drop down 3. Validate screen reader can read line segment ### Expected behavior #### Single Segment 1. Screen reader reads aria label for whole graph: `A line segment on a coordinate plane.` 2. Screen reader reads aria description for whole graph: `A line segment on a coordinate plane. Endpoint 1 at ${point1X} comma ${point1Y}. Endpoint 2 ${point2X} comma ${point2Y}. Segment length %(length)s units.` #### Multiple Segments 1. Screen reader reads aria label for whole graph: `{Number of segments} segment on a coordinate plane.` 2. Screen reader reads aria description for whole graph: `{Number of segments} segment on a coordinate plane. Segment {N}: Endpoint 1 at ${point1X} comma ${point1Y}. Endpoint 2 ${point2X} comma ${point2Y}. Segment length %(length)s units.` #### Individual Points 1. When selected, screen reader reads aria label for end points: `Endpoint ${endpointNumber} at ${x} comma ${y}` 2. When moving a point, aria labels and descriptions adjust to include new end points and length, as appropriate ## Screenshots: ### Single Segment on a Coordinate Plane - Aria Label and Description <img width="1576" alt="image" src="https://github.com/user-attachments/assets/82c66b8a-33ed-473d-855d-bdfb8105ee49" /> ### Multiple segments on a coordinate plane - Aria Label and Description <img width="1623" alt="image" src="https://github.com/user-attachments/assets/854ae6cd-6127-499c-9528-25baa86b7d46" /> ### Individual Segment Aria Label - Description <img width="1608" alt="image" src="https://github.com/user-attachments/assets/ac70d28e-dd31-478a-a4d1-7d11baf0c772" /> Author: anakaren-rojas Reviewers: nishasy, anakaren-rojas, catandthemachines Required Reviewers: Approved By: nishasy, catandthemachines Checks: ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish npm snapshot (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), ✅ Cypress (ubuntu-latest, 20.x) Pull Request URL: #2032
1 parent 93eb5a0 commit 22d108f

File tree

6 files changed

+705
-31
lines changed

6 files changed

+705
-31
lines changed

.changeset/fuzzy-cheetahs-develop.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus": minor
3+
---
4+
5+
adds aria labels to line segment

packages/perseus/src/strings.ts

+101
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,68 @@ export type PerseusStrings = {
260260
endingSideX: string;
261261
endingSideY: string;
262262
}) => string;
263+
srSingleSegmentGraphAriaLabel: string;
264+
srMultipleSegmentGraphAriaLabel: ({
265+
countOfSegments,
266+
}: {
267+
countOfSegments: number;
268+
}) => string;
269+
srMultipleSegmentIndividualLabel: ({
270+
point1X,
271+
point1Y,
272+
point2X,
273+
point2Y,
274+
indexOfSegment,
275+
}: {
276+
point1X: string;
277+
point1Y: string;
278+
point2X: string;
279+
point2Y: string;
280+
indexOfSegment: number;
281+
}) => string;
282+
srSingleSegmentLabel: ({
283+
point1X,
284+
point1Y,
285+
point2X,
286+
point2Y,
287+
}: {
288+
point1X: string;
289+
point1Y: string;
290+
point2X: string;
291+
point2Y: string;
292+
}) => string;
293+
srSegmentLength: ({length}: {length: string}) => string;
294+
srSingleSegmentGraphEndpointAriaLabel: ({
295+
endpointNumber,
296+
x,
297+
y,
298+
}: {
299+
endpointNumber: number;
300+
x: string;
301+
y: string;
302+
}) => string;
303+
srMultipleSegmentGraphEndpointAriaLabel: ({
304+
endpointNumber,
305+
x,
306+
y,
307+
indexOfSegment,
308+
}: {
309+
endpointNumber: number;
310+
x: string;
311+
y: string;
312+
indexOfSegment: number;
313+
}) => string;
314+
srSegmentGrabHandle: ({
315+
point1X,
316+
point1Y,
317+
point2X,
318+
point2Y,
319+
}: {
320+
point1X: string;
321+
point1Y: string;
322+
point2X: string;
323+
point2Y: string;
324+
}) => string;
263325
srLinearSystemGraph: string;
264326
srLinearSystemPoints: ({
265327
lineNumber,
@@ -525,6 +587,20 @@ export const strings = {
525587
srAngleGraphAriaLabel: "An angle on a coordinate plane.",
526588
srAngleGraphAriaDescription:
527589
"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",
590+
srSingleSegmentGraphAriaLabel: "A line segment on a coordinate plane.",
591+
srMultipleSegmentGraphAriaLabel:
592+
"%(countOfSegments)s line segments on a coordinate plane.",
593+
srMultipleSegmentIndividualLabel:
594+
"Segment %(indexOfSegment)s: Endpoint 1 at %(point1X)s comma %(point1Y)s. Endpoint 2 %(point2X)s comma %(point2Y)s.",
595+
srSingleSegmentLabel:
596+
"Endpoint 1 at %(point1X)s comma %(point1Y)s. Endpoint 2 %(point2X)s comma %(point2Y)s.",
597+
srSegmentLength: "Segment length %(length)s units.",
598+
srSingleSegmentGraphEndpointAriaLabel:
599+
"Endpoint %(endpointNumber)s at %(x)s comma %(y)s.",
600+
srMultipleSegmentGraphEndpointAriaLabel:
601+
"Endpoint %(endpointNumber)s on segment %(indexOfSegment)s at %(x)s comma %(y)s.",
602+
srSegmentGrabHandle:
603+
"Segment from %(point1X)s comma %(point1Y)s to %(point2X)s comma %(point2Y)s.",
528604
srLinearSystemGraph: "Two lines on a coordinate plane.",
529605
srLinearSystemPoints:
530606
"Line %(lineNumber)s has two points, point 1 at %(point1X)s comma %(point1Y)s and point 2 at %(point2X)s comma %(point2Y)s.",
@@ -759,6 +835,31 @@ export const mockStrings: PerseusStrings = {
759835
endingSideY,
760836
}) =>
761837
`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}.`,
838+
srSingleSegmentGraphAriaLabel: "A line segment on a coordinate plane.",
839+
srMultipleSegmentGraphAriaLabel: ({countOfSegments}) =>
840+
`${countOfSegments} segments on a coordinate plane.`,
841+
srMultipleSegmentIndividualLabel: ({
842+
point1X,
843+
point1Y,
844+
point2X,
845+
point2Y,
846+
indexOfSegment,
847+
}) =>
848+
`Segment ${indexOfSegment}: Endpoint 1 at ${point1X} comma ${point1Y}. Endpoint 2 at ${point2X} comma ${point2Y}.`,
849+
srSingleSegmentLabel: ({point1X, point1Y, point2X, point2Y}) =>
850+
`Endpoint 1 at ${point1X} comma ${point1Y}. Endpoint 2 at ${point2X} comma ${point2Y}.`,
851+
srSegmentLength: ({length}) => `Segment length ${length} units.`,
852+
srSingleSegmentGraphEndpointAriaLabel: ({endpointNumber, x, y}) =>
853+
`Endpoint ${endpointNumber} at ${x} comma ${y}.`,
854+
srMultipleSegmentGraphEndpointAriaLabel: ({
855+
endpointNumber,
856+
x,
857+
y,
858+
indexOfSegment,
859+
}) =>
860+
`Endpoint ${endpointNumber} on segment ${indexOfSegment} at ${x} comma ${y}.`,
861+
srSegmentGrabHandle: ({point1X, point1Y, point2X, point2Y}) =>
862+
`Segment from ${point1X} comma ${point1Y} to ${point2X} comma ${point2Y}.`,
762863
srLinearSystemGraph: "Two lines on a coordinate plane.",
763864
srLinearSystemPoints: ({lineNumber, point1X, point1Y, point2X, point2Y}) =>
764865
`Line ${lineNumber} has two points, point 1 at ${point1X} comma ${point1Y} and point 2 at ${point2X} comma ${point2Y}.`,

0 commit comments

Comments
 (0)