Skip to content

Commit

Permalink
💄 🩹 Fix dark mode logic to respect the user's system theme and update…
Browse files Browse the repository at this point in the history
… focus-visible style 🩹 💄
  • Loading branch information
Aszurar committed Jan 22, 2024
1 parent f0dbf7b commit d16a84e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/context/theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function ThemeProvider({ children }: Readonly<ThemeProviderProps>) {
const isTheSystemThemeDarkMode = systemTheme.matches // return true if the system theme is dark mode
const isTheLocalStorageThemeDarkMode = getTheme() === THEME.dark
const isDefaultThemeDarkMode =
isTheSystemThemeDarkMode || isTheLocalStorageThemeDarkMode
isTheSystemThemeDarkMode && isTheLocalStorageThemeDarkMode

const [isDarkMode, setIsDarkMode] = useState(isDefaultThemeDarkMode)

Expand Down
2 changes: 1 addition & 1 deletion src/storage/theme/getTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { APP_THEME } from '../storageConfig'
export function getTheme() {
const response = localStorage.getItem(APP_THEME)

const theme = response ? JSON.parse(response) : THEME.light
const theme = response ? JSON.parse(response) : THEME.dark

return theme as ITheme
}
2 changes: 1 addition & 1 deletion src/theme/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@layer base {
:focus-visible {
@apply ring-4 ring-purple-200 outline-none
@apply ring-4 dark:ring-purple-300 ring-purple-200 outline-none
}

::selection {
Expand Down

0 comments on commit d16a84e

Please sign in to comment.