@@ -2,8 +2,10 @@ import * as React from 'react';
22import { NavLink , useLocation } from 'react-router-dom' ;
33import {
44 Button ,
5+ Icon ,
56 Masthead ,
67 MastheadBrand ,
8+ MastheadContent ,
79 MastheadMain ,
810 MastheadToggle ,
911 Nav ,
@@ -13,17 +15,30 @@ import {
1315 Page ,
1416 PageSidebar ,
1517 PageSidebarBody ,
16- SkipToContent
18+ SkipToContent ,
19+ ToggleGroup ,
20+ ToggleGroupItem ,
21+ Toolbar ,
22+ ToolbarContent ,
23+ ToolbarItem
1724} from '@patternfly/react-core' ;
1825import { IAppRoute , IAppRouteGroup , routes } from '@app/routes' ;
19- import { BarsIcon } from '@patternfly/react-icons' ;
26+ import { BarsIcon , MoonIcon , SunIcon } from '@patternfly/react-icons' ;
2027
2128interface IAppLayout {
2229 children : React . ReactNode ;
2330}
2431
2532const AppLayout : React . FunctionComponent < IAppLayout > = ( { children } ) => {
2633 const [ sidebarOpen , setSidebarOpen ] = React . useState ( true ) ;
34+ const [ isDarkTheme , setIsDarkTheme ] = React . useState ( false ) ;
35+
36+ const toggleDarkTheme = ( _evt , selected ) => {
37+ const darkThemeToggleClicked = ! selected === isDarkTheme
38+ document . querySelector ( 'html' ) . classList . toggle ( 'pf-v5-theme-dark' , darkThemeToggleClicked ) ;
39+ setIsDarkTheme ( darkThemeToggleClicked ) ;
40+ } ;
41+
2742 const Header = (
2843 < Masthead >
2944 < MastheadToggle >
@@ -63,6 +78,18 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
6378 </ svg >
6479 </ MastheadBrand >
6580 </ MastheadMain >
81+ < MastheadContent >
82+ < Toolbar >
83+ < ToolbarContent >
84+ < ToolbarItem align = { { default : 'alignRight' } } >
85+ < ToggleGroup aria-label = "Dark theme toggle group" >
86+ < ToggleGroupItem aria-label = "light theme toggle" icon = { < Icon size = "md" > < SunIcon /> </ Icon > } isSelected = { ! isDarkTheme } onChange = { toggleDarkTheme } />
87+ < ToggleGroupItem aria-label = "dark theme toggle" icon = { < Icon size = "md" > < MoonIcon /> </ Icon > } isSelected = { isDarkTheme } onChange = { toggleDarkTheme } />
88+ </ ToggleGroup >
89+ </ ToolbarItem >
90+ </ ToolbarContent >
91+ </ Toolbar >
92+ </ MastheadContent >
6693 </ Masthead >
6794 ) ;
6895
0 commit comments