Skip to content

Commit

Permalink
TypeScript conversion for Panel, ComboBox (and assorted types), see p…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Mar 5, 2022
1 parent bee69f3 commit 4328f46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions js/create/view/TickMarkRangeComboBoxNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ import TickMarkView from '../../common/view/TickMarkView.js';
import ratioAndProportion from '../../ratioAndProportion.js';
import ratioAndProportionStrings from '../../ratioAndProportionStrings.js';
import EnumerationProperty from '../../../../axon/js/EnumerationProperty.js';
import IProperty from '../../../../axon/js/IProperty.js';
import Property from '../../../../axon/js/Property.js';

const TICK_MARK_RANGE_FONT = new PhetFont( 16 );
const RANGE_TEXT_OPTIONS = { font: TICK_MARK_RANGE_FONT };

class TickMarkRangeComboBoxNode extends Node {

private enabledComboBox: ComboBox;
private disabledComboBox: ComboBox;
private enabledComboBox: ComboBox<number>;
private disabledComboBox: ComboBox<true | number>;
private tickMarkRangeMap: Record<number, string>;
private tickMarkRangeProperty: IProperty<number>
private tickMarkRangeProperty: Property<number>

constructor( tickMarkRangeProperty: IProperty<number>, comboBoxParent: Node,
constructor( tickMarkRangeProperty: Property<number>, comboBoxParent: Node,
tickMarkViewProperty: EnumerationProperty<TickMarkView> ) {
super();

Expand Down Expand Up @@ -78,10 +78,11 @@ class TickMarkRangeComboBoxNode extends Node {

const value = true;

this.disabledComboBox = new ComboBox( [
// NOTE: The values are [ 10, true ]... so it's typed interestingly.
this.disabledComboBox = new ComboBox<true | number>( [
new ComboBoxItem( new HSeparator( widestItem, { centerY: -5 } ), value, { a11yLabel: ratioAndProportionStrings.a11y.tickMark.tickMarksHidden } ),
items[ 0 ] // add this one to get the proper height of the text.
], new BooleanProperty( value ), new Node(), comboBoxOptions );
], new BooleanProperty( value ) as Property<true | number>, new Node(), comboBoxOptions );

// always disabled
this.disabledComboBox.enabledProperty.value = false;
Expand Down
2 changes: 1 addition & 1 deletion js/discover/view/ChallengeComboBoxItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ratioAndProportion from '../../ratioAndProportion.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
import Property from '../../../../axon/js/Property.js';

class ChallengeComboBoxItem extends ComboBoxItem {
class ChallengeComboBoxItem extends ComboBoxItem<number> {

constructor( text: string, color: Color | string, value: number, valueProperty: NumberProperty,
colorProperty: Property<Color | string>, options?: any ) {
Expand Down
2 changes: 1 addition & 1 deletion js/discover/view/ChallengeRatioComboBoxNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ChallengeRatioComboBoxNode extends Node {

// Used to get the names of challenges based on the target ratio, NOTE: lowercase strings are only available in the PDOM (not yet i18n)
readonly ratioToChallengeNameMap: Map<number, { capitalized: string, lowercase: string }>;
private comboBox: ComboBox;
private comboBox: ComboBox<number>;

/**
* @param targetRatioProperty
Expand Down

0 comments on commit 4328f46

Please sign in to comment.