Skip to content

Commit

Permalink
nested options pattern for maxWidth of labels in help content, see ph…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Jan 17, 2019
1 parent 74bd1b5 commit 6763f5b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
26 changes: 15 additions & 11 deletions js/keyboard/help/GeneralNavigationHelpContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ define( function( require ) {
var keyboardHelpDialogGroupNavigationDescriptionString = SceneryPhetA11yStrings.keyboardHelpDialogGroupNavigationDescription.value;
var keyboardHelpDialogExitDialogDescriptionString = SceneryPhetA11yStrings.keyboardHelpDialogExitDialogDescription.value;

// constants
var DEFAULT_LABEL_OPTIONS = {
font: HelpContent.DEFAULT_LABEL_FONT,
maxWidth: HelpContent.DEFAULT_TEXT_MAX_WIDTH
};

/**
* @constructor
* @param {Object} options
Expand All @@ -45,33 +51,31 @@ define( function( require ) {
withGroupContent: false, // if true, the help content will include information about how to interact with groups

verticalIconSpacing: HelpContent.DEFAULT_VERTICAL_ICON_SPACING,
labelFont: HelpContent.DEFAULT_LABEL_FONT,
labelMaxWidth: HelpContent.DEFAULT_TEXT_MAX_WIDTH

// passed to label Text
labelOptions: null
}, options );

var labelOptions = {
font: options.labelFont,
maxWidth: options.labelMaxWidth
};
options.labelOptions = _.extend( DEFAULT_LABEL_OPTIONS, options.labelOptions );

// 'move to next item' content
var moveToNextItemText = new RichText( keyboardHelpDialogMoveToNextItemString, labelOptions );
var moveToNextItemText = new RichText( keyboardHelpDialogMoveToNextItemString, options.labelOptions );
var moveToNextItemIcon = new TabKeyNode();
var moveToNextItemRow = HelpContent.labelWithIcon( moveToNextItemText, moveToNextItemIcon, keyboardHelpDialogTabDescriptionString );

// 'move to previous item' content
var moveToPreviousItemText = new RichText( keyboardHelpDialogMoveToPreviousItemString, labelOptions );
var moveToPreviousItemText = new RichText( keyboardHelpDialogMoveToPreviousItemString, options.labelOptions );
var tabIcon = new TabKeyNode();
var moveToPreviousItemIcon = HelpContent.shiftPlusIcon( tabIcon );
var moveToPreviousItemRow = HelpContent.labelWithIcon( moveToPreviousItemText, moveToPreviousItemIcon, keyboardHelpDialogShiftTabDescriptionString );

// 'press buttons' content
var pressButtonsText = new RichText( keyboardHelpDialogPressButtonsString, labelOptions );
var pressButtonsText = new RichText( keyboardHelpDialogPressButtonsString, options.labelOptions );
var spaceIcon = new SpaceKeyNode();
var pressButtonsItemRow = HelpContent.labelWithIcon( pressButtonsText, spaceIcon, keyboardHelpDialogPressButtonsDescriptionString );

// 'exit a dialog' content
var exitADialogText = new RichText( keyboardHelpDialogExitADialogString, labelOptions );
var exitADialogText = new RichText( keyboardHelpDialogExitADialogString, options.labelOptions );
var exitADialogIcon = new EscapeKeyNode();
var exitADialogRow = HelpContent.labelWithIcon( exitADialogText, exitADialogIcon, keyboardHelpDialogExitDialogDescriptionString );

Expand All @@ -83,7 +87,7 @@ define( function( require ) {
moveToNextItemText.setText( keyboardHelpDialogMoveToNextItemOrGroupString );
moveToPreviousItemText.setText( keyboardHelpDialogMoveToPreviousItemOrGroupString );

var moveBetweenItemsInAGroupText = new RichText( keyboardHelpDialogMoveBetweenItemsInAGroupString, labelOptions );
var moveBetweenItemsInAGroupText = new RichText( keyboardHelpDialogMoveBetweenItemsInAGroupString, options.labelOptions );
var leftRightArrowsIcon = HelpContent.leftRightArrowKeysRowIcon();
var upDownArrowsIcon = HelpContent.upDownArrowKeysRowIcon();
var leftRightOrUpDownIcon = HelpContent.iconOrIcon( leftRightArrowsIcon, upDownArrowsIcon );
Expand Down
17 changes: 11 additions & 6 deletions js/keyboard/help/SliderControlsHelpContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,23 @@ define( function( require ) {
headingString: keyboardHelpDialogSliderControlsString,

// icon options
verticalIconSpacing: HelpContent.DEFAULT_VERTICAL_ICON_SPACING
verticalIconSpacing: HelpContent.DEFAULT_VERTICAL_ICON_SPACING,

// options passed to the label Text
labelOptions: null
}, options );

options.labelOptions = _.extend( DEFAULT_LABEL_OPTIONS, options.labelOptions );

// 'Move sliders' content
var adjustSliderText = new RichText( keyboardHelpDialogAdjustSliderString, DEFAULT_LABEL_OPTIONS );
var adjustSliderText = new RichText( keyboardHelpDialogAdjustSliderString, options.labelOptions );
var adjustSliderLeftRightIcon = HelpContent.leftRightArrowKeysRowIcon();
var adjustSliderUpDownIcon = HelpContent.upDownArrowKeysRowIcon();
var adjustSliderIcon = HelpContent.iconOrIcon( adjustSliderLeftRightIcon, adjustSliderUpDownIcon );
var adjustSliderRow = HelpContent.labelWithIcon( adjustSliderText, adjustSliderIcon, keyboardHelpDialogAdjustDefaultStepsString );

// 'move in smaller steps' content
var adjustInSmallerStepsText = new RichText( keyboardHelpDialogAdjustInSmallerStepsString, DEFAULT_LABEL_OPTIONS );
var adjustInSmallerStepsText = new RichText( keyboardHelpDialogAdjustInSmallerStepsString, options.labelOptions );
var smallStepsLeftRightIcon = HelpContent.leftRightArrowKeysRowIcon();
var smallStepsUpDownIcon = HelpContent.upDownArrowKeysRowIcon();

Expand All @@ -74,7 +79,7 @@ define( function( require ) {
var adjustSliderInSmallerStepsRow = HelpContent.labelWithIconList( adjustInSmallerStepsText, [ shiftPlusLeftRightIcon, shiftPlusUpDownIcon ], keyboardHelpDialogAdjustSmallerStepsString );

// 'move in larger steps' content
var adjustInLargerStepsText = new RichText( keyboardHelpDialogAdjustInLargerStepsString, DEFAULT_LABEL_OPTIONS );
var adjustInLargerStepsText = new RichText( keyboardHelpDialogAdjustInLargerStepsString, options.labelOptions );
var pageUpKeyNode = new PageUpKeyNode();
var pageDownKeyNode = new PageDownKeyNode();
var pageUpPageDownIcon = new HBox( {
Expand All @@ -84,12 +89,12 @@ define( function( require ) {
var adjustInLargerStepsRow = HelpContent.labelWithIcon( adjustInLargerStepsText, pageUpPageDownIcon, keyboardHelpDialogAdjustLargerStepsString );

// 'move to minimum value' content
var jumpToMinimumText = new RichText( keyboardHelpDialogJumpToMinimumString, DEFAULT_LABEL_OPTIONS );
var jumpToMinimumText = new RichText( keyboardHelpDialogJumpToMinimumString, options.labelOptions );
var homeKeyNode = new HomeKeyNode();
var jumpToMinimumRow = HelpContent.labelWithIcon( jumpToMinimumText, homeKeyNode, keyboardHelpDialogJumpToHomeString );

// 'move to maximum value' content
var jumpToMaximumText = new RichText( keyboardHelpDialogJumpToMaximumString, DEFAULT_LABEL_OPTIONS );
var jumpToMaximumText = new RichText( keyboardHelpDialogJumpToMaximumString, options.labelOptions );
var endKeyNode = new EndKeyNode();
var jumpToMaximumRow = HelpContent.labelWithIcon( jumpToMaximumText, endKeyNode, keyboardHelpDialogJumpToEndString );

Expand Down

0 comments on commit 6763f5b

Please sign in to comment.