Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(LEMS-2526): update aria label to include appearance descriptions #1745

Merged
merged 13 commits into from
Oct 18, 2024
Merged
6 changes: 6 additions & 0 deletions .changeset/tender-badgers-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@khanacademy/perseus": minor
"@khanacademy/perseus-editor": minor
---

adds appearance description to aria label
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ describe("LockedEllipseSettings", () => {

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Circle with radius 2, centered at (0, 0)",
ariaLabel:
"Circle with radius 2, centered at (0, 0). Appearance solid gray border, with no fill.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Circle with radius 2, centered at (0, 0)",
ariaLabel:
"Circle with radius 2, centered at (0, 0). Appearance solid gray border, with no fill.",
});
});

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

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

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Circle A with radius 2, centered at (0, 0)",
ariaLabel:
"Circle A with radius 2, centered at (0, 0). Appearance solid gray border, with no fill.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Circle A B with radius 2, centered at (0, 0)",
ariaLabel:
"Circle A, B with radius 2, centered at (0, 0). Appearance solid gray border, with no fill.",
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import LineStrokeSelect from "./line-stroke-select";
import LockedFigureAria from "./locked-figure-aria";
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
import LockedLabelSettings from "./locked-label-settings";
import {getDefaultFigureForType} from "./util";
import {
generateLockedFigureAppearanceDescription,
getDefaultFigureForType,
} from "./util";

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

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

const ellipseAppearance = generateLockedFigureAppearanceDescription(
color,
strokeStyle,
fillStyle,
);
str += ellipseAppearance;
return str;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ describe("Locked Function Settings", () => {

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Function with equation y=x^2",
ariaLabel:
"Function with equation y=x^2. Appearance solid gray.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Function with equation x=y^2",
ariaLabel:
"Function with equation x=y^2. Appearance solid gray.",
});
});

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

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Function with equation y=x^2",
ariaLabel:
"Function with equation y=x^2. Appearance solid gray.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Function A with equation y=x^2",
ariaLabel:
"Function A with equation y=x^2. Appearance solid gray.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Function A, B with equation y=x^2",
ariaLabel:
"Function A, B with equation y=x^2. Appearance solid gray.",
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import LockedFigureAria from "./locked-figure-aria";
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
import examples from "./locked-function-examples";
import LockedLabelSettings from "./locked-label-settings";
import {getDefaultFigureForType} from "./util";
import {
generateLockedFigureAppearanceDescription,
getDefaultFigureForType,
} from "./util";

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

const functionAppearance = generateLockedFigureAppearanceDescription(
lineColor,
strokeStyle,
);
str += functionAppearance;

return str;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ describe("LockedLineSettings", () => {

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Segment from (0, 0) to (2, 2)",
ariaLabel:
"Segment from (0, 0) to (2, 2). Appearance solid gray.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Line from (0, 0) to (2, 2)",
ariaLabel: "Line from (0, 0) to (2, 2). Appearance solid gray.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Line A from (0, 0) to (2, 2)",
ariaLabel:
"Line A from (0, 0) to (2, 2). Appearance solid gray.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Line A, B from (0, 0) to (2, 2)",
ariaLabel:
"Line A, B from (0, 0) to (2, 2). Appearance solid gray.",
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import LockedFigureAria from "./locked-figure-aria";
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
import LockedLabelSettings from "./locked-label-settings";
import LockedPointSettings from "./locked-point-settings";
import {getDefaultFigureForType} from "./util";
import {
generateLockedFigureAppearanceDescription,
getDefaultFigureForType,
} from "./util";

import type {LockedFigureSettingsCommonProps} from "./locked-figure-settings";
import type {
Expand Down Expand Up @@ -76,8 +79,12 @@ const LockedLineSettings = (props: Props) => {
if (labels && labels.length > 0) {
visiblelabel += ` ${labels.map((l) => l.text).join(", ")}`;
}

const str = `${capitalizeKind}${visiblelabel} from (${point1.coord[0]}, ${point1.coord[1]}) to (${point2.coord[0]}, ${point2.coord[1]})`;
let str = `${capitalizeKind}${visiblelabel} from (${point1.coord[0]}, ${point1.coord[1]}) to (${point2.coord[0]}, ${point2.coord[1]})`;
const lineAppearance = generateLockedFigureAppearanceDescription(
lineColor,
lineStyle,
);
str += lineAppearance;

return str;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ describe("LockedPointSettings", () => {

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Point at (0, 0)",
ariaLabel: "Point at (0, 0). Appearance solid gray.",
});
});

Expand Down Expand Up @@ -440,7 +440,7 @@ describe("LockedPointSettings", () => {

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Point A at (0, 0)",
ariaLabel: "Point A at (0, 0). Appearance solid gray.",
});
});

Expand Down Expand Up @@ -474,7 +474,7 @@ describe("LockedPointSettings", () => {

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Point A, B at (0, 0)",
ariaLabel: "Point A, B at (0, 0). Appearance solid gray.",
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import LabeledSwitch from "./labeled-switch";
import LockedFigureAria from "./locked-figure-aria";
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
import LockedLabelSettings from "./locked-label-settings";
import {getDefaultFigureForType} from "./util";
import {
generateLockedFigureAppearanceDescription,
getDefaultFigureForType,
} from "./util";

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

const str = `Point${visiblelabel} at (${coord[0]}, ${coord[1]})`;
const pointAppearance =
generateLockedFigureAppearanceDescription(pointColor);
str += pointAppearance;

return str;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ describe("LockedPolygonSettings", () => {
// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel:
"Polygon with 3 sides, vertices at (0, 0), (0, 1), (1, 1)",
"Polygon with 3 sides, vertices at (0, 0), (0, 1), (1, 1). Appearance solid gray border, with no fill.",
});
});

Expand Down Expand Up @@ -634,7 +634,7 @@ describe("LockedPolygonSettings", () => {
// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel:
"Polygon A with 3 sides, vertices at (0, 0), (0, 1), (1, 1)",
"Polygon A with 3 sides, vertices at (0, 0), (0, 1), (1, 1). Appearance solid gray border, with no fill.",
});
});

Expand Down Expand Up @@ -674,7 +674,7 @@ describe("LockedPolygonSettings", () => {
// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel:
"Polygon A, B with 3 sides, vertices at (0, 0), (0, 1), (1, 1)",
"Polygon A, B with 3 sides, vertices at (0, 0), (0, 1), (1, 1). Appearance solid gray border, with no fill.",
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ import LockedFigureAria from "./locked-figure-aria";
import LockedFigureSettingsActions from "./locked-figure-settings-actions";
import LockedLabelSettings from "./locked-label-settings";
import PolygonSwatch from "./polygon-swatch";
import {getDefaultFigureForType} from "./util";
import {
generateLockedFigureAppearanceDescription,
getDefaultFigureForType,
} from "./util";

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

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

const polygonAppearance = generateLockedFigureAppearanceDescription(
color,
strokeStyle,
fillStyle,
);
str += polygonAppearance;
return str;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ describe("Locked Vector Settings", () => {

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Vector from (0, 0) to (2, 2)",
ariaLabel:
"Vector from (0, 0) to (2, 2). Appearance solid gray.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Vector A from (0, 0) to (2, 2)",
ariaLabel:
"Vector A from (0, 0) to (2, 2). Appearance solid gray.",
});
});

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

// Assert
expect(onChangeProps).toHaveBeenCalledWith({
ariaLabel: "Vector A, B from (0, 0) to (2, 2)",
ariaLabel:
"Vector A, B from (0, 0) to (2, 2). Appearance solid gray.",
});
});
});
Expand Down
Loading