Skip to content

Commit

Permalink
Add accessible names and strings for UI elements in Number Pairs, see:
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Jan 31, 2025
1 parent 61e2a36 commit 2acceb0
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 2 deletions.
18 changes: 18 additions & 0 deletions js/NumberPairsStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ type StringsType = {
'totalJumpStringProperty': LocalizedStringProperty;
'automaticallyHearPhraseStringProperty': LocalizedStringProperty;
'automaticallyHearPhraseDescriptionStringProperty': LocalizedStringProperty;
'hearNumberSentenceStringProperty': LocalizedStringProperty;
'organizeObjectsStringProperty': LocalizedStringProperty;
'organizeObjectsHelpTextStringProperty': LocalizedStringProperty;
'swapAddendsStringProperty': LocalizedStringProperty;
'makesAreaVisibleStringProperty': LocalizedStringProperty;
'firstAddendNoJumpStringProperty': LocalizedStringProperty;
'firstAddendJumpStringProperty': LocalizedStringProperty;
'sceneSelectionRadioButtonGroupStringProperty': LocalizedStringProperty;
'applesStringProperty': LocalizedStringProperty;
'soccerBallsStringProperty': LocalizedStringProperty;
'butterfliesStringProperty': LocalizedStringProperty;
'oneCardsStringProperty': LocalizedStringProperty;
'kittensStringProperty': LocalizedStringProperty;
'beadsStringProperty': LocalizedStringProperty;
'numberLineStringProperty': LocalizedStringProperty;
'representationTypeStringProperty': LocalizedStringProperty;
'locationCountingObjectsStringProperty': LocalizedStringProperty;
'numberLineSliderStringProperty': LocalizedStringProperty;
};

const NumberPairsStrings = getStringModule( 'NUMBER_PAIRS' ) as StringsType;
Expand Down
10 changes: 10 additions & 0 deletions js/common/model/RepresentationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import NumberPairsColors from '../NumberPairsColors.js';
import NumberLineIcon from '../view/NumberLineIcon.js';
// eslint-disable-next-line phet/no-view-imported-from-model
import OneCard from '../view/OneCard.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';
import TProperty from '../../../../axon/js/TProperty.js';


const ICON_MAX_WIDTH = 25;
Expand All @@ -32,48 +34,55 @@ export default class RepresentationType extends EnumerationValue {

public static readonly APPLES = new RepresentationType(
'apples',
NumberPairsStrings.applesStringProperty,
NumberPairsColors.locationSumColorProperty,
NumberPairsColors.locationLeftAddendColorProperty,
NumberPairsColors.locationRightAddendColorProperty,
new Image( apple_svg, { maxWidth: ICON_MAX_WIDTH, maxHeight: ICON_MAX_HEIGHT } )
);
public static readonly SOCCER_BALLS = new RepresentationType(
'soccerBalls',
NumberPairsStrings.soccerBallsStringProperty,
NumberPairsColors.locationSumColorProperty,
NumberPairsColors.locationLeftAddendColorProperty,
NumberPairsColors.locationRightAddendColorProperty,
new Image( soccerball_svg, { maxWidth: ICON_MAX_WIDTH, maxHeight: ICON_MAX_HEIGHT } )
);
public static readonly BUTTERFLIES = new RepresentationType(
'butterflies',
NumberPairsStrings.butterfliesStringProperty,
NumberPairsColors.locationSumColorProperty,
NumberPairsColors.locationLeftAddendColorProperty,
NumberPairsColors.locationRightAddendColorProperty,
new Image( butterfly_svg, { maxWidth: ICON_MAX_WIDTH, maxHeight: ICON_MAX_HEIGHT } )
);
public static readonly ONE_CARDS = new RepresentationType(
'oneCards',
NumberPairsStrings.oneCardsStringProperty,
NumberPairsColors.locationSumColorProperty,
NumberPairsColors.locationLeftAddendColorProperty,
NumberPairsColors.locationRightAddendColorProperty,
new OneCard( ICON_MAX_WIDTH, ICON_MAX_HEIGHT, 20 )
);
public static readonly KITTENS = new RepresentationType(
'kittens',
NumberPairsStrings.kittensStringProperty,
NumberPairsColors.attributeSumColorProperty,
NumberPairsColors.attributeLeftAddendColorProperty,
NumberPairsColors.attributeRightAddendColorProperty,
new Image( kittenBlue_svg, { maxWidth: ICON_MAX_WIDTH, maxHeight: ICON_MAX_HEIGHT } )
);
public static readonly BEADS = new RepresentationType(
'beads',
NumberPairsStrings.beadsStringProperty,
NumberPairsColors.numberLineSumColorProperty,
NumberPairsColors.numberLineLeftAddendColorProperty,
NumberPairsColors.numberLineRightAddendColorProperty,
new Image( beadBlue_svg, { maxWidth: ICON_MAX_WIDTH, maxHeight: ICON_MAX_HEIGHT } )
);
public static readonly NUMBER_LINE = new RepresentationType(
'numberLine',
NumberPairsStrings.numberLineStringProperty,
NumberPairsColors.numberLineSumColorProperty,
NumberPairsColors.numberLineLeftAddendColorProperty,
NumberPairsColors.numberLineRightAddendColorProperty,
Expand All @@ -83,6 +92,7 @@ export default class RepresentationType extends EnumerationValue {

public constructor(
public readonly label: string,
public readonly accessibleName: TProperty<string>,
public readonly totalColorProperty: Property<Color>,
public readonly leftAddendColorProperty: Property<Color>,
public readonly rightAddendColorProperty: Property<Color>,
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/LocationCountingObjectsLayerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import DynamicProperty from '../../../../axon/js/DynamicProperty.js';
import LocationCountingObjectNode from './LocationCountingObjectNode.js';
import NumberPairsConstants from '../NumberPairsConstants.js';
import CountingAreaNode from './CountingAreaNode.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';

type LocationCountingObjectsLayerNodeOptions = WithRequired<NodeOptions, 'tandem'>;

Expand All @@ -32,7 +33,7 @@ export default class LocationCountingObjectsLayerNode extends Node {
public constructor( private readonly model: NumberPairsModel, countingAreaNode: CountingAreaNode, providedOptions: LocationCountingObjectsLayerNodeOptions ) {

const options = optionize<LocationCountingObjectsLayerNodeOptions, EmptySelfOptions, NodeOptions>()( {
accessibleName: 'Location Counting Objects'
accessibleName: NumberPairsStrings.locationCountingObjectsStringProperty
}, providedOptions );

super( options );
Expand Down
2 changes: 2 additions & 0 deletions js/common/view/NumberLineNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import CurvedArrowNode from './CurvedArrowNode.js';
import NumberLineSlider from './NumberLineSlider.js';
import NumberRectangle from './NumberRectangle.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';

type SelfOptions = {
numberLineRange: Range;
Expand Down Expand Up @@ -56,6 +57,7 @@ export default class NumberLineNode extends Node {
trackModelViewTransform,
model.showTickValuesProperty,
{
accessibleName: NumberPairsStrings.numberLineSliderStringProperty,
numberLineRange: options.numberLineRange,
numberLineWidth: numberLineWidth,
tandem: options.tandem.createTandem( 'slider' )
Expand Down
9 changes: 9 additions & 0 deletions js/common/view/NumberPairsScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import SpeechSynthesisControl from '../../../../number-suite-common/js/common/vi
import LocaleSwitch from '../../../../number-suite-common/js/common/view/LocaleSwitch.js';
import NumberPairsPreferences from '../model/NumberPairsPreferences.js';
import { NumberPairsUtils } from '../model/NumberPairsUtils.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';

type SelfOptions = {
numberSentenceContent: Node;
Expand Down Expand Up @@ -128,6 +129,9 @@ export default class NumberPairsScreenView extends ScreenView {
* Create the buttons along the left edge of each screen
*/
const speechSynthesisControl = new SpeechSynthesisControl( numberPairsSpeechSynthesisAnnouncer, numberPairsUtteranceQueue, {
speechSynthesisButtonOptions: {
accessibleName: NumberPairsStrings.hearNumberSentenceStringProperty
},
x: this.layoutBounds.minX + NumberPairsConstants.SCREEN_VIEW_X_MARGIN,
y: this.layoutBounds.minY + NumberPairsConstants.SCREEN_VIEW_Y_MARGIN,
tandem: options.tandem.createTandem( 'speechSynthesisControl' )
Expand All @@ -151,6 +155,8 @@ export default class NumberPairsScreenView extends ScreenView {
const sumTenFrameBounds = COUNTING_AREA_BOUNDS.erodedX( COUNTING_AREA_BOUNDS.width / 3.5 );
const tenFrameBounds = options.sumScreen ? [ sumTenFrameBounds ] : NumberPairsUtils.splitBoundsInHalf( COUNTING_AREA_BOUNDS );
const tenFrameButton = new TenFrameButton( {
accessibleName: NumberPairsStrings.organizeObjectsStringProperty,
helpText: NumberPairsStrings.organizeObjectsHelpTextStringProperty,
tandem: options.tandem.createTandem( 'tenFrameButton' ),
listener: () => {
this.interruptSubtreeInput();
Expand All @@ -166,6 +172,7 @@ export default class NumberPairsScreenView extends ScreenView {
} );

const commutativeButton = new CommutativeButton( {
accessibleName: NumberPairsStrings.swapAddendsStringProperty,
listener: () => {
this.interruptSubtreeInput();
model.swapAddends.bind( model )();
Expand Down Expand Up @@ -300,6 +307,8 @@ export default class NumberPairsScreenView extends ScreenView {
top: COUNTING_AREA_BOUNDS.bottom + COUNTING_AREA_Y_MARGIN,
left: COUNTING_AREA_BOUNDS.left,
visibleProperty: numberLineVisibleProperty,
valueAAccessibleName: NumberPairsStrings.firstAddendNoJumpStringProperty,
valueBAccessibleName: NumberPairsStrings.firstAddendJumpStringProperty,
toggleSwitchOptions: {
size: new Dimension2( 36, 18 )
},
Expand Down
7 changes: 6 additions & 1 deletion js/common/view/RepresentationRadioButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Color, Node } from '../../../../scenery/js/imports.js';
import RectangularRadioButtonGroup, { RectangularRadioButtonGroupOptions } from '../../../../sun/js/buttons/RectangularRadioButtonGroup.js';
import numberPairs from '../../numberPairs.js';
import RepresentationType, { ICON_MAX_HEIGHT } from '../model/RepresentationType.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';

type SelfOptions = EmptySelfOptions;
type CountingRepresentationRadioButtonGroupOptions = SelfOptions & PickRequired<RectangularRadioButtonGroupOptions, 'tandem'> &
Expand All @@ -29,12 +30,16 @@ export default class RepresentationRadioButtonGroup extends RectangularRadioButt
return {
value: countingRepresentationType,
createNode: () => new Node( { children: [ countingRepresentationType.icon ] } ),
tandemName: countingRepresentationType.label + 'RadioButton'
tandemName: countingRepresentationType.label + 'RadioButton',
options: {
accessibleName: countingRepresentationType.accessibleName
}
};
} ) || [];

const buttonMargin = 3;
const options = optionize<CountingRepresentationRadioButtonGroupOptions, SelfOptions, RectangularRadioButtonGroupOptions>()( {
accessibleName: NumberPairsStrings.representationTypeStringProperty,
orientation: 'horizontal',
radioButtonOptions: {
baseColor: Color.WHITE,
Expand Down
2 changes: 2 additions & 0 deletions js/common/view/SceneSelectionRadioButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Text } from '../../../../scenery/js/imports.js';
import RectangularRadioButtonGroup, { RectangularRadioButtonGroupOptions } from '../../../../sun/js/buttons/RectangularRadioButtonGroup.js';
import numberPairs from '../../numberPairs.js';
import NumberPairsScene from '../model/NumberPairsScene.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';

type SelfOptions = {
sceneRange: Range;
Expand All @@ -26,6 +27,7 @@ export default class SceneSelectionRadioButtonGroup extends RectangularRadioButt

public constructor( selectedSceneModelProperty: PhetioProperty<NumberPairsScene>, sceneModels: NumberPairsScene[], providedOptions: SceneSelectionRadioButtonGroupOptions ) {
const options = optionize<SceneSelectionRadioButtonGroupOptions, SelfOptions, RectangularRadioButtonGroupOptions>()( {
accessibleName: NumberPairsStrings.sceneSelectionRadioButtonGroupStringProperty,
radioButtonOptions: {
size: new Dimension2( 40, 40 )
}
Expand Down
2 changes: 2 additions & 0 deletions js/common/view/ShowHideAddendButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import eyeSolidShape from '../../../../sherpa/js/fontawesome-5/eyeSolidShape.js'
import RectangularPushButton, { RectangularPushButtonOptions } from '../../../../sun/js/buttons/RectangularPushButton.js';
import numberPairs from '../../numberPairs.js';
import NumberPairsConstants from '../NumberPairsConstants.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';

type SelfOptions = {
secondAddendVisibleProperty?: BooleanProperty | null;
Expand All @@ -30,6 +31,7 @@ export default class ShowHideAddendButton extends RectangularPushButton {
public constructor( addendVisibleProperty: BooleanProperty, providedOptions: ShowHideAddendButtonOptions ) {

const initialOptions = optionize<ShowHideAddendButtonOptions, SelfOptions, RectangularPushButtonOptions>()( {
accessibleName: NumberPairsStrings.makesAreaVisibleStringProperty,
size: new Dimension2( NumberPairsConstants.RECTANGULAR_PUSH_BUTTON_OPTIONS.size.width, 40 ),
secondAddendVisibleProperty: null,
baseColor: Color.WHITE
Expand Down
54 changes: 54 additions & 0 deletions number-pairs-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,59 @@
},
"automaticallyHearPhraseDescription": {
"value": "Hear the phrase update automatically as you interact."
},
"hearNumberSentence": {
"value": "Hear Number Sentence"
},
"organizeObjects": {
"value": "Organize Objects"
},
"organizeObjectsHelpText": {
"value": "Organizes objects into groups of five."
},
"swapAddends": {
"value": "Swap Addends"
},
"makesAreaVisible": {
"value": "Makes area visible."
},
"firstAddendNoJump": {
"value": "First Addend No Jump"
},
"firstAddendJump": {
"value": "First Addend Jump"
},
"sceneSelectionRadioButtonGroup": {
"value": "Scene Selection Radio Button Group"
},
"apples": {
"value": "Apples"
},
"soccerBalls": {
"value": "Soccer Balls"
},
"butterflies": {
"value": "Butterflies"
},
"oneCards": {
"value": "One Cards"
},
"kittens": {
"value": "Kittens"
},
"beads": {
"value": "Beads"
},
"numberLine": {
"value": "Number Line"
},
"representationType": {
"value": "Representation Type"
},
"locationCountingObjects": {
"value": "Location Counting Objects"
},
"numberLineSlider": {
"value": "Number Line Slider"
}
}

0 comments on commit 2acceb0

Please sign in to comment.