about summary refs log tree commit diff
path: root/bskyembed/src/color-mode.ts
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2025-03-05 17:24:59 +0000
committerGitHub <noreply@github.com>2025-03-05 09:24:59 -0800
commit2d854091b9684ab253a2c117509bf95609a975a1 (patch)
tree965f049c7d8e13e61bd1ce05737113340fb3d991 /bskyembed/src/color-mode.ts
parent01a51c327505bc84f5755be82f15a855234a2750 (diff)
downloadvoidsky-2d854091b9684ab253a2c117509bf95609a975a1.tar.zst
enhance(embed): add ability to pin color mode (#7186)
* enhance(embed): add ability to pin color mode

* fix: Move color mode dropdown to the root section

* auto -> system

* style tweaks

* default to light theme

* try and fix eslint

* fix dropdown styles on other browsers

* rm unnecessary eslintrc change

* more explicit color mode select

* make light explicit

---------

Co-authored-by: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com>
Diffstat (limited to 'bskyembed/src/color-mode.ts')
-rw-r--r--bskyembed/src/color-mode.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/bskyembed/src/color-mode.ts b/bskyembed/src/color-mode.ts
index 2b392c617..b34624e31 100644
--- a/bskyembed/src/color-mode.ts
+++ b/bskyembed/src/color-mode.ts
@@ -1,9 +1,15 @@
+export type ColorModeValues = 'system' | 'light' | 'dark'
+
+export function assertColorModeValues(value: string): value is ColorModeValues {
+  return ['system', 'light', 'dark'].includes(value)
+}
+
 export function applyTheme(theme: 'light' | 'dark') {
   document.documentElement.classList.remove('light', 'dark')
   document.documentElement.classList.add(theme)
 }
 
-export function initColorMode() {
+export function initSystemColorMode() {
   applyTheme(
     window.matchMedia('(prefers-color-scheme: dark)').matches
       ? 'dark'