-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add data-bs-theme attribute for user dark/light modes (#1782)
* fix: Add data-bs-theme attribute for user dark/light modes * fix: Remove unnecessary optional chain * fix: Oops -- add missing files
- Loading branch information
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import isDark from "./is-dark"; | ||
|
||
export default function dataBsTheme(user) { | ||
return (isDark() && user?.local_user_view.local_user.theme === "browser") || | ||
(user && | ||
["darkly", "darkly-red", "darkly-pureblack"].includes( | ||
user.local_user_view.local_user.theme | ||
)) | ||
? "dark" | ||
: "light"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import isBrowser from "./is-browser"; | ||
|
||
export default function isDark() { | ||
return ( | ||
isBrowser() && window.matchMedia("(prefers-color-scheme: dark)").matches | ||
); | ||
} |