55 Theme ,
66 Toolbar ,
77 Typography ,
8+ WithStyles ,
9+ withStyles ,
810} from '@material-ui/core' ;
911import { MuiThemeProvider } from '@material-ui/core/styles' ;
1012import { SvgIconProps } from '@material-ui/core/SvgIcon' ;
@@ -28,7 +30,7 @@ import { connect, createState } from './reactive';
2830import { actions , store , Viewer } from './stream-store' ;
2931import themes from './themes' ;
3032import { AuthorizationProps , HalLink , HalLinks } from './types' ;
31- import { mediaTypes , preventDefault } from './utils' ;
33+ import { mediaTypes , preventDefault } from './utils' ;
3234
3335const getSelfAlias = ( links : HalLinks ) =>
3436 Object . keys ( links )
@@ -90,41 +92,53 @@ const lightbulbs: { [key: string]: ComponentType<SvgIconProps> } = {
9092 light : LightbulbOutline ,
9193} ;
9294
95+ const heroStyle = {
96+ themeToggle : {
97+ marginLeft : 'auto' ,
98+ } ,
99+ } ;
100+ interface HeroProps {
101+ theme : Theme ;
102+ }
103+
93104const onThemeToggle = preventDefault ( ( ) => themes . actions . type . next ( void 0 ) ) ;
94105
95- const Hero = ( { theme } : { theme : Theme } ) => (
96- < AppBar position = { 'static' } >
97- < Toolbar >
98- < SqlStreamStore color = { 'action' } />
99- < Typography variant = { 'h6' } color = { 'inherit' } >
100- Sql Stream Store
101- </ Typography >
102- < IconButton onClick = { onThemeToggle } >
103- { createElement ( lightbulbs [ theme . palette . type ] ) }
104- </ IconButton >
105- </ Toolbar >
106- </ AppBar >
106+ const Hero : ComponentType < HeroProps > = withStyles ( heroStyle ) (
107+ ( { theme, classes } : HeroProps & WithStyles < typeof heroStyle > ) => (
108+ < AppBar position = { 'static' } >
109+ < Toolbar >
110+ < SqlStreamStore color = { 'action' } />
111+ < Typography variant = { 'h6' } color = { 'inherit' } >
112+ Sql Stream Store
113+ </ Typography >
114+ < IconButton
115+ onClick = { onThemeToggle }
116+ className = { classes . themeToggle }
117+ >
118+ { createElement ( lightbulbs [ theme . palette . type ] ) }
119+ </ IconButton >
120+ </ Toolbar >
121+ </ AppBar >
122+ ) ,
107123) ;
108124
109125const SqlStreamStoreBrowser : ComponentType <
110126 SqlStreamStoreBrowserState
111127> = withAuthorization ( ) (
112128 mount < SqlStreamStoreBrowserState & AuthorizationProps > ( initialNavigation ) (
113- ( { loading, theme, ...props } ) => {
114- return (
115- < MuiThemeProvider theme = { theme } >
116- < div >
117- < CssBaseline />
118- < Hero theme = { theme } />
119- < Loading open = { loading } />
120- < NavigationProvider onNavigate = { onNavigate } >
121- < Viewer { ...props } />
122- < Notifications />
123- </ NavigationProvider >
124- </ div >
125- </ MuiThemeProvider >
126- ) ;
127- } ,
129+ ( { loading, theme, ...props } ) => (
130+ < MuiThemeProvider theme = { theme } >
131+ < div >
132+ < CssBaseline />
133+ < Hero theme = { theme } />
134+ < Loading open = { loading } />
135+ < NavigationProvider onNavigate = { onNavigate } >
136+ < Viewer { ...props } />
137+ < Notifications />
138+ </ NavigationProvider >
139+ </ div >
140+ </ MuiThemeProvider >
141+ ) ,
128142 ) ,
129143) ;
130144
0 commit comments