@@ -3,9 +3,11 @@ import { Portal } from 'react-portal';
33
44import { Close } from './Icon' ;
55import { useAppDispatch , useAppSelector } from './hooks' ;
6- import { seenRustSurvey2023 } from './reducers/notifications' ;
6+ import { swapTheme } from './reducers/configuration' ;
7+ import { seenDarkMode , seenRustSurvey2023 } from './reducers/notifications' ;
78import { allowLongRun , wsExecuteKillCurrent } from './reducers/output/execute' ;
89import * as selectors from './selectors' ;
10+ import { Theme } from './types' ;
911
1012import * as styles from './Notifications.module.css' ;
1113
@@ -15,13 +17,63 @@ const Notifications: React.FC = () => {
1517 return (
1618 < Portal >
1719 < div className = { styles . container } >
20+ < DarkModeNotification />
1821 < RustSurvey2023Notification />
1922 < ExcessiveExecutionNotification />
2023 </ div >
2124 </ Portal >
2225 ) ;
2326} ;
2427
28+ const DarkModeNotification : React . FC = ( ) => {
29+ const showIt = useAppSelector ( selectors . showDarkModeSelector ) ;
30+
31+ const dispatch = useAppDispatch ( ) ;
32+ const seenIt = useCallback ( ( ) => dispatch ( seenDarkMode ( ) ) , [ dispatch ] ) ;
33+ const swapToLight = useCallback ( ( ) => dispatch ( swapTheme ( Theme . Light ) ) , [ dispatch ] ) ;
34+ const swapToDark = useCallback ( ( ) => dispatch ( swapTheme ( Theme . Dark ) ) , [ dispatch ] ) ;
35+ const swapToSystem = useCallback ( ( ) => dispatch ( swapTheme ( Theme . System ) ) , [ dispatch ] ) ;
36+
37+ return showIt ? (
38+ < Notification onClose = { seenIt } >
39+ < p > The playground now has a dark mode! Sample the themes here:</ p >
40+
41+ < table >
42+ < tr >
43+ < th >
44+ < button className = { styles . swapTheme } onClick = { swapToSystem } >
45+ System
46+ </ button >
47+ </ th >
48+ < td > Use your system's preference</ td >
49+ </ tr >
50+
51+ < tr >
52+ < th >
53+ < button className = { styles . swapTheme } onClick = { swapToLight } >
54+ Light
55+ </ button >
56+ </ th >
57+ < td > The classic playground style</ td >
58+ </ tr >
59+
60+ < tr >
61+ < th >
62+ < button className = { styles . swapTheme } onClick = { swapToDark } >
63+ Dark
64+ </ button >
65+ </ th >
66+ < td > Reduce the number of photons hitting your eyeballs</ td >
67+ </ tr >
68+ </ table >
69+
70+ < p >
71+ You can change the current UI theme (and the editor's theme) in the configuration menu.
72+ </ p >
73+ </ Notification >
74+ ) : null ;
75+ } ;
76+
2577const RustSurvey2023Notification : React . FC = ( ) => {
2678 const showIt = useAppSelector ( selectors . showRustSurvey2023Selector ) ;
2779
0 commit comments