@txnlab/use-wallet-ui-react 0.3.1 → 0.4.1
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.
- package/README.md +80 -1
- package/dist/cjs/index.cjs +59 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +3937 -3857
- package/dist/esm/index.js.map +1 -1
- package/dist/style.css +330 -390
- package/dist/types/index.d.cts +31 -1
- package/dist/types/index.d.ts +31 -1
- package/package.json +4 -2
- package/src/theme.css +76 -0
package/dist/types/index.d.cts
CHANGED
|
@@ -85,6 +85,10 @@ declare type RefableElement_2 = ReactElement & {
|
|
|
85
85
|
ref?: RefObject<HTMLElement> | ((instance: HTMLElement | null) => void);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
export declare type ResolvedTheme = 'light' | 'dark';
|
|
89
|
+
|
|
90
|
+
export declare type Theme = 'light' | 'dark' | 'system';
|
|
91
|
+
|
|
88
92
|
/**
|
|
89
93
|
* Custom hook to fetch account information for Algorand address
|
|
90
94
|
*
|
|
@@ -107,6 +111,15 @@ export declare function useNfd(options?: {
|
|
|
107
111
|
view?: NfdView;
|
|
108
112
|
}): UseQueryResult<NfdRecord | null>;
|
|
109
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Hook to resolve the actual theme value, handling 'system' preference detection.
|
|
116
|
+
* When theme is 'system', it listens to the user's OS/browser color scheme preference.
|
|
117
|
+
*
|
|
118
|
+
* @param theme - The theme setting: 'light', 'dark', or 'system'
|
|
119
|
+
* @returns The resolved theme: 'light' or 'dark'
|
|
120
|
+
*/
|
|
121
|
+
export declare function useResolvedTheme(theme: Theme): ResolvedTheme;
|
|
122
|
+
|
|
110
123
|
/**
|
|
111
124
|
* Hook to access the WalletUI context
|
|
112
125
|
* @throws Error if used outside of WalletUIProvider
|
|
@@ -124,6 +137,8 @@ declare interface WalletListProps {
|
|
|
124
137
|
|
|
125
138
|
declare interface WalletUIContextType {
|
|
126
139
|
queryClient: QueryClient;
|
|
140
|
+
theme: Theme;
|
|
141
|
+
resolvedTheme: ResolvedTheme;
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
/**
|
|
@@ -133,8 +148,13 @@ declare interface WalletUIContextType {
|
|
|
133
148
|
*
|
|
134
149
|
* Automatically prefetches data for all accounts in connected wallets for smoother
|
|
135
150
|
* account switching experience.
|
|
151
|
+
*
|
|
152
|
+
* Supports theme configuration via the `theme` prop:
|
|
153
|
+
* - 'light': Always use light mode
|
|
154
|
+
* - 'dark': Always use dark mode
|
|
155
|
+
* - 'system': Follow the user's OS/browser preference (default)
|
|
136
156
|
*/
|
|
137
|
-
export declare function WalletUIProvider({ children, queryClient: externalQueryClient, enablePrefetching, prefetchNfdView, }: WalletUIProviderProps): JSX.Element;
|
|
157
|
+
export declare function WalletUIProvider({ children, queryClient: externalQueryClient, enablePrefetching, prefetchNfdView, theme, }: WalletUIProviderProps): JSX.Element;
|
|
138
158
|
|
|
139
159
|
declare interface WalletUIProviderProps {
|
|
140
160
|
children: ReactNode;
|
|
@@ -147,6 +167,16 @@ declare interface WalletUIProviderProps {
|
|
|
147
167
|
* NFD view type for prefetching (defaults to 'thumbnail')
|
|
148
168
|
*/
|
|
149
169
|
prefetchNfdView?: NfdView;
|
|
170
|
+
/**
|
|
171
|
+
* Theme setting for wallet UI components.
|
|
172
|
+
* - 'light': Always use light mode
|
|
173
|
+
* - 'dark': Always use dark mode
|
|
174
|
+
* - 'system': Follow the user's OS/browser preference (default)
|
|
175
|
+
*
|
|
176
|
+
* The library also respects the `.dark` class on ancestor elements (Tailwind convention),
|
|
177
|
+
* which will enable dark mode unless explicitly overridden with theme="light".
|
|
178
|
+
*/
|
|
179
|
+
theme?: Theme;
|
|
150
180
|
}
|
|
151
181
|
|
|
152
182
|
export { }
|
package/dist/types/index.d.ts
CHANGED
|
@@ -85,6 +85,10 @@ declare type RefableElement_2 = ReactElement & {
|
|
|
85
85
|
ref?: RefObject<HTMLElement> | ((instance: HTMLElement | null) => void);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
export declare type ResolvedTheme = 'light' | 'dark';
|
|
89
|
+
|
|
90
|
+
export declare type Theme = 'light' | 'dark' | 'system';
|
|
91
|
+
|
|
88
92
|
/**
|
|
89
93
|
* Custom hook to fetch account information for Algorand address
|
|
90
94
|
*
|
|
@@ -107,6 +111,15 @@ export declare function useNfd(options?: {
|
|
|
107
111
|
view?: NfdView;
|
|
108
112
|
}): UseQueryResult<NfdRecord | null>;
|
|
109
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Hook to resolve the actual theme value, handling 'system' preference detection.
|
|
116
|
+
* When theme is 'system', it listens to the user's OS/browser color scheme preference.
|
|
117
|
+
*
|
|
118
|
+
* @param theme - The theme setting: 'light', 'dark', or 'system'
|
|
119
|
+
* @returns The resolved theme: 'light' or 'dark'
|
|
120
|
+
*/
|
|
121
|
+
export declare function useResolvedTheme(theme: Theme): ResolvedTheme;
|
|
122
|
+
|
|
110
123
|
/**
|
|
111
124
|
* Hook to access the WalletUI context
|
|
112
125
|
* @throws Error if used outside of WalletUIProvider
|
|
@@ -124,6 +137,8 @@ declare interface WalletListProps {
|
|
|
124
137
|
|
|
125
138
|
declare interface WalletUIContextType {
|
|
126
139
|
queryClient: QueryClient;
|
|
140
|
+
theme: Theme;
|
|
141
|
+
resolvedTheme: ResolvedTheme;
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
/**
|
|
@@ -133,8 +148,13 @@ declare interface WalletUIContextType {
|
|
|
133
148
|
*
|
|
134
149
|
* Automatically prefetches data for all accounts in connected wallets for smoother
|
|
135
150
|
* account switching experience.
|
|
151
|
+
*
|
|
152
|
+
* Supports theme configuration via the `theme` prop:
|
|
153
|
+
* - 'light': Always use light mode
|
|
154
|
+
* - 'dark': Always use dark mode
|
|
155
|
+
* - 'system': Follow the user's OS/browser preference (default)
|
|
136
156
|
*/
|
|
137
|
-
export declare function WalletUIProvider({ children, queryClient: externalQueryClient, enablePrefetching, prefetchNfdView, }: WalletUIProviderProps): JSX.Element;
|
|
157
|
+
export declare function WalletUIProvider({ children, queryClient: externalQueryClient, enablePrefetching, prefetchNfdView, theme, }: WalletUIProviderProps): JSX.Element;
|
|
138
158
|
|
|
139
159
|
declare interface WalletUIProviderProps {
|
|
140
160
|
children: ReactNode;
|
|
@@ -147,6 +167,16 @@ declare interface WalletUIProviderProps {
|
|
|
147
167
|
* NFD view type for prefetching (defaults to 'thumbnail')
|
|
148
168
|
*/
|
|
149
169
|
prefetchNfdView?: NfdView;
|
|
170
|
+
/**
|
|
171
|
+
* Theme setting for wallet UI components.
|
|
172
|
+
* - 'light': Always use light mode
|
|
173
|
+
* - 'dark': Always use dark mode
|
|
174
|
+
* - 'system': Follow the user's OS/browser preference (default)
|
|
175
|
+
*
|
|
176
|
+
* The library also respects the `.dark` class on ancestor elements (Tailwind convention),
|
|
177
|
+
* which will enable dark mode unless explicitly overridden with theme="light".
|
|
178
|
+
*/
|
|
179
|
+
theme?: Theme;
|
|
150
180
|
}
|
|
151
181
|
|
|
152
182
|
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@txnlab/use-wallet-ui-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "React components for use-wallet UI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.cjs",
|
|
@@ -18,10 +18,12 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"./dist/style.css": "./dist/style.css",
|
|
21
|
+
"./theme.css": "./src/theme.css",
|
|
21
22
|
"./package.json": "./package.json"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist",
|
|
26
|
+
"src/theme.css",
|
|
25
27
|
"README.md"
|
|
26
28
|
],
|
|
27
29
|
"keywords": [
|
|
@@ -86,7 +88,7 @@
|
|
|
86
88
|
"react-dom": "19.1.0",
|
|
87
89
|
"tailwindcss": "4.1.11",
|
|
88
90
|
"tsx": "4.20.3",
|
|
89
|
-
"vite": "6.
|
|
91
|
+
"vite": "6.4.1",
|
|
90
92
|
"vite-plugin-dts": "4.5.4",
|
|
91
93
|
"vite-tsconfig-paths": "5.1.4",
|
|
92
94
|
"vitest": "3.2.4"
|
package/src/theme.css
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* Theme CSS custom properties for wallet UI components */
|
|
2
|
+
/* Import this file in Tailwind projects to enable theming */
|
|
3
|
+
|
|
4
|
+
/* Light mode (default) */
|
|
5
|
+
[data-wallet-ui] {
|
|
6
|
+
--wui-color-primary: #2d2df1;
|
|
7
|
+
--wui-color-primary-hover: #2929d9;
|
|
8
|
+
--wui-color-primary-text: #ffffff;
|
|
9
|
+
--wui-color-bg: #ffffff;
|
|
10
|
+
--wui-color-bg-secondary: #f9fafb;
|
|
11
|
+
--wui-color-bg-tertiary: #f3f4f6;
|
|
12
|
+
--wui-color-bg-hover: #e9e9fd;
|
|
13
|
+
--wui-color-text: #1f2937;
|
|
14
|
+
--wui-color-text-secondary: #6b7280;
|
|
15
|
+
--wui-color-text-tertiary: #9ca3af;
|
|
16
|
+
--wui-color-border: #e5e7eb;
|
|
17
|
+
--wui-color-link: rgba(45, 45, 241, 0.8);
|
|
18
|
+
--wui-color-link-hover: #2d2df1;
|
|
19
|
+
--wui-color-overlay: rgba(0, 0, 0, 0.3);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Dark mode via data-theme attribute (explicit) */
|
|
23
|
+
[data-wallet-ui][data-theme='dark'] {
|
|
24
|
+
--wui-color-primary: #bfbff9;
|
|
25
|
+
--wui-color-primary-hover: #d4d4fa;
|
|
26
|
+
--wui-color-primary-text: #001324;
|
|
27
|
+
--wui-color-bg: #001324;
|
|
28
|
+
--wui-color-bg-secondary: #101b29;
|
|
29
|
+
--wui-color-bg-tertiary: #192a39;
|
|
30
|
+
--wui-color-bg-hover: #192a39;
|
|
31
|
+
--wui-color-text: #e9e9fd;
|
|
32
|
+
--wui-color-text-secondary: #99a1a7;
|
|
33
|
+
--wui-color-text-tertiary: #6b7280;
|
|
34
|
+
--wui-color-border: #192a39;
|
|
35
|
+
--wui-color-link: #6c6cf1;
|
|
36
|
+
--wui-color-link-hover: #8080f3;
|
|
37
|
+
--wui-color-overlay: rgba(0, 0, 0, 0.5);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Dark mode via .dark class on ancestor (Tailwind convention) */
|
|
41
|
+
.dark [data-wallet-ui]:not([data-theme='light']) {
|
|
42
|
+
--wui-color-primary: #bfbff9;
|
|
43
|
+
--wui-color-primary-hover: #d4d4fa;
|
|
44
|
+
--wui-color-primary-text: #001324;
|
|
45
|
+
--wui-color-bg: #001324;
|
|
46
|
+
--wui-color-bg-secondary: #101b29;
|
|
47
|
+
--wui-color-bg-tertiary: #192a39;
|
|
48
|
+
--wui-color-bg-hover: #192a39;
|
|
49
|
+
--wui-color-text: #e9e9fd;
|
|
50
|
+
--wui-color-text-secondary: #99a1a7;
|
|
51
|
+
--wui-color-text-tertiary: #6b7280;
|
|
52
|
+
--wui-color-border: #192a39;
|
|
53
|
+
--wui-color-link: #6c6cf1;
|
|
54
|
+
--wui-color-link-hover: #8080f3;
|
|
55
|
+
--wui-color-overlay: rgba(0, 0, 0, 0.5);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Dark mode via system preference (when theme="system" or no explicit theme) */
|
|
59
|
+
@media (prefers-color-scheme: dark) {
|
|
60
|
+
[data-wallet-ui]:not([data-theme='light']):not([data-theme='dark']) {
|
|
61
|
+
--wui-color-primary: #bfbff9;
|
|
62
|
+
--wui-color-primary-hover: #d4d4fa;
|
|
63
|
+
--wui-color-primary-text: #001324;
|
|
64
|
+
--wui-color-bg: #001324;
|
|
65
|
+
--wui-color-bg-secondary: #101b29;
|
|
66
|
+
--wui-color-bg-tertiary: #192a39;
|
|
67
|
+
--wui-color-bg-hover: #192a39;
|
|
68
|
+
--wui-color-text: #e9e9fd;
|
|
69
|
+
--wui-color-text-secondary: #99a1a7;
|
|
70
|
+
--wui-color-text-tertiary: #6b7280;
|
|
71
|
+
--wui-color-border: #192a39;
|
|
72
|
+
--wui-color-link: #6c6cf1;
|
|
73
|
+
--wui-color-link-hover: #8080f3;
|
|
74
|
+
--wui-color-overlay: rgba(0, 0, 0, 0.5);
|
|
75
|
+
}
|
|
76
|
+
}
|