@@ -45,6 +45,8 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
4545 this . state = this . stateFromUrl ( ) ;
4646 this . hotKeyBoundActions = {
4747 'Alt F' : this . onFullScreenToggle ,
48+ 'Alt Down' : this . onNextDemo ,
49+ 'Alt Up' : this . onPrevDemo ,
4850 ...this . dropDownKeyBoundActions ( )
4951 } ;
5052 }
@@ -56,7 +58,7 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
5658 } = this . state ;
5759
5860 const registry = this . findSelectedRegistry ( ) ;
59- const demoEntry = registry ? registry . findByName ( demoName ) : null ;
61+ const demoEntry = registry ? registry . findDemoByName ( demoName ) : null ;
6062
6163 const rendered = demoEntry && ( demoEntry . isMiniApp ( ) || isFullScreen ) ?
6264 this . renderDemo ( demoEntry , true ) :
@@ -204,6 +206,31 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
204206 this . state . selectedToolbarItem ) ;
205207 }
206208
209+ private onNextDemo = ( ) => {
210+ this . withRegistryAndDemoNameWhenPresent ( ( ( registry , demoName ) => {
211+ const nextDemo = registry . findNextDemoByCurrentName ( demoName ) ;
212+ this . selectDemo ( nextDemo . name ) ;
213+ } ) ) ;
214+ }
215+
216+ private onPrevDemo = ( ) => {
217+ this . withRegistryAndDemoNameWhenPresent ( ( ( registry , demoName ) => {
218+ const prevDemo = registry . findPrevDemoByCurrentName ( demoName ) ;
219+ this . selectDemo ( prevDemo . name ) ;
220+ } ) ) ;
221+ }
222+
223+ private withRegistryAndDemoNameWhenPresent = ( code : ( registry : Registry , demoName : string ) => void ) => {
224+ const registry = this . findSelectedRegistry ( ) ;
225+ const { demoName} = this . state ;
226+
227+ if ( ! registry ) {
228+ return ;
229+ }
230+
231+ code ( registry , demoName ) ;
232+ }
233+
207234 private selectRegistry = ( registryName : string ) => {
208235 this . pushUrl (
209236 registryName ,
0 commit comments