@@ -5,7 +5,7 @@ import { useLocation, Link } from 'react-router-dom';
55import { notification , Input , Select , Form , Button , Affix } from 'antd' ;
66import { copyText } from 'copy-clipboard-js' ;
77import CopyOutlined from '@ant-design/icons/CopyOutlined' ;
8- import { ReloadOutlined , SearchOutlined } from '@ant-design/icons' ;
8+ import { ReloadOutlined , SearchOutlined , MoonOutlined , SunOutlined } from '@ant-design/icons' ;
99import logo from './logo.svg' ;
1010
1111const defaultMenus : MenuDataItem [ ] = [
@@ -169,9 +169,11 @@ const subMenuItemRender = (item: any, dom: React.ReactNode) => <Link to={item.pa
169169
170170interface ICustomLayoutProps {
171171 children : ReactNode ;
172+ isDark : boolean ;
173+ toggleTheme : ( ) => void ;
172174}
173175
174- const CustomLayout = ( { children } : ICustomLayoutProps ) => {
176+ const CustomLayout = ( { children, isDark , toggleTheme } : ICustomLayoutProps ) => {
175177 const location = useLocation ( ) ;
176178
177179 const [ scrollPercent , setScrollPercent ] = useState ( 0 ) ;
@@ -203,6 +205,18 @@ const CustomLayout = ({ children }: ICustomLayoutProps) => {
203205 subMenuItemRender = { subMenuItemRender }
204206 // eslint-disable-next-line
205207 menuFooterRender = { ( props ) => < CustomFooterMenu { ...props } /> }
208+ actionsRender = { ( ) => [
209+ < span key = "theme-text" style = { { fontSize : '14px' , opacity : 0.85 , marginRight : '8px' } } >
210+ { isDark ? 'Dark Mode' : 'Light Mode' }
211+ </ span > ,
212+ < Button
213+ key = "theme-button"
214+ type = "text"
215+ icon = { isDark ? < SunOutlined /> : < MoonOutlined /> }
216+ onClick = { toggleTheme }
217+ title = { isDark ? 'Switch to light mode' : 'Switch to dark mode' }
218+ /> ,
219+ ] }
206220 >
207221 < PageContainer header = { { title : true } } >
208222 < Affix offsetTop = { 0 } >
0 commit comments