Skip to content

Commit 52a511b

Browse files
committed
improve tree-shaking and dependency injection
1 parent 3f50eac commit 52a511b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lib/nthul/src/client/theme-switcher/theme-switcher.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import useRGS from "r18gs";
22
import type { SetStateAction } from "r18gs/use-rgs";
33
import * as React from "react";
44
import type { ColorSchemePreference, ThemeState } from "../../hooks/use-theme";
5-
import { DEFAULT_ID } from "../../hooks/use-theme";
5+
import { DEFAULT_ID } from "../../constants";
66

77
export interface ThemeSwitcherProps {
88
/** id of target element to apply classes to. This is useful when you want to apply theme only to specific container. */

lib/nthul/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** shared constants -- keep in separate files for better tree-shaking and dependency injection */
2+
export const DEFAULT_ID = "nthul";

lib/nthul/src/hooks/use-theme.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import useRGS from "r18gs";
2+
import { DEFAULT_ID } from "../constants";
23

34
export type ColorSchemePreference = "system" | "dark" | "light";
45

@@ -8,9 +9,7 @@ export interface ThemeState {
89
theme: string;
910
}
1011

11-
export const DEFAULT_ID = "nthul";
12-
13-
export const DEFAULT_THEME_STATE = {
12+
const DEFAULT_THEME_STATE = {
1413
colorSchemePreference: "system" as ColorSchemePreference,
1514
systemColorScheme: "light" as "light" | "dark",
1615
theme: "",

0 commit comments

Comments
 (0)