From b93be5a846d9368db999fd37f10db5d9c339cab0 Mon Sep 17 00:00:00 2001 From: Nash Date: Wed, 9 Nov 2022 20:25:30 +0300 Subject: [PATCH] Set default theme to the user's browser theme (#69) --- packages/bruno-app/src/providers/Theme/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/bruno-app/src/providers/Theme/index.js b/packages/bruno-app/src/providers/Theme/index.js index e46f6a451..19c539a7f 100644 --- a/packages/bruno-app/src/providers/Theme/index.js +++ b/packages/bruno-app/src/providers/Theme/index.js @@ -6,7 +6,8 @@ import { ThemeProvider as SCThemeProvider } from 'styled-components'; export const ThemeContext = createContext(); export const ThemeProvider = (props) => { - const [storedTheme, setStoredTheme] = useLocalStorage('bruno.theme', 'light'); + const isBrowserThemeLight = window.matchMedia("(prefers-color-scheme: light)").matches; + const [storedTheme, setStoredTheme] = useLocalStorage('bruno.theme', isBrowserThemeLight ? 'light' : 'dark'); const theme = themes[storedTheme]; const themeOptions = Object.keys(themes);