Skip to content

Commit 25db39e

Browse files
committed
Update doc comments
1 parent d4f1ccf commit 25db39e

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

lib/src/client/core/core.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface CoreProps {
99
t?: string;
1010
}
1111

12+
/** Modify transition globally to avoid patched transitions */
1213
const modifyTransition = (documentMinify: Document, themeTransition = "none") => {
1314
const css = documentMinify.createElement("style");
1415
/** split by ';' to prevent CSS injection */
@@ -25,11 +26,12 @@ const modifyTransition = (documentMinify: Document, themeTransition = "none") =>
2526
};
2627

2728
/**
28-
*
29+
* The Core component wich applies classes and transitions.
30+
* Cookies are set only if corresponding ServerTarget is detected.
2931
*
3032
* @example
3133
* ```tsx
32-
* <Core />
34+
* <Core [t="background-color .3s"]/>
3335
* ```
3436
*
3537
* @source - Source code
@@ -48,7 +50,7 @@ export const Core = ({ t }: CoreProps) => {
4850

4951
setThemeState(state => ({
5052
...state,
51-
m: (localStorageMinify.getItem(COOKIE_KEY) ?? SYSTEM) as ColorSchemePreference,
53+
m: (localStorageMinify?.getItem(COOKIE_KEY) ?? SYSTEM) as ColorSchemePreference,
5254
}));
5355
/** Sync the tabs */
5456
const storageListener = (e: StorageEvent): void => {
@@ -78,7 +80,7 @@ export const Core = ({ t }: CoreProps) => {
7880
});
7981
restoreTransitions();
8082
// System mode is decided by current system state and need not be stored in localStorage
81-
localStorageMinify.setItem(COOKIE_KEY, mode);
83+
localStorageMinify?.setItem(COOKIE_KEY, mode);
8284
if (serverTargetEl)
8385
documentMinify.cookie = `${COOKIE_KEY}=${resolvedMode};max-age=31536000;SameSite=Strict;`;
8486
}, [resolvedMode, systemMode, mode, t]);

lib/src/client/switch/switch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export interface SwitchProps extends HTMLProps<HTMLElement> {
1313
}
1414

1515
/**
16-
*
16+
* Switch button to quickly toggle user preference.
1717
*
1818
* @example
1919
* ```tsx
20-
* <Switch />
20+
* <Switch [size={20} skipSystem]/>
2121
* ```
2222
*
2323
* @source - Source code

lib/src/hooks/use-mode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export interface UseModeYeild {
99
}
1010

1111
/**
12-
*
12+
* use this hook to gain access to mode state and setter.
1313
*
1414
* @example
1515
* ```tsx
16-
* const [] = useMode(options);
16+
* const {resolvedMode, setMode} = useMode(options);
1717
* ```
1818
*
1919
* @source - Source code

lib/src/server/server-target/server-target.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { COOKIE_KEY, LIGHT } from "../../constants";
33

44
/**
55
* Server Side target for avoiding flash of un-themed content.
6+
*
67
* @example
78
* ```tsx
89
* <html>
@@ -13,6 +14,8 @@ import { COOKIE_KEY, LIGHT } from "../../constants";
1314
* </body>
1415
* </html>
1516
* ```
17+
*
18+
* @source - Source code
1619
*/
1720
export const ServerTarget = () => {
1821
const rm = cookies().get(COOKIE_KEY)?.value ?? LIGHT;

0 commit comments

Comments
 (0)