Skip to content

Commit

Permalink
Add KeyboardHelpDialog to binder, phetsims/a11y-research#195
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kauzmann <[email protected]>
  • Loading branch information
zepumph committed Mar 13, 2024
1 parent 4596a79 commit 7c087ba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/KeyboardHelpDialog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: KeyboardHelpDialog
category: other-ui
---


## General Design Considerations

* A keyboard help dialog helps guide users with keyboard interaction.
* If an interaction comes first as an interaction in the sim, it should likely come first in the help dialog.
3 changes: 3 additions & 0 deletions js/KeyboardHelpButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class KeyboardHelpButton extends JoistButton {
backgroundColorProperty.link( backgroundColor => {
icon.image = backgroundColor.equals( Color.BLACK ) ? keyboardIcon_png : keyboardIconOnWhite_png;
} );

// support for binder documentation, stripped out in builds and only runs when ?binder is specified
assert && phet?.chipper?.queryParameters?.binder && keyboardHelpDialogCapsule.getElement();
}
}

Expand Down
9 changes: 9 additions & 0 deletions js/KeyboardHelpDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import joist from './joist.js';
import JoistStrings from './JoistStrings.js';
import { AnyScreen } from './Screen.js';
import Tandem from '../../tandem/js/Tandem.js';
import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.js';

// constants
const TITLE_MAX_WIDTH = 670;
Expand Down Expand Up @@ -111,6 +112,14 @@ export default class KeyboardHelpDialog extends Dialog {
otherNode: shortcutsTitleText,
otherElementName: PDOMPeer.PRIMARY_SIBLING
} );

// support for binder documentation, stripped out in builds and only runs when ?binder is specified
if ( assert && phet?.chipper?.queryParameters?.binder ) {
screenContentNodes.forEach( node => {
content.children = [ node ];
InstanceRegistry.registerDataURL( 'joist', 'KeyboardHelpDialog', this );
} );
}
}
}

Expand Down

0 comments on commit 7c087ba

Please sign in to comment.