Skip to content

Commit

Permalink
Add accessibleName for density, see phetsims/buoyancy#109
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed May 28, 2024
1 parent b560ef1 commit f6eead6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
18 changes: 10 additions & 8 deletions js/density/view/DensityIntroScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export default class DensityIntroScreenView extends DensityBuoyancyScreenView<De
} );

const accordionTandem = tandem.createTandem( 'densityAccordionBox' );
const accordionBoxTitleStringProperty = new DerivedProperty( [
DensityBuoyancyCommonPreferences.volumeUnitsProperty,
DensityBuoyancyCommonStrings.densityReadoutStringProperty,
DensityBuoyancyCommonStrings.densityReadoutDecimetersCubedStringProperty
], ( units, litersReadout, decimetersCubedReadout ) => {
return units === 'liters' ? litersReadout : decimetersCubedReadout;
} );
const densityAccordionBox = new AccordionBox( new DensityNumberLineNode( {
displayDensities: [
// DerivedProperty doesn't need disposal, since everything here lives for the lifetime of the simulation
Expand All @@ -76,13 +83,7 @@ export default class DensityIntroScreenView extends DensityBuoyancyScreenView<De
}
}
), combineOptions<AccordionBoxOptions>( {
titleNode: new RichText( new DerivedProperty( [
DensityBuoyancyCommonPreferences.volumeUnitsProperty,
DensityBuoyancyCommonStrings.densityReadoutStringProperty,
DensityBuoyancyCommonStrings.densityReadoutDecimetersCubedStringProperty
], ( units, litersReadout, decimetersCubedReadout ) => {
return units === 'liters' ? litersReadout : decimetersCubedReadout;
} ), {
titleNode: new RichText( accordionBoxTitleStringProperty, {
font: DensityBuoyancyCommonConstants.TITLE_FONT,
maxWidth: 200,
visiblePropertyOptions: {
Expand All @@ -91,7 +92,8 @@ export default class DensityIntroScreenView extends DensityBuoyancyScreenView<De
tandem: accordionTandem.createTandem( 'titleText' )
} ),
buttonAlign: 'left' as const,
tandem: accordionTandem
tandem: accordionTandem,
accessibleName: accordionBoxTitleStringProperty
}, DensityBuoyancyCommonConstants.ACCORDION_BOX_OPTIONS ) );

this.addChild( densityAccordionBox );
Expand Down
8 changes: 6 additions & 2 deletions js/density/view/DensityMysteryScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default class DensityMysteryScreenView extends DensityBuoyancyScreenView<
tandem: densityTableAccordionBoxTandem.createTandem( 'titleText' )
} ),
expandedDefaultValue: false,
tandem: densityTableAccordionBoxTandem
tandem: densityTableAccordionBoxTandem,
accessibleName: DensityBuoyancyCommonStrings.densityTableStringProperty
}, DensityBuoyancyCommonConstants.ACCORDION_BOX_OPTIONS ) );

this.addChild( new AlignBox( densityTableAccordionBox, {
Expand All @@ -69,7 +70,10 @@ export default class DensityMysteryScreenView extends DensityBuoyancyScreenView<
tandem: tandem.createTandem( 'labelText' )
} ),
value: blockSet,
tandemName: `${blockSet.tandemName}RadioButton`
tandemName: `${blockSet.tandemName}RadioButton`,
options: {
accessibleName: blockSet.stringProperty
}
};
} ), {
align: 'left',
Expand Down

0 comments on commit f6eead6

Please sign in to comment.