Skip to content

Commit 5cbbeeb

Browse files
feat(LEMS-2526): update aria label to include appearance descriptions (#1745)
## Summary: Updates the aria description to include visual traits New aria label structure will be: `Element Type` `Visible Label(s)` `Math Details` `Visual Traits` Note: - Other updates to aria descriptions will be submitted in separate PRs Issue: LEMS-2526 ## Test plan: 1. Navigate to[ storybook ](https://650db21c3f5d1b2f13c02952-kiuwtyujyg.chromatic.com/?path=/docs/perseuseditor-editorpage--docs) 2. Add interactive graph widget using the add widget dropdown 3. Scroll down to add locked figure - select any from the dropdown 4. Click auto generate button to see basic auto generated aria label (AL) 5. Update color / line style / fill 6. Re-generate AL by clicking auto generate button to see updated label text ### Expected Behavior `Visual Traits` of each of the locked figures should change when an input (color, line style, fill) is updated and the generate aria label button is pressed ## Screen recording https://github.com/user-attachments/assets/9fb228d9-a86e-4c3b-b288-398ced6fb6f2 Author: anakaren-rojas Reviewers: benchristel, catandthemachines Required Reviewers: Approved By: benchristel, catandthemachines Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1745
1 parent 94342fc commit 5cbbeeb

16 files changed

+290
-37
lines changed

.changeset/tender-badgers-brush.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@khanacademy/perseus": minor
3+
"@khanacademy/perseus-editor": minor
4+
---
5+
6+
adds appearance description to aria label

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-ellipse-settings.test.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ describe("LockedEllipseSettings", () => {
382382

383383
// Assert
384384
expect(onChangeProps).toHaveBeenCalledWith({
385-
ariaLabel: "Circle with radius 2, centered at (0, 0)",
385+
ariaLabel:
386+
"Circle with radius 2, centered at (0, 0). Appearance solid gray border, with no fill.",
386387
});
387388
});
388389

@@ -409,7 +410,8 @@ describe("LockedEllipseSettings", () => {
409410

410411
// Assert
411412
expect(onChangeProps).toHaveBeenCalledWith({
412-
ariaLabel: "Circle with radius 2, centered at (0, 0)",
413+
ariaLabel:
414+
"Circle with radius 2, centered at (0, 0). Appearance solid gray border, with no fill.",
413415
});
414416
});
415417

@@ -436,7 +438,7 @@ describe("LockedEllipseSettings", () => {
436438
// Assert
437439
expect(onChangeProps).toHaveBeenCalledWith({
438440
ariaLabel:
439-
"Ellipse with x radius 2 and y radius 3, centered at (0, 0)",
441+
"Ellipse with x radius 2 and y radius 3, centered at (0, 0). Appearance solid gray border, with no fill.",
440442
});
441443
});
442444

@@ -464,7 +466,7 @@ describe("LockedEllipseSettings", () => {
464466
// Assert
465467
expect(onChangeProps).toHaveBeenCalledWith({
466468
ariaLabel:
467-
"Ellipse with x radius 2 and y radius 3, centered at (0, 0), rotated by 90 degrees",
469+
"Ellipse with x radius 2 and y radius 3, centered at (0, 0), rotated by 90 degrees. Appearance solid gray border, with no fill.",
468470
});
469471
});
470472

@@ -495,7 +497,8 @@ describe("LockedEllipseSettings", () => {
495497

496498
// Assert
497499
expect(onChangeProps).toHaveBeenCalledWith({
498-
ariaLabel: "Circle A with radius 2, centered at (0, 0)",
500+
ariaLabel:
501+
"Circle A with radius 2, centered at (0, 0). Appearance solid gray border, with no fill.",
499502
});
500503
});
501504

@@ -530,7 +533,8 @@ describe("LockedEllipseSettings", () => {
530533

531534
// Assert
532535
expect(onChangeProps).toHaveBeenCalledWith({
533-
ariaLabel: "Circle A B with radius 2, centered at (0, 0)",
536+
ariaLabel:
537+
"Circle A, B with radius 2, centered at (0, 0). Appearance solid gray border, with no fill.",
534538
});
535539
});
536540
});

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-ellipse-settings.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import LineStrokeSelect from "./line-stroke-select";
2020
import LockedFigureAria from "./locked-figure-aria";
2121
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
2222
import LockedLabelSettings from "./locked-label-settings";
23-
import {getDefaultFigureForType} from "./util";
23+
import {
24+
generateLockedFigureAppearanceDescription,
25+
getDefaultFigureForType,
26+
} from "./util";
2427

2528
import type {LockedFigureSettingsCommonProps} from "./locked-figure-settings";
2629
import type {
@@ -62,7 +65,7 @@ const LockedEllipseSettings = (props: Props) => {
6265
function getPrepopulatedAriaLabel() {
6366
let visiblelabel = "";
6467
if (labels && labels.length > 0) {
65-
visiblelabel += ` ${labels.map((l) => l.text).join(" ")}`;
68+
visiblelabel += ` ${labels.map((l) => l.text).join(", ")}`;
6669
}
6770

6871
const isCircle = radius[0] === radius[1];
@@ -80,6 +83,12 @@ const LockedEllipseSettings = (props: Props) => {
8083
str += `, rotated by ${radianToDegree(angle)} degrees`;
8184
}
8285

86+
const ellipseAppearance = generateLockedFigureAppearanceDescription(
87+
color,
88+
strokeStyle,
89+
fillStyle,
90+
);
91+
str += ellipseAppearance;
8392
return str;
8493
}
8594

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-function-settings.test.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,8 @@ describe("Locked Function Settings", () => {
678678

679679
// Assert
680680
expect(onChangeProps).toHaveBeenCalledWith({
681-
ariaLabel: "Function with equation y=x^2",
681+
ariaLabel:
682+
"Function with equation y=x^2. Appearance solid gray.",
682683
});
683684
});
684685

@@ -704,7 +705,8 @@ describe("Locked Function Settings", () => {
704705

705706
// Assert
706707
expect(onChangeProps).toHaveBeenCalledWith({
707-
ariaLabel: "Function with equation x=y^2",
708+
ariaLabel:
709+
"Function with equation x=y^2. Appearance solid gray.",
708710
});
709711
});
710712

@@ -730,7 +732,7 @@ describe("Locked Function Settings", () => {
730732
// Assert
731733
expect(onChangeProps).toHaveBeenCalledWith({
732734
ariaLabel:
733-
"Function with equation y=x^2, domain from 1 to 2",
735+
"Function with equation y=x^2, domain from 1 to 2. Appearance solid gray.",
734736
});
735737
});
736738

@@ -755,7 +757,8 @@ describe("Locked Function Settings", () => {
755757

756758
// Assert
757759
expect(onChangeProps).toHaveBeenCalledWith({
758-
ariaLabel: "Function with equation y=x^2",
760+
ariaLabel:
761+
"Function with equation y=x^2. Appearance solid gray.",
759762
});
760763
});
761764

@@ -785,7 +788,8 @@ describe("Locked Function Settings", () => {
785788

786789
// Assert
787790
expect(onChangeProps).toHaveBeenCalledWith({
788-
ariaLabel: "Function A with equation y=x^2",
791+
ariaLabel:
792+
"Function A with equation y=x^2. Appearance solid gray.",
789793
});
790794
});
791795

@@ -819,7 +823,8 @@ describe("Locked Function Settings", () => {
819823

820824
// Assert
821825
expect(onChangeProps).toHaveBeenCalledWith({
822-
ariaLabel: "Function A, B with equation y=x^2",
826+
ariaLabel:
827+
"Function A, B with equation y=x^2. Appearance solid gray.",
823828
});
824829
});
825830
});

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-function-settings.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ import LockedFigureAria from "./locked-figure-aria";
2828
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
2929
import examples from "./locked-function-examples";
3030
import LockedLabelSettings from "./locked-label-settings";
31-
import {getDefaultFigureForType} from "./util";
31+
import {
32+
generateLockedFigureAppearanceDescription,
33+
getDefaultFigureForType,
34+
} from "./util";
3235

3336
import type {LockedFigureSettingsCommonProps} from "./locked-figure-settings";
3437
import type {
@@ -95,6 +98,12 @@ const LockedFunctionSettings = (props: Props) => {
9598
str += `, domain from ${domain[0]} to ${domain[1]}`;
9699
}
97100

101+
const functionAppearance = generateLockedFigureAppearanceDescription(
102+
lineColor,
103+
strokeStyle,
104+
);
105+
str += functionAppearance;
106+
98107
return str;
99108
}
100109

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-line-settings.test.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,8 @@ describe("LockedLineSettings", () => {
614614

615615
// Assert
616616
expect(onChangeProps).toHaveBeenCalledWith({
617-
ariaLabel: "Segment from (0, 0) to (2, 2)",
617+
ariaLabel:
618+
"Segment from (0, 0) to (2, 2). Appearance solid gray.",
618619
});
619620
});
620621

@@ -639,7 +640,7 @@ describe("LockedLineSettings", () => {
639640

640641
// Assert
641642
expect(onChangeProps).toHaveBeenCalledWith({
642-
ariaLabel: "Line from (0, 0) to (2, 2)",
643+
ariaLabel: "Line from (0, 0) to (2, 2). Appearance solid gray.",
643644
});
644645
});
645646

@@ -669,7 +670,8 @@ describe("LockedLineSettings", () => {
669670

670671
// Assert
671672
expect(onChangeProps).toHaveBeenCalledWith({
672-
ariaLabel: "Line A from (0, 0) to (2, 2)",
673+
ariaLabel:
674+
"Line A from (0, 0) to (2, 2). Appearance solid gray.",
673675
});
674676
});
675677

@@ -703,7 +705,8 @@ describe("LockedLineSettings", () => {
703705

704706
// Assert
705707
expect(onChangeProps).toHaveBeenCalledWith({
706-
ariaLabel: "Line A, B from (0, 0) to (2, 2)",
708+
ariaLabel:
709+
"Line A, B from (0, 0) to (2, 2). Appearance solid gray.",
707710
});
708711
});
709712
});

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-line-settings.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import LockedFigureAria from "./locked-figure-aria";
2525
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
2626
import LockedLabelSettings from "./locked-label-settings";
2727
import LockedPointSettings from "./locked-point-settings";
28-
import {getDefaultFigureForType} from "./util";
28+
import {
29+
generateLockedFigureAppearanceDescription,
30+
getDefaultFigureForType,
31+
} from "./util";
2932

3033
import type {LockedFigureSettingsCommonProps} from "./locked-figure-settings";
3134
import type {
@@ -76,8 +79,12 @@ const LockedLineSettings = (props: Props) => {
7679
if (labels && labels.length > 0) {
7780
visiblelabel += ` ${labels.map((l) => l.text).join(", ")}`;
7881
}
79-
80-
const str = `${capitalizeKind}${visiblelabel} from (${point1.coord[0]}, ${point1.coord[1]}) to (${point2.coord[0]}, ${point2.coord[1]})`;
82+
let str = `${capitalizeKind}${visiblelabel} from (${point1.coord[0]}, ${point1.coord[1]}) to (${point2.coord[0]}, ${point2.coord[1]})`;
83+
const lineAppearance = generateLockedFigureAppearanceDescription(
84+
lineColor,
85+
lineStyle,
86+
);
87+
str += lineAppearance;
8188

8289
return str;
8390
}

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-point-settings.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ describe("LockedPointSettings", () => {
410410

411411
// Assert
412412
expect(onChangeProps).toHaveBeenCalledWith({
413-
ariaLabel: "Point at (0, 0)",
413+
ariaLabel: "Point at (0, 0). Appearance solid gray.",
414414
});
415415
});
416416

@@ -440,7 +440,7 @@ describe("LockedPointSettings", () => {
440440

441441
// Assert
442442
expect(onChangeProps).toHaveBeenCalledWith({
443-
ariaLabel: "Point A at (0, 0)",
443+
ariaLabel: "Point A at (0, 0). Appearance solid gray.",
444444
});
445445
});
446446

@@ -474,7 +474,7 @@ describe("LockedPointSettings", () => {
474474

475475
// Assert
476476
expect(onChangeProps).toHaveBeenCalledWith({
477-
ariaLabel: "Point A, B at (0, 0)",
477+
ariaLabel: "Point A, B at (0, 0). Appearance solid gray.",
478478
});
479479
});
480480
});

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-point-settings.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import LabeledSwitch from "./labeled-switch";
2222
import LockedFigureAria from "./locked-figure-aria";
2323
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
2424
import LockedLabelSettings from "./locked-label-settings";
25-
import {getDefaultFigureForType} from "./util";
25+
import {
26+
generateLockedFigureAppearanceDescription,
27+
getDefaultFigureForType,
28+
} from "./util";
2629

2730
import type {LockedFigureSettingsMovementType} from "./locked-figure-settings-actions";
2831
import type {
@@ -115,8 +118,11 @@ const LockedPointSettings = (props: Props) => {
115118
if (labels && labels.length > 0) {
116119
visiblelabel += ` ${labels.map((l) => l.text).join(", ")}`;
117120
}
121+
let str = `Point${visiblelabel} at (${coord[0]}, ${coord[1]})`;
118122

119-
const str = `Point${visiblelabel} at (${coord[0]}, ${coord[1]})`;
123+
const pointAppearance =
124+
generateLockedFigureAppearanceDescription(pointColor);
125+
str += pointAppearance;
120126

121127
return str;
122128
}

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-polygon-settings.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ describe("LockedPolygonSettings", () => {
598598
// Assert
599599
expect(onChangeProps).toHaveBeenCalledWith({
600600
ariaLabel:
601-
"Polygon with 3 sides, vertices at (0, 0), (0, 1), (1, 1)",
601+
"Polygon with 3 sides, vertices at (0, 0), (0, 1), (1, 1). Appearance solid gray border, with no fill.",
602602
});
603603
});
604604

@@ -634,7 +634,7 @@ describe("LockedPolygonSettings", () => {
634634
// Assert
635635
expect(onChangeProps).toHaveBeenCalledWith({
636636
ariaLabel:
637-
"Polygon A with 3 sides, vertices at (0, 0), (0, 1), (1, 1)",
637+
"Polygon A with 3 sides, vertices at (0, 0), (0, 1), (1, 1). Appearance solid gray border, with no fill.",
638638
});
639639
});
640640

@@ -674,7 +674,7 @@ describe("LockedPolygonSettings", () => {
674674
// Assert
675675
expect(onChangeProps).toHaveBeenCalledWith({
676676
ariaLabel:
677-
"Polygon A, B with 3 sides, vertices at (0, 0), (0, 1), (1, 1)",
677+
"Polygon A, B with 3 sides, vertices at (0, 0), (0, 1), (1, 1). Appearance solid gray border, with no fill.",
678678
});
679679
});
680680
});

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-polygon-settings.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ import LockedFigureAria from "./locked-figure-aria";
3232
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
3333
import LockedLabelSettings from "./locked-label-settings";
3434
import PolygonSwatch from "./polygon-swatch";
35-
import {getDefaultFigureForType} from "./util";
35+
import {
36+
generateLockedFigureAppearanceDescription,
37+
getDefaultFigureForType,
38+
} from "./util";
3639

3740
import type {LockedFigureSettingsCommonProps} from "./locked-figure-settings";
3841

@@ -72,6 +75,12 @@ const LockedPolygonSettings = (props: Props) => {
7275
// Add the coordinates of each point to the aria label
7376
str += points.map(([x, y]) => `(${x}, ${y})`).join(", ");
7477

78+
const polygonAppearance = generateLockedFigureAppearanceDescription(
79+
color,
80+
strokeStyle,
81+
fillStyle,
82+
);
83+
str += polygonAppearance;
7584
return str;
7685
}
7786

packages/perseus-editor/src/widgets/interactive-graph-editor/locked-figures/locked-vector-settings.test.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ describe("Locked Vector Settings", () => {
430430

431431
// Assert
432432
expect(onChangeProps).toHaveBeenCalledWith({
433-
ariaLabel: "Vector from (0, 0) to (2, 2)",
433+
ariaLabel:
434+
"Vector from (0, 0) to (2, 2). Appearance solid gray.",
434435
});
435436
});
436437

@@ -460,7 +461,8 @@ describe("Locked Vector Settings", () => {
460461

461462
// Assert
462463
expect(onChangeProps).toHaveBeenCalledWith({
463-
ariaLabel: "Vector A from (0, 0) to (2, 2)",
464+
ariaLabel:
465+
"Vector A from (0, 0) to (2, 2). Appearance solid gray.",
464466
});
465467
});
466468

@@ -494,7 +496,8 @@ describe("Locked Vector Settings", () => {
494496

495497
// Assert
496498
expect(onChangeProps).toHaveBeenCalledWith({
497-
ariaLabel: "Vector A, B from (0, 0) to (2, 2)",
499+
ariaLabel:
500+
"Vector A, B from (0, 0) to (2, 2). Appearance solid gray.",
498501
});
499502
});
500503
});

0 commit comments

Comments
 (0)