Skip to content

Commit

Permalink
Rename NumberSentenceAccordionBox to NumberPhraseAccordionBox and upd…
Browse files Browse the repository at this point in the history
…ate accessibleName/HelpText, see: #78
  • Loading branch information
marlitas committed Feb 6, 2025
1 parent 551487e commit 670dd9a
Show file tree
Hide file tree
Showing 17 changed files with 171 additions and 124 deletions.
29 changes: 18 additions & 11 deletions js/NumberPairsStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ type StringsType = {
'sumStringProperty': LocalizedStringProperty;
'gameStringProperty': LocalizedStringProperty;
};
'numberSentenceStringProperty': LocalizedStringProperty;
'numberPhraseStringProperty': LocalizedStringProperty;
'numberPhraseHelpTextStringProperty': LocalizedStringProperty;
'numberBondStringProperty': LocalizedStringProperty;
'barModelStringProperty': LocalizedStringProperty;
'equationStringProperty': LocalizedStringProperty;
'decompositionNumberSentencePatternStringProperty': LocalizedStringProperty;
'decompositionNumberPhrasePatternStringProperty': LocalizedStringProperty;
'decompositionNumberPhraseSpeechPatternStringProperty': LocalizedStringProperty;
'sumNumberSentencePatternStringProperty': LocalizedStringProperty;
'sumNumberPhrasePatternStringProperty': LocalizedStringProperty;
'sumNumberPhraseSpeechPatternStringProperty': LocalizedStringProperty;
'aNumberStringProperty': LocalizedStringProperty;
'someNumberStringProperty': LocalizedStringProperty;
Expand All @@ -38,24 +40,29 @@ type StringsType = {
'totalStringProperty': LocalizedStringProperty;
'automaticallyHearPhraseStringProperty': LocalizedStringProperty;
'automaticallyHearPhraseDescriptionStringProperty': LocalizedStringProperty;
'hearNumberSentenceStringProperty': LocalizedStringProperty;
'organizeObjectsStringProperty': LocalizedStringProperty;
'organizeObjectsHelpTextStringProperty': LocalizedStringProperty;
'hearNumberPhraseStringProperty': LocalizedStringProperty;
'organizeObjectsPatternStringProperty': LocalizedStringProperty;
'organizeObjectsHelpTextPatternStringProperty': LocalizedStringProperty;
'swapAddendsStringProperty': LocalizedStringProperty;
'makesAreaVisibleStringProperty': LocalizedStringProperty;
'firstAddendNoJumpStringProperty': LocalizedStringProperty;
'firstAddendJumpStringProperty': LocalizedStringProperty;
'sceneSelectionRadioButtonGroupStringProperty': LocalizedStringProperty;
'showOrHideAddendStringProperty': LocalizedStringProperty;
'showOrHideAddendsStringProperty': LocalizedStringProperty;
'totalNumberPatternStringProperty': LocalizedStringProperty;
'chooseTotalHelpTextStringProperty': LocalizedStringProperty;
'applesStringProperty': LocalizedStringProperty;
'soccerBallsStringProperty': LocalizedStringProperty;
'butterfliesStringProperty': LocalizedStringProperty;
'oneCardsStringProperty': LocalizedStringProperty;
'onesStringProperty': LocalizedStringProperty;
'kittensStringProperty': LocalizedStringProperty;
'beadsStringProperty': LocalizedStringProperty;
'beadsOnAWireStringProperty': LocalizedStringProperty;
'numberLineStringProperty': LocalizedStringProperty;
'representationTypeStringProperty': LocalizedStringProperty;
'representationTypeHelpTextStringProperty': LocalizedStringProperty;
'locationCountingObjectsStringProperty': LocalizedStringProperty;
'numberLineSliderStringProperty': LocalizedStringProperty;
'countOnStringProperty': LocalizedStringProperty;
'countFromZeroStringProperty': LocalizedStringProperty;
'totalCheckboxHelpTextStringProperty': LocalizedStringProperty;
};

const NumberPairsStrings = getStringModule( 'NUMBER_PAIRS' ) as StringsType;
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/RepresentationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class RepresentationType extends EnumerationValue {
);
public static readonly ONE_CARDS = new RepresentationType(
'oneCards',
NumberPairsStrings.oneCardsStringProperty,
NumberPairsStrings.onesStringProperty,
NumberPairsColors.locationSumColorProperty,
NumberPairsColors.locationLeftAddendColorProperty,
NumberPairsColors.locationRightAddendColorProperty,
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/BeadsOnWireNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Vector2Property from '../../../../dot/js/Vector2Property.js';
import BeadManager from '../model/BeadManager.js';
import isResettingAllProperty from '../../../../scenery-phet/js/isResettingAllProperty.js';
import isSettingPhetioStateProperty from '../../../../tandem/js/isSettingPhetioStateProperty.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';

const BEAD_WIDTH = BeadManager.BEAD_WIDTH;
const WIRE_HEIGHT = 4;
Expand Down Expand Up @@ -96,7 +97,7 @@ export default class BeadsOnWireNode extends Node {
const options = optionize<BeadsOnWireNodeOptions, SelfOptions, NodeOptions>()( {
children: [ wire, beadSeparator ],
excludeInvisibleChildrenFromBounds: true,
accessibleName: 'Beads On a Wire'
accessibleName: NumberPairsStrings.beadsOnAWireStringProperty
}, providedOptions );

super( options );
Expand Down
2 changes: 2 additions & 0 deletions js/common/view/CountingAreaNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Animation from '../../../../twixt/js/Animation.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
import NumberPairsModel from '../model/NumberPairsModel.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';

type SelfOptions = {
backgroundColorProperty: TReadOnlyProperty<TColor>;
Expand Down Expand Up @@ -83,6 +84,7 @@ export default class CountingAreaNode extends Node {
} );

const showHideBothAddendsButton = new ShowHideAddendButton( leftAddendVisibleProperty, {
accessibleName: NumberPairsStrings.showOrHideAddendsStringProperty,
left: COUNTING_AREA_BOUNDS.minX + COUNTING_AREA_MARGIN,
bottom: COUNTING_AREA_BOUNDS.maxY - COUNTING_AREA_MARGIN,
secondAddendVisibleProperty: rightAddendVisibleProperty,
Expand Down
4 changes: 2 additions & 2 deletions js/common/view/EquationAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import NumberPairsConstants from '../NumberPairsConstants.js';
import NumberRectangle from './NumberRectangle.js';
import TotalRepresentationAccordionBox, { TotalRepresentationAccordionBoxOptions } from './TotalRepresentationAccordionBox.js';
import Dimension2 from '../../../../dot/js/Dimension2.js';
import NumberSentenceAccordionBox from './NumberSentenceAccordionBox.js';
import NumberPhraseAccordionBox from './NumberPhraseAccordionBox.js';

type SelfOptions = {
addendsOnRight?: boolean;
Expand All @@ -38,7 +38,7 @@ export default class EquationAccordionBox extends TotalRepresentationAccordionBo
addendsOnRight: true,
titleNode: titleNode,
contentYMargin: 18,
minWidth: NumberSentenceAccordionBox.MIN_WIDTH, // Match the minWidth of the NumberSentenceAccordionBox
minWidth: NumberPhraseAccordionBox.MIN_WIDTH, // Match the minWidth of the NumberPhraseAccordionBox
expandedDefaultValue: false
}, providedOptions );

Expand Down
8 changes: 6 additions & 2 deletions js/common/view/NumberBondAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import optionize, { combineOptions } from '../../../../phet-core/js/optionize.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import { Text, Node } from '../../../../scenery/js/imports.js';
import { Node, Text } from '../../../../scenery/js/imports.js';
import numberPairs from '../../numberPairs.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';
import NumberPairsModel from '../model/NumberPairsModel.js';
Expand All @@ -30,7 +30,11 @@ type NumberBondAccordionBoxOptions = SelfOptions & StrictOmit<TotalRepresentatio
export default class NumberBondAccordionBox extends TotalRepresentationAccordionBox {

public constructor( model: NumberPairsModel, providedOptions: NumberBondAccordionBoxOptions ) {
const titleNode = new Text( NumberPairsStrings.numberBondStringProperty, NumberPairsConstants.ACCORDION_BOX_TITLE_OPTIONS );
const accordionBoxTitleStringProperty = new DerivedProperty( [ NumberPairsConstants.NUMBER_MODEL_TYPE_PROPERTY, NumberPairsStrings.numberBondStringProperty, NumberPairsStrings.barModelStringProperty ],
( numberModelType, numberBondString, barModelString ) => {
return numberModelType === NumberModelType.NUMBER_BOND_MODEL ? numberBondString : barModelString;
} );
const titleNode = new Text( accordionBoxTitleStringProperty, NumberPairsConstants.ACCORDION_BOX_TITLE_OPTIONS );
const options = optionize<NumberBondAccordionBoxOptions, SelfOptions, TotalRepresentationAccordionBoxOptions>()( {
numberBondNodeOptions: {},
titleNode: titleNode,
Expand Down
32 changes: 20 additions & 12 deletions js/common/view/NumberPairsScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ import LocaleSwitch from '../../../../number-suite-common/js/common/view/LocaleS
import NumberPairsPreferences from '../model/NumberPairsPreferences.js';
import { NumberPairsUtils } from '../model/NumberPairsUtils.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';
import PatternStringProperty from '../../../../axon/js/PatternStringProperty.js';

type SelfOptions = {
numberSentenceContent: Node;
numberPhraseContent: Node;
numberBondContent: Node;
equationContent?: Node | null;
sceneRange?: Range | null;
Expand Down Expand Up @@ -82,12 +83,12 @@ export default class NumberPairsScreenView extends ScreenView {
/**
* Set the layout of the accordion boxes along the top of each screen.
*/
const numberSentenceVBox = new VBox( {
children: [ options.numberSentenceContent ],
const numberPhraseVBox = new VBox( {
children: [ options.numberPhraseContent ],
spacing: 5,
align: 'left'
} );
const numberSentenceAlignBox = new AlignBox( numberSentenceVBox, {
const numberPhraseAlignBox = new AlignBox( numberPhraseVBox, {
alignBounds: this.layoutBounds,
yMargin: NumberPairsConstants.SCREEN_VIEW_Y_MARGIN,
xMargin: NumberPairsConstants.COUNTING_AREA_X_MARGIN,
Expand All @@ -101,7 +102,7 @@ export default class NumberPairsScreenView extends ScreenView {
yAlign: 'top',
xAlign: 'center'
} );
this.addChild( numberSentenceAlignBox );
this.addChild( numberPhraseAlignBox );
this.addChild( numberBondAlignBox );

if ( options.equationContent ) {
Expand Down Expand Up @@ -132,7 +133,8 @@ export default class NumberPairsScreenView extends ScreenView {
*/
const speechSynthesisControl = new SpeechSynthesisControl( numberPairsSpeechSynthesisAnnouncer, numberPairsUtteranceQueue, {
speechSynthesisButtonOptions: {
accessibleName: NumberPairsStrings.hearNumberSentenceStringProperty
accessibleName: NumberPairsStrings.hearNumberPhraseStringProperty,
helpText: NumberPairsStrings.numberPhraseHelpTextStringProperty
},
x: this.layoutBounds.minX + NumberPairsConstants.SCREEN_VIEW_X_MARGIN,
y: this.layoutBounds.minY + NumberPairsConstants.SCREEN_VIEW_Y_MARGIN,
Expand All @@ -142,7 +144,7 @@ export default class NumberPairsScreenView extends ScreenView {
const localeSwitch = new LocaleSwitch( NumberPairsPreferences, numberPairsUtteranceQueue, 300, {
tandem: options.tandem.createTandem( 'localeSwitch' )
} );
numberSentenceVBox.addChild( localeSwitch );
numberPhraseVBox.addChild( localeSwitch );

const tenFrameButtonVisibleProperty = new DerivedProperty( [ model.representationTypeProperty ],
countingRepresentation => countingRepresentation === RepresentationType.APPLES ||
Expand All @@ -156,9 +158,15 @@ export default class NumberPairsScreenView extends ScreenView {
// we have access to the countingAreaBounds which are defined during construction.
const sumTenFrameBounds = COUNTING_AREA_BOUNDS.erodedX( COUNTING_AREA_BOUNDS.width / 3.5 );
const tenFrameBounds = options.sumScreen ? [ sumTenFrameBounds ] : NumberPairsUtils.splitBoundsInHalf( COUNTING_AREA_BOUNDS );
const organizeObjectsPatternStringProperty = new PatternStringProperty( NumberPairsStrings.organizeObjectsPatternStringProperty, {
representation: model.representationTypeProperty.value.accessibleName
} );
const organizeObjectsHelpTextPatternStringProperty = new PatternStringProperty( NumberPairsStrings.organizeObjectsHelpTextPatternStringProperty, {
representation: model.representationTypeProperty.value.accessibleName
} );
const tenFrameButton = new TenFrameButton( {
accessibleName: NumberPairsStrings.organizeObjectsStringProperty,
helpText: NumberPairsStrings.organizeObjectsHelpTextStringProperty,
accessibleName: organizeObjectsPatternStringProperty,
helpText: organizeObjectsHelpTextPatternStringProperty,
tandem: options.tandem.createTandem( 'tenFrameButton' ),
listener: () => {
this.interruptSubtreeInput();
Expand Down Expand Up @@ -301,8 +309,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,
valueAAccessibleName: NumberPairsStrings.countOnStringProperty,
valueBAccessibleName: NumberPairsStrings.countFromZeroStringProperty,
toggleSwitchOptions: {
size: new Dimension2( 36, 18 )
},
Expand Down Expand Up @@ -338,7 +346,7 @@ export default class NumberPairsScreenView extends ScreenView {
* Add in the rest of the nodes as part of the control area
*/
this.controlNodes.push( speechSynthesisControl );
this.controlNodes.push( numberSentenceVBox );
this.controlNodes.push( numberPhraseVBox );
this.controlNodes.push( options.numberBondContent );
options.equationContent && this.controlNodes.push( options.equationContent );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@ NUMBER_TO_WORD_MAP.set( 'someNumber', NumberPairsStrings.someNumberStringPropert
NUMBER_TO_WORD_MAP.set( 'anotherNumber', NumberPairsStrings.anotherNumberStringProperty );

type SelfOptions = {
numberSentenceStringProperty: LocalizedStringProperty;
numberPhraseStringProperty: LocalizedStringProperty;
numberPhraseSpeechStringProperty: LocalizedStringProperty;
speechDataProperty: TProperty<string>;
};
type NumberSentenceAccordionBoxOptions = SelfOptions & StrictOmit<TotalRepresentationAccordionBoxOptions, 'titleNode'>;
type NumberPhraseAccordionBoxOptions = SelfOptions & StrictOmit<TotalRepresentationAccordionBoxOptions, 'titleNode'>;

const LINE_WRAP = 240;
export default class NumberSentenceAccordionBox extends TotalRepresentationAccordionBox {
export default class NumberPhraseAccordionBox extends TotalRepresentationAccordionBox {

// We want the accordion box to resize in the Y direction to accommodate the RichText line wrap, however the
// width should stay the same. In order to do this we must define and control all options that contribute
// to the width of the accordion box.
public static readonly MIN_WIDTH = LINE_WRAP + 2 * TotalRepresentationAccordionBox.CONTENT_X_MARGIN + TotalRepresentationAccordionBox.EXPAND_COLLAPSE_SIDE_LENGTH + TotalRepresentationAccordionBox.BUTTON_X_MARGIN;

public constructor( model: NumberPairsModel, providedOptions: NumberSentenceAccordionBoxOptions ) {
public constructor( model: NumberPairsModel, providedOptions: NumberPhraseAccordionBoxOptions ) {

const options = optionize<NumberSentenceAccordionBoxOptions, SelfOptions, WithOptional<TotalRepresentationAccordionBoxOptions, 'titleNode'>>()( {
const options = optionize<NumberPhraseAccordionBoxOptions, SelfOptions, WithOptional<TotalRepresentationAccordionBoxOptions, 'titleNode'>>()( {
contentXMargin: 20,
contentYMargin: 20,
contentAlign: 'left',
minWidth: NumberSentenceAccordionBox.MIN_WIDTH,
minWidth: NumberPhraseAccordionBox.MIN_WIDTH,
expandedDefaultValue: false
}, providedOptions );

Expand Down Expand Up @@ -128,17 +128,17 @@ export default class NumberSentenceAccordionBox extends TotalRepresentationAccor
const rightAddendDynamicProperty = new DynamicProperty( rightAddendStringProperty );

// Create the PatternStringProperties for primary and secondary locales.
const primaryLocalePatternStringProperty = new PatternStringProperty( options.numberSentenceStringProperty, {
const primaryLocalePatternStringProperty = new PatternStringProperty( options.numberPhraseStringProperty, {
total: totalDynamicProperty,
leftAddend: leftAddendDynamicProperty,
rightAddend: rightAddendDynamicProperty
} );
const secondaryLocaleStringProperty = new DerivedProperty( [ secondLocaleStringsProperty, options.numberSentenceStringProperty ],
( secondLocaleStrings, numberSentenceString ) => {
const secondaryLocaleStringProperty = new DerivedProperty( [ secondLocaleStringsProperty, options.numberPhraseStringProperty ],
( secondLocaleStrings, numberPhraseString ) => {
const secondLocaleString = secondLocaleStrings[ options.numberPhraseSpeechStringProperty.localizedString.stringKey ];

// If the secondLocaleString is not defined, default to the primary locale string.
return secondLocaleString ? secondLocaleString : numberSentenceString;
return secondLocaleString ? secondLocaleString : numberPhraseString;
} );
const secondaryLocalePatternStringProperty = new PatternStringProperty( secondaryLocaleStringProperty, {
total: totalDynamicProperty,
Expand All @@ -148,7 +148,7 @@ export default class NumberSentenceAccordionBox extends TotalRepresentationAccor

// This is the final Property that the RichText will listen to. At this point all decisions about what locale
// to display based on translation have been filtered down.
const numberSentenceStringProperty = new DerivedProperty( [
const numberPhraseStringProperty = new DerivedProperty( [
isPrimaryLocaleProperty,
primaryLocalePatternStringProperty,
secondaryLocalePatternStringProperty
Expand All @@ -159,7 +159,7 @@ export default class NumberSentenceAccordionBox extends TotalRepresentationAccor
let totalHighlight: Rectangle;
let leftAddendHighlight: Rectangle;
let rightAddendHighlight: Rectangle;
const richText = new RichText( numberSentenceStringProperty, {
const richText = new RichText( numberPhraseStringProperty, {
lineWrap: LINE_WRAP,
leading: 10,
tags: {
Expand Down Expand Up @@ -240,10 +240,10 @@ export default class NumberSentenceAccordionBox extends TotalRepresentationAccor
rightAddendHighlight.fill = color;
} );

options.titleNode = new Text( NumberPairsStrings.numberSentenceStringProperty, NumberPairsConstants.ACCORDION_BOX_TITLE_OPTIONS );
options.titleNode = new Text( NumberPairsStrings.numberPhraseStringProperty, NumberPairsConstants.ACCORDION_BOX_TITLE_OPTIONS );

super( richText, options );
}
}

numberPairs.register( 'NumberSentenceAccordionBox', NumberSentenceAccordionBox );
numberPairs.register( 'NumberPhraseAccordionBox', NumberPhraseAccordionBox );
1 change: 1 addition & 0 deletions js/common/view/RepresentationRadioButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class RepresentationRadioButtonGroup extends RectangularRadioButt
const buttonMargin = 3;
const options = optionize<CountingRepresentationRadioButtonGroupOptions, SelfOptions, RectangularRadioButtonGroupOptions>()( {
accessibleName: NumberPairsStrings.representationTypeStringProperty,
helpText: NumberPairsStrings.representationTypeHelpTextStringProperty,
orientation: 'horizontal',
radioButtonOptions: {
baseColor: Color.WHITE,
Expand Down
7 changes: 6 additions & 1 deletion js/common/view/SceneSelectionRadioButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import RectangularRadioButtonGroup, { RectangularRadioButtonGroupOptions } from
import numberPairs from '../../numberPairs.js';
import NumberPairsScene from '../model/NumberPairsScene.js';
import NumberPairsStrings from '../../NumberPairsStrings.js';
import PatternStringProperty from '../../../../axon/js/PatternStringProperty.js';

type SelfOptions = {
sceneRange: Range;
Expand All @@ -26,8 +27,12 @@ type SceneSelectionRadioButtonGroupOptions = SelfOptions & RectangularRadioButto
export default class SceneSelectionRadioButtonGroup extends RectangularRadioButtonGroup<NumberPairsScene> {

public constructor( selectedSceneModelProperty: PhetioProperty<NumberPairsScene>, sceneModels: NumberPairsScene[], providedOptions: SceneSelectionRadioButtonGroupOptions ) {
const totalNumberPatternStringProperty = new PatternStringProperty( NumberPairsStrings.totalNumberPatternStringProperty, {
value: selectedSceneModelProperty.value.total
} );
const options = optionize<SceneSelectionRadioButtonGroupOptions, SelfOptions, RectangularRadioButtonGroupOptions>()( {
accessibleName: NumberPairsStrings.sceneSelectionRadioButtonGroupStringProperty,
accessibleName: totalNumberPatternStringProperty,
helpText: NumberPairsStrings.chooseTotalHelpTextStringProperty,
radioButtonOptions: {
size: new Dimension2( 40, 40 )
}
Expand Down
Loading

0 comments on commit 670dd9a

Please sign in to comment.