@douglasneuroinformatics/libui 2.4.1 → 2.4.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9B,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAE1C,eAAe;AACf,QAAA,MAAM,aAAa,EAAE,KAAe,CAAC;AAErC,eAAe;AACf,QAAA,MAAM,eAAe,cAAc,CAAC;AAEpC,eAAe;AACf,QAAA,MAAM,SAAS,UAAU,CAAC;AAE1B,eAAe;AACf,QAAA,MAAM,oBAAoB,iCAAiC,CAAC;AAE5D;;;;;GAKG;AACH,iBAAS,QAAQ,IAAI,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9B,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAE1C,eAAe;AACf,QAAA,MAAM,aAAa,EAAE,KAAe,CAAC;AAErC,eAAe;AACf,QAAA,MAAM,eAAe,cAAc,CAAC;AAEpC,eAAe;AACf,QAAA,MAAM,SAAS,UAAU,CAAC;AAE1B,eAAe;AACf,QAAA,MAAM,oBAAoB,iCAAiC,CAAC;AAE5D;;;;;GAKG;AACH,iBAAS,QAAQ,IAAI,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,CA2CjD;AAED,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/hooks/useTheme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
import { isBrowser } from '../utils.js';
|
|
3
3
|
/** @private */
|
|
4
4
|
const DEFAULT_THEME = 'light';
|
|
@@ -52,9 +52,9 @@ function useTheme() {
|
|
|
52
52
|
return () => observer.disconnect();
|
|
53
53
|
}, []);
|
|
54
54
|
// When the user wants to change the theme
|
|
55
|
-
const updateTheme =
|
|
55
|
+
const updateTheme = (theme) => {
|
|
56
56
|
document.documentElement.setAttribute(THEME_ATTRIBUTE, theme);
|
|
57
|
-
}
|
|
57
|
+
};
|
|
58
58
|
return [theme, updateTheme];
|
|
59
59
|
}
|
|
60
60
|
export { DEFAULT_THEME, SYS_DARK_MEDIA_QUERY, THEME_ATTRIBUTE, THEME_KEY, useTheme };
|
package/package.json
CHANGED
package/src/hooks/useTheme.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { isBrowser } from '../utils.js';
|
|
4
4
|
|
|
@@ -62,12 +62,9 @@ function useTheme(): readonly [Theme, UpdateTheme] {
|
|
|
62
62
|
}, []);
|
|
63
63
|
|
|
64
64
|
// When the user wants to change the theme
|
|
65
|
-
const updateTheme =
|
|
66
|
-
(theme
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
[document.documentElement]
|
|
70
|
-
);
|
|
65
|
+
const updateTheme = (theme: Theme) => {
|
|
66
|
+
document.documentElement.setAttribute(THEME_ATTRIBUTE, theme);
|
|
67
|
+
};
|
|
71
68
|
|
|
72
69
|
return [theme, updateTheme] as const;
|
|
73
70
|
}
|