react-theme-forge 1.0.0

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,6 @@
1
+ import React from "react";
2
+ import type { ThemeContextValue, ThemeProviderProps } from "../types";
3
+ declare const ThemeContext: React.Context<ThemeContextValue | null>;
4
+ export declare function ThemeProvider({ children, defaultMode, defaultTheme, storageKey, themes: initialThemes, darkClass, targetElement, disablePersistence, }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function useTheme(): ThemeContextValue;
6
+ export { ThemeContext };
@@ -0,0 +1,18 @@
1
+ export interface ThemeToggleProps {
2
+ /** "icon" shows one button that toggles, "segmented" shows Light/Dark/System buttons */
3
+ variant?: "icon" | "segmented";
4
+ /** Additional CSS classes */
5
+ className?: string;
6
+ /** Size of the icon button. Default: "md" */
7
+ size?: "sm" | "md" | "lg";
8
+ /** Show label next to icon */
9
+ showLabel?: boolean;
10
+ /** Custom aria-label */
11
+ ariaLabel?: string;
12
+ }
13
+ export declare function ThemeToggle({ variant, className, size, showLabel, ariaLabel, }: ThemeToggleProps): import("react/jsx-runtime").JSX.Element;
14
+ export interface ThemePickerProps {
15
+ className?: string;
16
+ showPreview?: boolean;
17
+ }
18
+ export declare function ThemePicker({ className, showPreview }: ThemePickerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Get the resolved CSS variable value for a given token.
3
+ *
4
+ * @example
5
+ * const primary = useThemeColor("primary");
6
+ * // Returns: "hsl(var(--primary))"
7
+ *
8
+ * const raw = useThemeColor("primary", true);
9
+ * // Returns: "221 83% 53%" (raw HSL parts, no wrapper)
10
+ */
11
+ export declare function useThemeColor(token: string, raw?: boolean): string;
12
+ /**
13
+ * @returns true when the resolved theme is "dark"
14
+ */
15
+ export declare function useIsDark(): boolean;
16
+ /**
17
+ * Returns a value depending on the active theme.
18
+ *
19
+ * @example
20
+ * const bg = useThemeValue("white", "gray-900");
21
+ */
22
+ export declare function useThemeValue<T>(lightValue: T, darkValue: T): T;
23
+ /**
24
+ * Temporarily adds a CSS transition to the document root
25
+ * so theme changes animate smoothly.
26
+ *
27
+ * @example
28
+ * const withTransition = useThemeTransition();
29
+ * withTransition(() => applyTheme("ocean"));
30
+ */
31
+ export declare function useThemeTransition(duration?: number): (fn: () => void) => void;
@@ -0,0 +1,147 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type ThemeMode = "light" | "dark" | "system";
4
+ interface ThemeColors {
5
+ primary: string;
6
+ primaryForeground: string;
7
+ secondary: string;
8
+ secondaryForeground: string;
9
+ background: string;
10
+ foreground: string;
11
+ card: string;
12
+ cardForeground: string;
13
+ border: string;
14
+ input: string;
15
+ ring: string;
16
+ muted: string;
17
+ mutedForeground: string;
18
+ accent: string;
19
+ accentForeground: string;
20
+ destructive: string;
21
+ destructiveForeground: string;
22
+ success: string;
23
+ successForeground: string;
24
+ warning: string;
25
+ warningForeground: string;
26
+ }
27
+ interface ThemeRadius {
28
+ sm: string;
29
+ md: string;
30
+ lg: string;
31
+ xl: string;
32
+ full: string;
33
+ }
34
+ interface ThemeFonts {
35
+ sans: string;
36
+ mono: string;
37
+ heading: string;
38
+ }
39
+ interface ThemeConfig {
40
+ name: string;
41
+ colors: {
42
+ light: Partial<ThemeColors>;
43
+ dark: Partial<ThemeColors>;
44
+ };
45
+ radius?: Partial<ThemeRadius>;
46
+ fonts?: Partial<ThemeFonts>;
47
+ }
48
+ interface ThemeContextValue {
49
+ /** Current active resolved theme: "light" | "dark" */
50
+ theme: "light" | "dark";
51
+ /** Raw mode including "system" */
52
+ mode: ThemeMode;
53
+ /** All registered custom themes */
54
+ themes: Record<string, ThemeConfig>;
55
+ /** Name of the currently applied custom theme, if any */
56
+ activeTheme: string | null;
57
+ /** Toggle between light and dark */
58
+ toggleTheme: () => void;
59
+ /** Set mode explicitly */
60
+ setMode: (mode: ThemeMode) => void;
61
+ /** Apply a registered custom theme by name */
62
+ applyTheme: (themeName: string) => void;
63
+ /** Register a new custom theme */
64
+ registerTheme: (config: ThemeConfig) => void;
65
+ /** Remove a theme */
66
+ removeTheme: (themeName: string) => void;
67
+ /** Reset to default theme */
68
+ resetTheme: () => void;
69
+ /** Check if system prefers dark */
70
+ systemPrefersDark: boolean;
71
+ }
72
+ interface ThemeProviderProps {
73
+ children: React.ReactNode;
74
+ /** Default mode on first load. Default: "system" */
75
+ defaultMode?: ThemeMode;
76
+ /** Default custom theme name to apply */
77
+ defaultTheme?: string;
78
+ /** Key used for localStorage persistence. Default: "rtf-theme" */
79
+ storageKey?: string;
80
+ /** Custom themes to register at startup */
81
+ themes?: ThemeConfig[];
82
+ /** CSS class applied to <html> for dark mode. Default: "dark" */
83
+ darkClass?: string;
84
+ /** Apply CSS variables to a custom element instead of :root */
85
+ targetElement?: string;
86
+ /** Disable localStorage persistence */
87
+ disablePersistence?: boolean;
88
+ }
89
+
90
+ declare function ThemeProvider({ children, defaultMode, defaultTheme, storageKey, themes: initialThemes, darkClass, targetElement, disablePersistence, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
91
+ declare function useTheme(): ThemeContextValue;
92
+
93
+ interface ThemeToggleProps {
94
+ /** "icon" shows one button that toggles, "segmented" shows Light/Dark/System buttons */
95
+ variant?: "icon" | "segmented";
96
+ /** Additional CSS classes */
97
+ className?: string;
98
+ /** Size of the icon button. Default: "md" */
99
+ size?: "sm" | "md" | "lg";
100
+ /** Show label next to icon */
101
+ showLabel?: boolean;
102
+ /** Custom aria-label */
103
+ ariaLabel?: string;
104
+ }
105
+ declare function ThemeToggle({ variant, className, size, showLabel, ariaLabel, }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
106
+ interface ThemePickerProps {
107
+ className?: string;
108
+ showPreview?: boolean;
109
+ }
110
+ declare function ThemePicker({ className, showPreview }: ThemePickerProps): react_jsx_runtime.JSX.Element;
111
+
112
+ /**
113
+ * Get the resolved CSS variable value for a given token.
114
+ *
115
+ * @example
116
+ * const primary = useThemeColor("primary");
117
+ * // Returns: "hsl(var(--primary))"
118
+ *
119
+ * const raw = useThemeColor("primary", true);
120
+ * // Returns: "221 83% 53%" (raw HSL parts, no wrapper)
121
+ */
122
+ declare function useThemeColor(token: string, raw?: boolean): string;
123
+ /**
124
+ * @returns true when the resolved theme is "dark"
125
+ */
126
+ declare function useIsDark(): boolean;
127
+ /**
128
+ * Returns a value depending on the active theme.
129
+ *
130
+ * @example
131
+ * const bg = useThemeValue("white", "gray-900");
132
+ */
133
+ declare function useThemeValue<T>(lightValue: T, darkValue: T): T;
134
+ /**
135
+ * Temporarily adds a CSS transition to the document root
136
+ * so theme changes animate smoothly.
137
+ *
138
+ * @example
139
+ * const withTransition = useThemeTransition();
140
+ * withTransition(() => applyTheme("ocean"));
141
+ */
142
+ declare function useThemeTransition(duration?: number): (fn: () => void) => void;
143
+
144
+ declare const presetThemes: Record<string, ThemeConfig>;
145
+
146
+ export { ThemePicker, ThemeProvider, ThemeToggle, presetThemes, useIsDark, useTheme, useThemeColor, useThemeTransition, useThemeValue };
147
+ export type { ThemeColors, ThemeConfig, ThemeContextValue, ThemeFonts, ThemeMode, ThemeProviderProps, ThemeRadius };