diff --git a/docs/functions/client_core_core.Core.html b/docs/functions/client_core_core.Core.html index 3f895167..1d502db6 100644 --- a/docs/functions/client_core_core.Core.html +++ b/docs/functions/client_core_core.Core.html @@ -9,4 +9,4 @@
export const Core = ({ t, nonce, k = "o" }: CoreProps) => {
// handle client side exceptions when script is not run. <- for client side apps like vite or CRA
if (typeof window !== "undefined" && !window.m) noFOUCScript(k);

const [{ m: mode, s: systemMode }, setThemeState] = useStore();

useEffect(() => {
// store global functions to local variables to avoid any interference
[media, updateDOM] = [m, u];
/** Updating media: prefers-color-scheme*/
media.addEventListener("change", () =>
setThemeState(state => ({ ...state, s: media.matches ? DARK : LIGHT })),
);
/** Sync the tabs */
addEventListener("storage", (e: StorageEvent): void => {
e.key === k && setThemeState(state => ({ ...state, m: e.newValue as ColorSchemePreference }));
});
}, []);

useEffect(() => {
const restoreTransitions = modifyTransition(t, nonce);
updateDOM(mode, systemMode);
restoreTransitions();
}, [systemMode, mode, t, nonce]);

return <Script {...{ n: nonce, k }} />;
};
-
+
diff --git a/docs/functions/client_core_no-fouc.noFOUCScript.html b/docs/functions/client_core_no-fouc.noFOUCScript.html index a9b40d84..07ab0163 100644 --- a/docs/functions/client_core_no-fouc.noFOUCScript.html +++ b/docs/functions/client_core_no-fouc.noFOUCScript.html @@ -1,2 +1,2 @@ noFOUCScript | React18 Loaders

function to be injected in script tag for avoiding FOUC

-
+
diff --git a/docs/functions/client_switch_switch.Switch.html b/docs/functions/client_switch_switch.Switch.html index 7e08e0a9..884f1ac7 100644 --- a/docs/functions/client_switch_switch.Switch.html +++ b/docs/functions/client_switch_switch.Switch.html @@ -8,4 +8,4 @@
export const Switch = ({
tag: Tag = "button",
size = 24,
skipSystem,
children,
...tagProps
}: SwitchProps) => {
const [{ m, s }, setState] = useStore();
const n = modes.length - (skipSystem ? 1 : 0);
/** toggle mode */
tagProps.onClick = () =>
setState({
s,
m: modes[(modes.indexOf(m) + 1) % n],
});

const className = styles.switch;
const style = { "--size": `${size}px` };

if (!children) {
tagProps.className += " " + className;
tagProps.style = { ...tagProps.style, ...style };
}

return (
// @ts-expect-error -- too complex types
<Tag suppressHydrationWarning {...tagProps} data-testid="switch">
{/* @ts-expect-error -> we are setting the CSS variable */}
{children && <div {...{ className, style }} />}
{children}
</Tag>
);
};
-
+
diff --git a/docs/functions/hooks_use-mode.useMode.html b/docs/functions/hooks_use-mode.useMode.html index dc480713..15161c31 100644 --- a/docs/functions/hooks_use-mode.useMode.html +++ b/docs/functions/hooks_use-mode.useMode.html @@ -8,4 +8,4 @@
export const useMode = (): UseModeYeild => {
const [{ m, s }, setState] = useStore();
/** Set user preference */
return {
mode: m,
systemMode: s,
resolvedMode: (m === SYSTEM ? s : m) as ResolvedScheme,
setMode: (m: ColorSchemePreference) => setState({ s, m }),
};
};
-
+
diff --git a/docs/functions/utils.useStore.html b/docs/functions/utils.useStore.html index 2dd0557a..bfbee9ae 100644 --- a/docs/functions/utils.useStore.html +++ b/docs/functions/utils.useStore.html @@ -1,2 +1,2 @@ useStore | React18 Loaders

local abstaction of RGS to avoid multiple imports

-
+
diff --git a/docs/interfaces/client_core_core.CoreProps.html b/docs/interfaces/client_core_core.CoreProps.html index 9d8f2150..ecfb503c 100644 --- a/docs/interfaces/client_core_core.CoreProps.html +++ b/docs/interfaces/client_core_core.CoreProps.html @@ -1,16 +1,16 @@ -CoreProps | React18 Loaders
interface CoreProps {
    k?: string;
    nonce?: string;
    t?: string;
}

Properties

k? +CoreProps | React18 Loaders
interface CoreProps {
    k?: string;
    nonce?: string;
    t?: string;
}

Properties

Properties

k?: string

storageKey

'o'
 
-
nonce?: string

The nonce value for your Content Security Policy.

+
nonce?: string

The nonce value for your Content Security Policy.

''
 
-
t?: string

themeTransition: force apply CSS transition property to all the elements during theme switching. E.g., all .3s

+
t?: string

themeTransition: force apply CSS transition property to all the elements during theme switching. E.g., all .3s

'none'
 
-
+
diff --git a/docs/interfaces/client_switch_switch.SwitchProps.html b/docs/interfaces/client_switch_switch.SwitchProps.html index 7c0e66df..3d622de1 100644 --- a/docs/interfaces/client_switch_switch.SwitchProps.html +++ b/docs/interfaces/client_switch_switch.SwitchProps.html @@ -1,10 +1,10 @@ -SwitchProps | React18 Loaders
interface SwitchProps {
    size?: number;
    skipSystem?: boolean;
    tag?: "button" | "div";
}

Hierarchy

Properties

size? +SwitchProps | React18 Loaders
interface SwitchProps {
    size?: number;
    skipSystem?: boolean;
    tag?: "button" | "div";
}

Hierarchy

Properties

size?: number

Diameter of the color switch

-
skipSystem?: boolean

Skip system colorScheme while toggling

-
tag?: "button" | "div"

html tag

+
skipSystem?: boolean

Skip system colorScheme while toggling

+
tag?: "button" | "div"

html tag

'button'
 
-
+
diff --git a/docs/interfaces/hooks_use-mode.UseModeYeild.html b/docs/interfaces/hooks_use-mode.UseModeYeild.html index 0392329c..5886477d 100644 --- a/docs/interfaces/hooks_use-mode.UseModeYeild.html +++ b/docs/interfaces/hooks_use-mode.UseModeYeild.html @@ -1,5 +1,5 @@ -UseModeYeild | React18 Loaders
interface UseModeYeild {
    mode: ColorSchemePreference;
    resolvedMode: ResolvedScheme;
    setMode: (mode: ColorSchemePreference) => void;
    systemMode: ResolvedScheme;
}

Properties

mode +UseModeYeild | React18 Loaders
interface UseModeYeild {
    mode: ColorSchemePreference;
    resolvedMode: ResolvedScheme;
    setMode: (mode: ColorSchemePreference) => void;
    systemMode: ResolvedScheme;
}

Properties

resolvedMode: ResolvedScheme
setMode: (mode: ColorSchemePreference) => void
systemMode: ResolvedScheme
+

Properties

resolvedMode: ResolvedScheme
setMode: (mode: ColorSchemePreference) => void
systemMode: ResolvedScheme
diff --git a/docs/interfaces/utils.Store.html b/docs/interfaces/utils.Store.html index 6fc121cd..a7e959dd 100644 --- a/docs/interfaces/utils.Store.html +++ b/docs/interfaces/utils.Store.html @@ -1,3 +1,3 @@ -Store | React18 Loaders
interface Store {
    m: ColorSchemePreference;
    s: ResolvedScheme;
}

Properties

m +Store | React18 Loaders
interface Store {
    m: ColorSchemePreference;
    s: ResolvedScheme;
}

Properties

m s -

Properties

+

Properties

diff --git a/docs/types/utils.ColorSchemePreference.html b/docs/types/utils.ColorSchemePreference.html index 2e997ea0..010e22af 100644 --- a/docs/types/utils.ColorSchemePreference.html +++ b/docs/types/utils.ColorSchemePreference.html @@ -1 +1 @@ -ColorSchemePreference | React18 Loaders

Type Alias ColorSchemePreference

ColorSchemePreference: "system" | "dark" | ""
+ColorSchemePreference | React18 Loaders

Type Alias ColorSchemePreference

ColorSchemePreference: "system" | "dark" | ""
diff --git a/docs/types/utils.ResolvedScheme.html b/docs/types/utils.ResolvedScheme.html index 1ea1b1a7..e5c22f69 100644 --- a/docs/types/utils.ResolvedScheme.html +++ b/docs/types/utils.ResolvedScheme.html @@ -1 +1 @@ -ResolvedScheme | React18 Loaders

Type Alias ResolvedScheme

ResolvedScheme: "dark" | ""
+ResolvedScheme | React18 Loaders

Type Alias ResolvedScheme

ResolvedScheme: "dark" | ""
diff --git a/docs/variables/constants.DARK.html b/docs/variables/constants.DARK.html index 424d7904..6462206d 100644 --- a/docs/variables/constants.DARK.html +++ b/docs/variables/constants.DARK.html @@ -1 +1 @@ -DARK | React18 Loaders
DARK: ResolvedScheme = "dark"
+DARK | React18 Loaders
DARK: ResolvedScheme = "dark"
diff --git a/docs/variables/constants.LIGHT.html b/docs/variables/constants.LIGHT.html index 2058ddad..20039732 100644 --- a/docs/variables/constants.LIGHT.html +++ b/docs/variables/constants.LIGHT.html @@ -1 +1 @@ -LIGHT | React18 Loaders
LIGHT: ResolvedScheme = ""
+LIGHT | React18 Loaders
LIGHT: ResolvedScheme = ""
diff --git a/docs/variables/constants.SYSTEM.html b/docs/variables/constants.SYSTEM.html index 11acfe56..f2d9feb6 100644 --- a/docs/variables/constants.SYSTEM.html +++ b/docs/variables/constants.SYSTEM.html @@ -1 +1 @@ -SYSTEM | React18 Loaders

Variable SYSTEMConst

SYSTEM: ColorSchemePreference = "system"
+SYSTEM | React18 Loaders

Variable SYSTEMConst

SYSTEM: ColorSchemePreference = "system"
diff --git a/docs/variables/constants.modes.html b/docs/variables/constants.modes.html index 0b1df129..d419257d 100644 --- a/docs/variables/constants.modes.html +++ b/docs/variables/constants.modes.html @@ -1 +1 @@ -modes | React18 Loaders
modes: ColorSchemePreference[] = ...
+modes | React18 Loaders
modes: ColorSchemePreference[] = ...