@thorprovider/create-thor-app 4.1.6 → 4.1.8
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/package.json
CHANGED
|
@@ -45,6 +45,11 @@ ALWAYS import from @thorprovider/types — NEVER define Product, Cart, Collectio
|
|
|
45
45
|
- Do NOT replace the commerce runtime globally with local demo data
|
|
46
46
|
- Do NOT gate storefront rendering on environment-variable checks
|
|
47
47
|
|
|
48
|
+
## Dark Mode
|
|
49
|
+
ThemeProvider is pre-configured in `app-providers.tsx` — do NOT create a new `theme-provider.tsx`.
|
|
50
|
+
Toggle theme with `useTheme()` from 'next-themes': `const { setTheme } = useTheme()`.
|
|
51
|
+
Dark mode tokens are in `styles/tokens.css` under `.dark { ... }` — use CSS variables, never hardcode colors.
|
|
52
|
+
|
|
48
53
|
## Stack
|
|
49
54
|
Next.js 16, React 19, TS strict, Tailwind 4, shadcn/ui.
|
|
50
55
|
Server Components default. 'use client' only for interactivity.
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Application Providers — Composites all context providers.
|
|
5
5
|
*
|
|
6
6
|
* Provider Hierarchy (ordered by dependencies — FROZEN, do not reorder):
|
|
7
|
-
* 1.
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
7
|
+
* 1. ThemeProvider — Dark/light mode via .dark class (no dependencies)
|
|
8
|
+
* 2. CommerceProvider — Commerce backend access (no dependencies)
|
|
9
|
+
* 3. RegionProvider — Region/currency context (depends on commerce)
|
|
10
|
+
* 4. CartProvider — Shopping cart (depends on commerce)
|
|
10
11
|
*
|
|
11
12
|
* Receives `commerceConfig` from the async RSC layout (app/layout.tsx).
|
|
12
13
|
* The config is read from process.env server-side and forwarded here as
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
import React from 'react'
|
|
18
|
+
import { ThemeProvider } from './theme-provider'
|
|
17
19
|
import { CommerceProvider } from './commerce-provider'
|
|
18
20
|
import { RegionProvider } from './region-provider'
|
|
19
21
|
import { CartProvider } from './cart-provider'
|
|
@@ -27,12 +29,15 @@ interface AppProvidersProps {
|
|
|
27
29
|
|
|
28
30
|
export function AppProviders({ children, commerceConfig }: AppProvidersProps) {
|
|
29
31
|
return (
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
|
|
33
|
+
<CommerceProvider config={commerceConfig}>
|
|
34
|
+
<RegionProvider>
|
|
35
|
+
<CartProvider>
|
|
36
|
+
{children}
|
|
37
|
+
</CartProvider>
|
|
38
|
+
</RegionProvider>
|
|
39
|
+
</CommerceProvider>
|
|
40
|
+
</ThemeProvider>
|
|
37
41
|
)
|
|
38
42
|
}
|
|
43
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
|
5
|
+
import type { ThemeProviderProps } from 'next-themes'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ThemeProvider — thin wrapper over next-themes.
|
|
9
|
+
*
|
|
10
|
+
* FROZEN — do not modify.
|
|
11
|
+
* Already wired in app-providers.tsx with attribute="class" defaultTheme="system".
|
|
12
|
+
* Dark mode tokens are in styles/tokens.css under .dark { ... }.
|
|
13
|
+
*
|
|
14
|
+
* To toggle theme in a component:
|
|
15
|
+
* import { useTheme } from 'next-themes'
|
|
16
|
+
* const { theme, setTheme } = useTheme()
|
|
17
|
+
* setTheme('dark') | setTheme('light') | setTheme('system')
|
|
18
|
+
*/
|
|
19
|
+
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
|
20
|
+
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
|
21
|
+
}
|