Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Check user theme preference, closes #555.

Mike Cao041c7737e803
diff --git a/hooks/useTheme.js b/hooks/useTheme.js
index cc610756e..46114d436 100644
--- a/hooks/useTheme.js
+++ b/hooks/useTheme.js
@@ -5,7 +5,8 @@ import { THEME_CONFIG } from 'lib/constants';
import { useEffect } from 'react';
export default function useTheme() {
- const theme = useSelector(state => state.app.theme || getItem(THEME_CONFIG) || 'light');
+ const defaultTheme = window?.matchMedia('prefers-color-scheme: dark')?.matches ? 'dark' : 'light';
+ const theme = useSelector(state => state.app.theme || getItem(THEME_CONFIG) || defaultTheme);
const dispatch = useDispatch();
function saveTheme(value) {