Skip to content

Commit

Permalink
converted JS to TS, see #160
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Mar 25, 2022
1 parent 8514d4a commit 2fb3831
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
4 changes: 2 additions & 2 deletions js/demo/sim-like-components/model/SimLikeComponentsModel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2018-2022, University of Colorado Boulder

/**
* A model that exists only for the purposes of demonstrating sonification, particularly how view and model elements are
* used together to hook up sonification elements.
* SimLikeComponentsModel is a model that exists only for the purposes of demonstrating sonification, particularly how
* view and model elements are used together to hook up sonification elements.
*
* @author John Blanco
*/
Expand Down
16 changes: 7 additions & 9 deletions js/demo/ui-components/model/UIComponentsModel.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright 2018-2020, University of Colorado Boulder

// @ts-nocheck

/**
* A model that exists only for the purposes of demonstrating sonification, particularly how view and model elements are
* used together to hook up sonification elements.
* UIComponentsModel is a model that exists only for the purposes of demonstrating sonification, particularly the
* sound-related behavior of common user interface (UI) components.
*
* @author John Blanco
*/
Expand All @@ -14,25 +12,25 @@ import tambo from '../../../tambo.js';

class UIComponentsModel {

// tracks whether a reset is happening
public readonly resetInProgressProperty: BooleanProperty;

/**
* @constructor
*/
constructor() {

// @public {BooleanProperty} - tracks whether a reset is happening
this.resetInProgressProperty = new BooleanProperty( false );
}

/**
* restore initial state
* @public
*/
reset() {
public reset() {
this.resetInProgressProperty.value = true;
this.resetInProgressProperty.value = false;
}

}

tambo.register( 'UIComponentsModel', UIComponentsModel );

export default UIComponentsModel;
36 changes: 17 additions & 19 deletions js/demo/ui-components/view/UIComponentsScreenView.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright 2018-2022, University of Colorado Boulder

// @ts-nocheck

/**
* view for a screen that demonstrates views and sounds for components that interact with the model in some way
* UIComponentsScreenView is a view for a screen that demonstrates views and sounds for common User Interface
* components.
*
* @author John Blanco (PhET Interactive Simulations)
*/
Expand All @@ -27,16 +26,15 @@ import DemosScreenView from '../../../../../sun/js/demo/DemosScreenView.js';
import accordion_png from '../../../../images/accordion_png.js';
import tambo from '../../../tambo.js';
import SliderSoundTestNode from './SliderSoundTestNode.js';
import UIComponentsModel from '../model/UIComponentsModel.js';
import Bounds2 from '../../../../../dot/js/Bounds2.js';

// constants
const LABEL_FONT = new PhetFont( 20 );

class UIComponentsScreenView extends DemosScreenView {

/**
* @constructor
*/
constructor( model ) {
constructor( model: UIComponentsModel ) {

const radioButtonItems = [
{
Expand All @@ -56,14 +54,14 @@ class UIComponentsScreenView extends DemosScreenView {
const demos = [
{
label: 'PushButton',
createNode: layoutBounds => new RectangularPushButton( {
createNode: ( layoutBounds: Bounds2 ) => new RectangularPushButton( {
content: new Text( 'You\'re Pushing It.', { font: LABEL_FONT } ),
center: layoutBounds.center
} )
},
{
label: 'Checkbox',
createNode: layoutBounds => new Checkbox(
createNode: ( layoutBounds: Bounds2 ) => new Checkbox(
new Text( 'Check it Out', { font: LABEL_FONT } ),
new BooleanProperty( false ),
{
Expand All @@ -73,7 +71,7 @@ class UIComponentsScreenView extends DemosScreenView {
},
{
label: 'AquaRadioButtonGroup',
createNode: layoutBounds => new AquaRadioButtonGroup(
createNode: ( layoutBounds: Bounds2 ) => new AquaRadioButtonGroup(
new NumberProperty( 0 ),
radioButtonItems,
{
Expand All @@ -86,7 +84,7 @@ class UIComponentsScreenView extends DemosScreenView {
},
{
label: 'TimeControlNode',
createNode: layoutBounds => new TimeControlNode(
createNode: ( layoutBounds: Bounds2 ) => new TimeControlNode(
new BooleanProperty( true ),
{
center: layoutBounds.center,
Expand All @@ -98,11 +96,11 @@ class UIComponentsScreenView extends DemosScreenView {
},
{
label: 'ResetAllButton',
createNode: layoutBounds => new ResetAllButton( { center: layoutBounds.center } )
createNode: ( layoutBounds: Bounds2 ) => new ResetAllButton( { center: layoutBounds.center } )
},
{
label: 'ComboBox',
createNode: layoutBounds => new ComboBox(
createNode: ( layoutBounds: Bounds2 ) => new ComboBox(
[
new ComboBoxItem( new Text( 'Rainbows', { font: LABEL_FONT } ), 0 ),
new ComboBoxItem( new Text( 'Unicorns', { font: LABEL_FONT } ), 1 ),
Expand All @@ -115,7 +113,7 @@ class UIComponentsScreenView extends DemosScreenView {
},
{
label: 'BooleanRectangularToggleButton',
createNode: layoutBounds => new BooleanRectangularToggleButton(
createNode: ( layoutBounds: Bounds2 ) => new BooleanRectangularToggleButton(
new Text( 'Yep', { font: LABEL_FONT } ),
new Text( 'Nope', { font: LABEL_FONT } ),
new BooleanProperty( true ),
Expand All @@ -127,7 +125,7 @@ class UIComponentsScreenView extends DemosScreenView {
},
{
label: 'AccordionBox',
createNode: layoutBounds => new AccordionBox(
createNode: ( layoutBounds: Bounds2 ) => new AccordionBox(
new Image( accordion_png, { maxWidth: 200 } ),
{
titleNode: new Text( 'Accordion Box', { font: LABEL_FONT } ),
Expand All @@ -141,18 +139,18 @@ class UIComponentsScreenView extends DemosScreenView {
},
{
label: 'Sliders',
createNode: layoutBounds => new SliderSoundTestNode( LABEL_FONT, layoutBounds.center )
createNode: ( layoutBounds: Bounds2 ) => new SliderSoundTestNode( LABEL_FONT, layoutBounds.center )
},
{
label: 'NumberControl',
createNode: layoutBounds => new VBox( {
createNode: ( layoutBounds: Bounds2 ) => new VBox( {
children: [

new NumberControl( 'Basic Number Control', new NumberProperty( 0 ), new Range( 0, 10 ), { delta: 2 } ),
new NumberControl( 'How much you want?', new NumberProperty( 0 ), new Range( 0, 10 ), { delta: 2 } ),

// This is an example of a number control that has a delta value that leads to thresholds in the sound
// player that are not all equally sized. See https://github.com/phetsims/sun/issues/697.
new NumberControl( 'Asymmetric Number Control', new NumberProperty( 0 ), new Range( 0, 100 ), { delta: 22 } )
new NumberControl( 'How much you want (asymmetric)?', new NumberProperty( 0 ), new Range( 0, 100 ), { delta: 22 } )
],
spacing: 20,
center: layoutBounds.center
Expand Down

0 comments on commit 2fb3831

Please sign in to comment.