1- const Preferences = require ( 'compass-preferences-model' ) ;
1+ const { THEMES } = require ( 'compass-preferences-model' ) ;
22const { Theme } = require ( '@mongodb-js/compass-components' ) ;
33const ipc = require ( 'hadron-ipc' ) ;
44const darkreader = require ( 'darkreader' ) ;
5-
6- const { THEMES } = Preferences ;
5+ const { remote } = require ( 'electron' ) ;
76
87const darkreaderOptions = { brightness : 100 , contrast : 90 , sepia : 10 } ;
9- export function enableDarkTheme ( ) {
8+
9+ function enableDarkTheme ( ) {
1010 // Compass-home initializes the theme and listens to these events
1111 // to update the theme in the react context.
1212 global . hadronApp . theme = Theme . Dark ;
@@ -15,19 +15,19 @@ export function enableDarkTheme() {
1515 darkreader . enable ( darkreaderOptions ) ;
1616}
1717
18- export function disableDarkTheme ( ) {
18+ function disableDarkTheme ( ) {
1919 global . hadronApp . theme = Theme . Light ;
2020 global . hadronApp . appRegistry ?. emit ( 'darkmode-disable' ) ;
2121
2222 darkreader . disable ( ) ;
2323}
2424
25- export function loadTheme ( theme ) {
25+ function loadTheme ( theme ) {
2626 // Update main Compass when we've loaded the theme for setting app menus.
2727 ipc . call ( 'window:theme-loaded' , theme ) ;
2828
2929 if ( theme === THEMES . OS_THEME
30- && electron . remote . nativeTheme . shouldUseDarkColors
30+ && remote . nativeTheme . shouldUseDarkColors
3131 ) {
3232 enableDarkTheme ( ) ;
3333 return ;
@@ -41,3 +41,9 @@ export function loadTheme(theme) {
4141
4242 disableDarkTheme ( ) ;
4343}
44+
45+ module . exports = {
46+ enableDarkTheme,
47+ disableDarkTheme,
48+ loadTheme
49+ }
0 commit comments