@@ -2,8 +2,10 @@ import * as React from 'react';
2
2
import { NavLink , useLocation } from 'react-router-dom' ;
3
3
import {
4
4
Button ,
5
+ Icon ,
5
6
Masthead ,
6
7
MastheadBrand ,
8
+ MastheadContent ,
7
9
MastheadMain ,
8
10
MastheadToggle ,
9
11
Nav ,
@@ -13,17 +15,30 @@ import {
13
15
Page ,
14
16
PageSidebar ,
15
17
PageSidebarBody ,
16
- SkipToContent
18
+ SkipToContent ,
19
+ ToggleGroup ,
20
+ ToggleGroupItem ,
21
+ Toolbar ,
22
+ ToolbarContent ,
23
+ ToolbarItem
17
24
} from '@patternfly/react-core' ;
18
25
import { IAppRoute , IAppRouteGroup , routes } from '@app/routes' ;
19
- import { BarsIcon } from '@patternfly/react-icons' ;
26
+ import { BarsIcon , MoonIcon , SunIcon } from '@patternfly/react-icons' ;
20
27
21
28
interface IAppLayout {
22
29
children : React . ReactNode ;
23
30
}
24
31
25
32
const AppLayout : React . FunctionComponent < IAppLayout > = ( { children } ) => {
26
33
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
+
27
42
const Header = (
28
43
< Masthead >
29
44
< MastheadToggle >
@@ -63,6 +78,18 @@ const AppLayout: React.FunctionComponent<IAppLayout> = ({ children }) => {
63
78
</ svg >
64
79
</ MastheadBrand >
65
80
</ 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 >
66
93
</ Masthead >
67
94
) ;
68
95
0 commit comments