Skip to content

Commit

Permalink
Add QuestionBar text labels, see #6
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Feb 2, 2022
1 parent 95d981e commit 8cf826c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 8 deletions.
9 changes: 9 additions & 0 deletions center-and-spread-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@
},
"screen.lab": {
"value": "Lab"
},
"medianQuestion": {
"value": "What is the typical ball distance?"
},
"meanAndMedianQuestion": {
"value": "How does each kick influence the mean and median?"
},
"spreadQuestion": {
"value": "How consistent is ball distance?"
}
}
5 changes: 4 additions & 1 deletion js/centerAndSpreadStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ type StringsType = {
'meanAndMedian': string,
'spread': string,
'lab': string
}
},
'medianQuestion': string,
'meanAndMedianQuestion': string,
'spreadQuestion': string
};

const centerAndSpreadStrings = getStringModule( 'CENTER_AND_SPREAD' ) as StringsType;
Expand Down
3 changes: 0 additions & 3 deletions js/common/CASConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
import centerAndSpread from '../centerAndSpread.js';

const CASConstants = {

SCREEN_VIEW_X_MARGIN: 15,
SCREEN_VIEW_Y_MARGIN: 15

//TODO
};

centerAndSpread.register( 'CASConstants', CASConstants );
Expand Down
20 changes: 19 additions & 1 deletion js/common/view/QuestionBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
import optionize from '../../../../phet-core/js/optionize.js';
import centerAndSpread from '../../centerAndSpread.js';
import StatusBar from '../../../../vegas/js/StatusBar.js';
import { Text } from '../../../../scenery/js/imports.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
import Property from '../../../../axon/js/Property.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import CASConstants from '../CASConstants.js';

type QuestionBarSelfOptions = {};
type QuestionBarSelfOptions = {
labelText: string
};
type StatusBarOptions = {}; // TODO: Add Options in StatusBar
export type QuestionBarOptions = QuestionBarSelfOptions & Omit<StatusBarOptions, 'floatToTop'>

Expand All @@ -25,6 +30,19 @@ class QuestionBar extends StatusBar {
floatToTop: true
}, providedOptions );
super( layoutBounds, boundsProperty, options );

const labelText = new Text( options.labelText, {
font: new PhetFont( {
weight: 'bold',
size: '18px'
} )
} );
this.addChild( labelText );

this.positioningBoundsProperty.link( bounds2 => {
labelText.centerY = bounds2.centerY;
labelText.left = CASConstants.SCREEN_VIEW_X_MARGIN;
} );
}
}

Expand Down
4 changes: 3 additions & 1 deletion js/mean-and-median/view/MeanAndMedianScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import centerAndSpread from '../../centerAndSpread.js';
import MeanAndMedianModel from '../model/MeanAndMedianModel.js';
import SoccerScreenView, { SoccerScreenViewOptions } from '../../common/view/SoccerScreenView.js';
import CASColors from '../../common/CASColors.js';
import CenterAndSpreadStrings from '../../centerAndSpreadStrings.js';

type MeanAndMedianScreenViewOptions = SoccerScreenViewOptions;

Expand All @@ -26,7 +27,8 @@ class MeanAndMedianScreenView extends SoccerScreenView {
tandem: Tandem.REQUIRED,

questionBarOptions: {
barFill: CASColors.meanAndMedianQuestionBarFillColorProperty
barFill: CASColors.meanAndMedianQuestionBarFillColorProperty,
labelText: CenterAndSpreadStrings.meanAndMedianQuestion
}
}, providedOptions );

Expand Down
4 changes: 3 additions & 1 deletion js/median/view/MedianScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import MedianModel from '../model/MedianModel.js';
import { CASScreenViewOptions } from '../../common/view/CASScreenView.js';
import SoccerScreenView from '../../common/view/SoccerScreenView.js';
import CASColors from '../../common/CASColors.js';
import CenterAndSpreadStrings from '../../centerAndSpreadStrings.js';

type MedianScreenViewOptions = CASScreenViewOptions;

Expand All @@ -27,7 +28,8 @@ class MedianScreenView extends SoccerScreenView {
tandem: Tandem.REQUIRED,

questionBarOptions: {
barFill: CASColors.medianQuestionBarFillColorProperty
barFill: CASColors.medianQuestionBarFillColorProperty,
labelText: CenterAndSpreadStrings.medianQuestion
}
}, providedOptions );

Expand Down
4 changes: 3 additions & 1 deletion js/spread/view/SpreadScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import centerAndSpread from '../../centerAndSpread.js';
import SpreadModel from '../model/SpreadModel.js';
import SoccerScreenView, { SoccerScreenViewOptions } from '../../common/view/SoccerScreenView.js';
import CASColors from '../../common/CASColors.js';
import CenterAndSpreadStrings from '../../centerAndSpreadStrings.js';

type SpreadScreenViewOptions = SoccerScreenViewOptions;

Expand All @@ -26,7 +27,8 @@ class SpreadScreenView extends SoccerScreenView {
tandem: Tandem.REQUIRED,

questionBarOptions: {
barFill: CASColors.spreadQuestionBarFillColorProperty
barFill: CASColors.spreadQuestionBarFillColorProperty,
labelText: CenterAndSpreadStrings.spreadQuestion
}
}, providedOptions );

Expand Down

0 comments on commit 8cf826c

Please sign in to comment.