@indietabletop/appkit 0.2.2 → 0.2.3
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.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Sets document background color, reverting it to previous color on unmount.
|
|
4
|
+
*/
|
|
5
|
+
export function useDocumentBackgroundColor(bodyColor) {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const style = window.document.documentElement.style;
|
|
8
|
+
const originalColor = style.backgroundColor;
|
|
9
|
+
style.backgroundColor = bodyColor;
|
|
10
|
+
return () => {
|
|
11
|
+
style.backgroundColor = originalColor;
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the app is installed.
|
|
3
|
+
*
|
|
4
|
+
* Note that this doesn't check whether the app is installed on the device at
|
|
5
|
+
* all, only whether the currently running process is within an installed window
|
|
6
|
+
* or running within a browser.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useIsInstalled(): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether the app is installed.
|
|
4
|
+
*
|
|
5
|
+
* Note that this doesn't check whether the app is installed on the device at
|
|
6
|
+
* all, only whether the currently running process is within an installed window
|
|
7
|
+
* or running within a browser.
|
|
8
|
+
*/
|
|
9
|
+
export function useIsInstalled() {
|
|
10
|
+
// The only way to get into the Standalone display mode is to install
|
|
11
|
+
// the app, so this is a good way to check installation status.
|
|
12
|
+
return useMemo(() => window.matchMedia("(display-mode: standalone)").matches, []);
|
|
13
|
+
}
|