@bsthun/tailwindcss-instant-dark-mode 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsthun/tailwindcss-instant-dark-mode",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A tailwind plugin that make a class to instant apply both light and dark variants of a color automatically.",
5
5
  "repository": {
6
6
  "type": "git",
package/util/instant.ts CHANGED
@@ -4,8 +4,8 @@ export type tailwindInstantDarkModeConfig = {
4
4
  colorMap: Record<string, string> | null
5
5
  }
6
6
 
7
- export const tailwindcssInstantDarkMode = (config?: tailwindInstantDarkModeConfig) => {=
8
- const getDarkEquivalent = (color: string) => {=
7
+ export const tailwindcssInstantDarkMode = (config?: tailwindInstantDarkModeConfig) => {
8
+ const getDarkEquivalent = (color: string) => {
9
9
  if (!config)
10
10
  config = {
11
11
  colorMap: null,
@@ -1,6 +1,3 @@
1
- const userPref = localStorage.getItem('theme')
2
- const systemPref = window.matchMedia('(prefers-color-scheme: dark)').matches
3
-
4
1
  const apply = (isDark: boolean) => {
5
2
  const root = document.documentElement
6
3
  if (isDark) {
@@ -11,6 +8,9 @@ const apply = (isDark: boolean) => {
11
8
  }
12
9
 
13
10
  const initDarkMode = () => {
11
+ const userPref = localStorage.getItem('theme')
12
+ const systemPref = window.matchMedia('(prefers-color-scheme: dark)').matches
13
+
14
14
  if (userPref === 'dark') {
15
15
  apply(true)
16
16
  } else if (userPref === 'light') {