nextworks 0.2.0-alpha.2 → 0.2.0-alpha.21
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 +280 -228
- package/dist/cli_manifests/blocks_manifest.json +193 -194
- package/dist/commands/blocks.d.ts +3 -0
- package/dist/commands/blocks.d.ts.map +1 -1
- package/dist/commands/blocks.js +128 -19
- package/dist/commands/blocks.js.map +1 -1
- package/dist/commands/doctor.d.ts +136 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +696 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/remove-blocks.d.ts +4 -1
- package/dist/commands/remove-blocks.d.ts.map +1 -1
- package/dist/commands/remove-blocks.js +24 -6
- package/dist/commands/remove-blocks.js.map +1 -1
- package/dist/index.js +125 -4
- package/dist/index.js.map +1 -1
- package/dist/kits/blocks/.nextworks/docs/BLOCKS_QUICKSTART.md +104 -194
- package/dist/kits/blocks/.nextworks/docs/BLOCKS_README.md +115 -75
- package/dist/kits/blocks/.nextworks/docs/THEME_GUIDE.md +269 -251
- package/dist/kits/blocks/app/templates/digitalagency/PresetThemeVars.tsx +80 -80
- package/dist/kits/blocks/app/templates/digitalagency/README.md +42 -36
- package/dist/kits/blocks/app/templates/digitalagency/components/About.tsx +71 -99
- package/dist/kits/blocks/app/templates/digitalagency/components/CTA.tsx +40 -74
- package/dist/kits/blocks/app/templates/digitalagency/components/Contact.tsx +123 -227
- package/dist/kits/blocks/app/templates/digitalagency/components/Footer.tsx +89 -89
- package/dist/kits/blocks/app/templates/digitalagency/components/Hero.tsx +83 -90
- package/dist/kits/blocks/app/templates/digitalagency/components/Navbar.tsx +121 -168
- package/dist/kits/blocks/app/templates/digitalagency/components/NetworkPattern.tsx +288 -297
- package/dist/kits/blocks/app/templates/digitalagency/components/Portfolio.tsx +157 -157
- package/dist/kits/blocks/app/templates/digitalagency/components/Pricing.tsx +114 -114
- package/dist/kits/blocks/app/templates/digitalagency/components/Process.tsx +59 -59
- package/dist/kits/blocks/app/templates/digitalagency/components/Services.tsx +55 -55
- package/dist/kits/blocks/app/templates/digitalagency/components/Team.tsx +28 -28
- package/dist/kits/blocks/app/templates/digitalagency/components/Testimonials.tsx +65 -65
- package/dist/kits/blocks/app/templates/digitalagency/page.tsx +38 -38
- package/dist/kits/blocks/app/templates/gallery/PresetThemeVars.tsx +130 -85
- package/dist/kits/blocks/app/templates/gallery/page.tsx +357 -303
- package/dist/kits/blocks/app/templates/productlaunch/PresetThemeVars.tsx +75 -74
- package/dist/kits/blocks/app/templates/productlaunch/README.md +62 -55
- package/dist/kits/blocks/app/templates/productlaunch/components/About.tsx +84 -178
- package/dist/kits/blocks/app/templates/productlaunch/components/CTA.tsx +50 -93
- package/dist/kits/blocks/app/templates/productlaunch/components/Contact.tsx +231 -231
- package/dist/kits/blocks/app/templates/productlaunch/components/FAQ.tsx +86 -93
- package/dist/kits/blocks/app/templates/productlaunch/components/Features.tsx +83 -84
- package/dist/kits/blocks/app/templates/productlaunch/components/Footer.tsx +132 -132
- package/dist/kits/blocks/app/templates/productlaunch/components/Hero.tsx +88 -89
- package/dist/kits/blocks/app/templates/productlaunch/components/Navbar.tsx +116 -162
- package/dist/kits/blocks/app/templates/productlaunch/components/Pricing.tsx +106 -106
- package/dist/kits/blocks/app/templates/productlaunch/components/ProcessTimeline.tsx +110 -110
- package/dist/kits/blocks/app/templates/productlaunch/components/ServicesGrid.tsx +68 -68
- package/dist/kits/blocks/app/templates/productlaunch/components/Team.tsx +104 -104
- package/dist/kits/blocks/app/templates/productlaunch/components/Testimonials.tsx +90 -89
- package/dist/kits/blocks/app/templates/productlaunch/components/TrustBadges.tsx +76 -76
- package/dist/kits/blocks/app/templates/productlaunch/page.tsx +43 -43
- package/dist/kits/blocks/app/templates/saasdashboard/PresetThemeVars.tsx +80 -80
- package/dist/kits/blocks/app/templates/saasdashboard/README.md +44 -38
- package/dist/kits/blocks/app/templates/saasdashboard/components/Contact.tsx +129 -176
- package/dist/kits/blocks/app/templates/saasdashboard/components/Dashboard.tsx +293 -293
- package/dist/kits/blocks/app/templates/saasdashboard/components/FAQ.tsx +55 -55
- package/dist/kits/blocks/app/templates/saasdashboard/components/Features.tsx +90 -91
- package/dist/kits/blocks/app/templates/saasdashboard/components/Footer.tsx +77 -77
- package/dist/kits/blocks/app/templates/saasdashboard/components/Hero.tsx +104 -105
- package/dist/kits/blocks/app/templates/saasdashboard/components/Hero_mask.tsx +126 -127
- package/dist/kits/blocks/app/templates/saasdashboard/components/Navbar.tsx +117 -159
- package/dist/kits/blocks/app/templates/saasdashboard/components/Pricing.tsx +90 -90
- package/dist/kits/blocks/app/templates/saasdashboard/components/SmoothScroll.tsx +96 -97
- package/dist/kits/blocks/app/templates/saasdashboard/components/Testimonials.tsx +72 -72
- package/dist/kits/blocks/app/templates/saasdashboard/components/TrustBadges.tsx +53 -53
- package/dist/kits/blocks/app/templates/saasdashboard/page.tsx +39 -39
- package/dist/kits/blocks/components/enhanced-theme-provider.tsx +195 -183
- package/dist/kits/blocks/components/providers/BlocksAppProviders.tsx +27 -27
- package/dist/kits/blocks/components/sections/About.tsx +291 -291
- package/dist/kits/blocks/components/sections/CTA.tsx +257 -258
- package/dist/kits/blocks/components/sections/CommandShowcase.tsx +517 -0
- package/dist/kits/blocks/components/sections/Contact.tsx +267 -267
- package/dist/kits/blocks/components/sections/FAQ.tsx +214 -225
- package/dist/kits/blocks/components/sections/FeaturedProjectShowcase.tsx +687 -0
- package/dist/kits/blocks/components/sections/Features.tsx +268 -270
- package/dist/kits/blocks/components/sections/Footer.tsx +302 -302
- package/dist/kits/blocks/components/sections/HeroMotion.tsx +308 -308
- package/dist/kits/blocks/components/sections/HeroOverlay.tsx +358 -358
- package/dist/kits/blocks/components/sections/HeroProductDemo.tsx +246 -0
- package/dist/kits/blocks/components/sections/HeroSplit.tsx +352 -352
- package/dist/kits/blocks/components/sections/HeroWithVideo.tsx +495 -0
- package/dist/kits/blocks/components/sections/Navbar.tsx +352 -353
- package/dist/kits/blocks/components/sections/PortfolioSimple.tsx +549 -550
- package/dist/kits/blocks/components/sections/Pricing.tsx +264 -264
- package/dist/kits/blocks/components/sections/ProcessTimeline.tsx +325 -325
- package/dist/kits/blocks/components/sections/ProjectDeepDive.tsx +805 -0
- package/dist/kits/blocks/components/sections/SelectedWorkRail.tsx +485 -0
- package/dist/kits/blocks/components/sections/ServicesGrid.tsx +210 -210
- package/dist/kits/blocks/components/sections/Team.tsx +309 -309
- package/dist/kits/blocks/components/sections/Testimonials.tsx +158 -158
- package/dist/kits/blocks/components/sections/TrustBadges.tsx +162 -162
- package/dist/kits/blocks/components/sections/product-demo/ApprovalInboxPanel.tsx +128 -0
- package/dist/kits/blocks/components/sections/product-demo/DemoStage.tsx +519 -0
- package/dist/kits/blocks/components/sections/product-demo/DemoWindow.tsx +140 -0
- package/dist/kits/blocks/components/sections/product-demo/KnowledgePanel.tsx +130 -0
- package/dist/kits/blocks/components/sections/product-demo/RunConsolePanel.tsx +430 -0
- package/dist/kits/blocks/components/sections/product-demo/TaskListPanel.tsx +302 -0
- package/dist/kits/blocks/components/sections/product-demo/WorkflowStudioPanel.tsx +744 -0
- package/dist/kits/blocks/components/sections/product-demo/types.ts +262 -0
- package/dist/kits/blocks/components/theme-provider.tsx +1 -34
- package/dist/kits/blocks/components/ui/alert-dialog.tsx +134 -134
- package/dist/kits/blocks/components/ui/brand-node.tsx +121 -121
- package/dist/kits/blocks/components/ui/button.tsx +122 -122
- package/dist/kits/blocks/components/ui/card.tsx +95 -95
- package/dist/kits/blocks/components/ui/checkbox.tsx +30 -30
- package/dist/kits/blocks/components/ui/cta-button.tsx +125 -125
- package/dist/kits/blocks/components/ui/dropdown-menu.tsx +201 -201
- package/dist/kits/blocks/components/ui/feature-card.tsx +91 -91
- package/dist/kits/blocks/components/ui/input.tsx +27 -27
- package/dist/kits/blocks/components/ui/label.tsx +29 -29
- package/dist/kits/blocks/components/ui/pricing-card.tsx +120 -120
- package/dist/kits/blocks/components/ui/select.tsx +25 -25
- package/dist/kits/blocks/components/ui/skeleton.tsx +13 -13
- package/dist/kits/blocks/components/ui/table.tsx +98 -98
- package/dist/kits/blocks/components/ui/testimonial-card.tsx +108 -108
- package/dist/kits/blocks/components/ui/textarea.tsx +26 -26
- package/dist/kits/blocks/components/ui/theme-selector.tsx +243 -247
- package/dist/kits/blocks/components/ui/theme-toggle.tsx +74 -74
- package/dist/kits/blocks/components/ui/toaster.tsx +7 -7
- package/dist/kits/blocks/lib/themes.ts +400 -400
- package/dist/kits/blocks/lib/utils.ts +6 -9
- package/dist/kits/blocks/package-deps.json +40 -28
- package/dist/kits/blocks/tsconfig.json +11 -0
- package/dist/kits/blocks/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/file-operations.d.ts +3 -1
- package/dist/utils/file-operations.d.ts.map +1 -1
- package/dist/utils/file-operations.js +84 -12
- package/dist/utils/file-operations.js.map +1 -1
- package/dist/utils/installation-tracker.d.ts +2 -2
- package/dist/utils/installation-tracker.d.ts.map +1 -1
- package/dist/utils/installation-tracker.js +11 -11
- package/dist/utils/installation-tracker.js.map +1 -1
- package/dist/utils/package-manager.d.ts +6 -0
- package/dist/utils/package-manager.d.ts.map +1 -0
- package/dist/utils/package-manager.js +58 -0
- package/dist/utils/package-manager.js.map +1 -0
- package/dist/utils/yarn-pnp.d.ts +6 -0
- package/dist/utils/yarn-pnp.d.ts.map +1 -0
- package/dist/utils/yarn-pnp.js +39 -0
- package/dist/utils/yarn-pnp.js.map +1 -0
- package/package.json +5 -2
- package/dist/kits/blocks/notes/THEME_GUIDE.md +0 -29
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { Navbar } from "./components/Navbar";
|
|
2
|
-
import { Hero } from "./components/Hero";
|
|
3
|
-
import { Features } from "./components/Features";
|
|
4
|
-
import { Testimonials } from "./components/Testimonials";
|
|
5
|
-
import { TrustBadges } from "./components/TrustBadges";
|
|
6
|
-
import { Contact } from "./components/Contact";
|
|
7
|
-
import { Pricing } from "./components/Pricing";
|
|
8
|
-
import { FAQ } from "./components/FAQ";
|
|
9
|
-
import { Footer } from "./components/Footer";
|
|
10
|
-
import { SmoothScroll } from "./components/SmoothScroll";
|
|
11
|
-
|
|
12
|
-
import { PresetThemeVars } from "./PresetThemeVars";
|
|
13
|
-
|
|
14
|
-
export default function SaaSDashboardPage() {
|
|
15
|
-
return (
|
|
16
|
-
<PresetThemeVars>
|
|
17
|
-
<div>
|
|
18
|
-
<SmoothScroll />
|
|
19
|
-
<Navbar />
|
|
20
|
-
<section id="home">
|
|
21
|
-
<Hero />
|
|
22
|
-
</section>
|
|
23
|
-
<Features />
|
|
24
|
-
<Testimonials />
|
|
25
|
-
<TrustBadges />
|
|
26
|
-
<section id="pricing">
|
|
27
|
-
<Pricing />
|
|
28
|
-
</section>
|
|
29
|
-
<section id="contact">
|
|
30
|
-
<Contact />
|
|
31
|
-
</section>
|
|
32
|
-
<section id="faq">
|
|
33
|
-
<FAQ />
|
|
34
|
-
</section>
|
|
35
|
-
<Footer />
|
|
36
|
-
</div>
|
|
37
|
-
</PresetThemeVars>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
1
|
+
import { Navbar } from "./components/Navbar";
|
|
2
|
+
import { Hero } from "./components/Hero";
|
|
3
|
+
import { Features } from "./components/Features";
|
|
4
|
+
import { Testimonials } from "./components/Testimonials";
|
|
5
|
+
import { TrustBadges } from "./components/TrustBadges";
|
|
6
|
+
import { Contact } from "./components/Contact";
|
|
7
|
+
import { Pricing } from "./components/Pricing";
|
|
8
|
+
import { FAQ } from "./components/FAQ";
|
|
9
|
+
import { Footer } from "./components/Footer";
|
|
10
|
+
import { SmoothScroll } from "./components/SmoothScroll";
|
|
11
|
+
|
|
12
|
+
import { PresetThemeVars } from "./PresetThemeVars";
|
|
13
|
+
|
|
14
|
+
export default function SaaSDashboardPage() {
|
|
15
|
+
return (
|
|
16
|
+
<PresetThemeVars>
|
|
17
|
+
<div>
|
|
18
|
+
<SmoothScroll />
|
|
19
|
+
<Navbar />
|
|
20
|
+
<section id="home">
|
|
21
|
+
<Hero />
|
|
22
|
+
</section>
|
|
23
|
+
<Features />
|
|
24
|
+
<Testimonials />
|
|
25
|
+
<TrustBadges />
|
|
26
|
+
<section id="pricing">
|
|
27
|
+
<Pricing />
|
|
28
|
+
</section>
|
|
29
|
+
<section id="contact">
|
|
30
|
+
<Contact />
|
|
31
|
+
</section>
|
|
32
|
+
<section id="faq">
|
|
33
|
+
<FAQ />
|
|
34
|
+
</section>
|
|
35
|
+
<Footer />
|
|
36
|
+
</div>
|
|
37
|
+
</PresetThemeVars>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -1,183 +1,195 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
|
5
|
-
import type { ThemeProviderProps as NextThemesProviderProps } from "next-themes";
|
|
6
|
-
import {
|
|
7
|
-
ThemeVariant,
|
|
8
|
-
themes,
|
|
9
|
-
darkThemes,
|
|
10
|
-
type ThemeConfig,
|
|
11
|
-
} from "@/lib/themes";
|
|
12
|
-
|
|
13
|
-
type ColorTokens = ThemeConfig["colors"];
|
|
14
|
-
const CUSTOM_STORAGE_KEY = "nxw-theme-custom";
|
|
15
|
-
|
|
16
|
-
interface EnhancedThemeProviderProps {
|
|
17
|
-
children: React.ReactNode;
|
|
18
|
-
attribute?: NextThemesProviderProps["attribute"];
|
|
19
|
-
defaultTheme?: NextThemesProviderProps["defaultTheme"];
|
|
20
|
-
enableSystem?: NextThemesProviderProps["enableSystem"];
|
|
21
|
-
disableTransitionOnChange?: NextThemesProviderProps["disableTransitionOnChange"];
|
|
22
|
-
defaultThemeVariant?: ThemeVariant;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
document.cookie = `theme-custom
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
root.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
|
5
|
+
import type { ThemeProviderProps as NextThemesProviderProps } from "next-themes";
|
|
6
|
+
import {
|
|
7
|
+
ThemeVariant,
|
|
8
|
+
themes,
|
|
9
|
+
darkThemes,
|
|
10
|
+
type ThemeConfig,
|
|
11
|
+
} from "@/lib/themes";
|
|
12
|
+
|
|
13
|
+
type ColorTokens = ThemeConfig["colors"];
|
|
14
|
+
const CUSTOM_STORAGE_KEY = "nxw-theme-custom";
|
|
15
|
+
|
|
16
|
+
interface EnhancedThemeProviderProps {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
attribute?: NextThemesProviderProps["attribute"];
|
|
19
|
+
defaultTheme?: NextThemesProviderProps["defaultTheme"];
|
|
20
|
+
enableSystem?: NextThemesProviderProps["enableSystem"];
|
|
21
|
+
disableTransitionOnChange?: NextThemesProviderProps["disableTransitionOnChange"];
|
|
22
|
+
defaultThemeVariant?: ThemeVariant;
|
|
23
|
+
defaultCustomTokens?: Partial<ColorTokens> | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ThemeContextType {
|
|
27
|
+
themeVariant: ThemeVariant;
|
|
28
|
+
setThemeVariant: (variant: ThemeVariant) => void;
|
|
29
|
+
|
|
30
|
+
customTheme: Partial<ColorTokens> | null;
|
|
31
|
+
setCustomTheme: (tokens: Partial<ColorTokens> | null) => void;
|
|
32
|
+
setCustomBrandColors: (tokens: Partial<ColorTokens>) => void;
|
|
33
|
+
|
|
34
|
+
applyTheme: (variant: ThemeVariant, isDark?: boolean) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ThemeContext = React.createContext<ThemeContextType | undefined>(
|
|
38
|
+
undefined,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export function useThemeVariant() {
|
|
42
|
+
const context = React.useContext(ThemeContext);
|
|
43
|
+
if (context === undefined) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
"useThemeVariant must be used within an EnhancedThemeProvider",
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function EnhancedThemeProvider({
|
|
52
|
+
children,
|
|
53
|
+
attribute = "class",
|
|
54
|
+
defaultTheme = "system",
|
|
55
|
+
enableSystem = true,
|
|
56
|
+
disableTransitionOnChange = false,
|
|
57
|
+
defaultThemeVariant = "monochrome",
|
|
58
|
+
defaultCustomTokens = null,
|
|
59
|
+
}: EnhancedThemeProviderProps) {
|
|
60
|
+
const [themeVariant, setThemeVariant] =
|
|
61
|
+
React.useState<ThemeVariant>(defaultThemeVariant);
|
|
62
|
+
const [customTheme, setCustomThemeState] =
|
|
63
|
+
React.useState<Partial<ColorTokens> | null>(defaultCustomTokens);
|
|
64
|
+
|
|
65
|
+
const writeCustomCookies = React.useCallback(
|
|
66
|
+
(tokens: Partial<ColorTokens> | null) => {
|
|
67
|
+
if (tokens) {
|
|
68
|
+
document.cookie = `theme-variant=custom; Path=/; Max-Age=31536000; SameSite=Lax`;
|
|
69
|
+
document.cookie = `theme-custom=${encodeURIComponent(JSON.stringify(tokens))}; Path=/; Max-Age=31536000; SameSite=Lax`;
|
|
70
|
+
} else {
|
|
71
|
+
document.cookie = `theme-custom=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[],
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const setCustomTheme = React.useCallback(
|
|
78
|
+
(tokens: Partial<ColorTokens> | null) => {
|
|
79
|
+
setCustomThemeState(tokens);
|
|
80
|
+
try {
|
|
81
|
+
if (tokens) {
|
|
82
|
+
localStorage.setItem(CUSTOM_STORAGE_KEY, JSON.stringify(tokens));
|
|
83
|
+
} else {
|
|
84
|
+
localStorage.removeItem(CUSTOM_STORAGE_KEY);
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
// ignore
|
|
88
|
+
}
|
|
89
|
+
writeCustomCookies(tokens ?? null);
|
|
90
|
+
},
|
|
91
|
+
[writeCustomCookies],
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const setCustomBrandColors = React.useCallback(
|
|
95
|
+
(tokens: Partial<ColorTokens>) => {
|
|
96
|
+
setThemeVariant("custom");
|
|
97
|
+
setCustomTheme(tokens);
|
|
98
|
+
},
|
|
99
|
+
[setCustomTheme],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const applyTheme = React.useCallback(
|
|
103
|
+
(variant: ThemeVariant, isDark = false) => {
|
|
104
|
+
const base = isDark ? darkThemes[variant].colors : themes[variant].colors;
|
|
105
|
+
const merged =
|
|
106
|
+
variant === "custom" && customTheme
|
|
107
|
+
? { ...base, ...customTheme }
|
|
108
|
+
: base;
|
|
109
|
+
|
|
110
|
+
// Apply CSS custom properties to the document root
|
|
111
|
+
const root = document.documentElement;
|
|
112
|
+
|
|
113
|
+
// Reflect the current variant for CSS selectors
|
|
114
|
+
root.setAttribute("data-theme-variant", variant);
|
|
115
|
+
|
|
116
|
+
Object.entries(merged).forEach(([key, value]) => {
|
|
117
|
+
const cssVar = `--${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`;
|
|
118
|
+
root.style.setProperty(cssVar, value as string);
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
[customTheme],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
// Apply theme when variant or custom tokens change
|
|
125
|
+
React.useEffect(() => {
|
|
126
|
+
const isDark = document.documentElement.classList.contains("dark");
|
|
127
|
+
applyTheme(themeVariant, isDark);
|
|
128
|
+
}, [themeVariant, customTheme, applyTheme]);
|
|
129
|
+
|
|
130
|
+
// Load custom tokens from localStorage on mount (overrides defaultCustomTokens if present)
|
|
131
|
+
React.useEffect(() => {
|
|
132
|
+
try {
|
|
133
|
+
const raw = localStorage.getItem(CUSTOM_STORAGE_KEY);
|
|
134
|
+
if (raw) {
|
|
135
|
+
const parsed = JSON.parse(raw) as Partial<ColorTokens>;
|
|
136
|
+
setCustomThemeState(parsed);
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
// ignore
|
|
140
|
+
}
|
|
141
|
+
}, []);
|
|
142
|
+
|
|
143
|
+
// Listen for theme changes from next-themes
|
|
144
|
+
React.useEffect(() => {
|
|
145
|
+
const observer = new MutationObserver((mutations) => {
|
|
146
|
+
mutations.forEach((mutation) => {
|
|
147
|
+
if (
|
|
148
|
+
mutation.type === "attributes" &&
|
|
149
|
+
mutation.attributeName === "class"
|
|
150
|
+
) {
|
|
151
|
+
const isDark = document.documentElement.classList.contains("dark");
|
|
152
|
+
applyTheme(themeVariant, isDark);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
observer.observe(document.documentElement, {
|
|
158
|
+
attributes: true,
|
|
159
|
+
attributeFilter: ["class"],
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return () => observer.disconnect();
|
|
163
|
+
}, [themeVariant, applyTheme]);
|
|
164
|
+
|
|
165
|
+
const contextValue = React.useMemo(
|
|
166
|
+
() => ({
|
|
167
|
+
themeVariant,
|
|
168
|
+
setThemeVariant,
|
|
169
|
+
customTheme,
|
|
170
|
+
setCustomTheme,
|
|
171
|
+
setCustomBrandColors,
|
|
172
|
+
applyTheme,
|
|
173
|
+
}),
|
|
174
|
+
[
|
|
175
|
+
themeVariant,
|
|
176
|
+
customTheme,
|
|
177
|
+
setCustomTheme,
|
|
178
|
+
setCustomBrandColors,
|
|
179
|
+
applyTheme,
|
|
180
|
+
],
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<NextThemesProvider
|
|
185
|
+
attribute={attribute}
|
|
186
|
+
defaultTheme={defaultTheme}
|
|
187
|
+
enableSystem={enableSystem}
|
|
188
|
+
disableTransitionOnChange={disableTransitionOnChange}
|
|
189
|
+
>
|
|
190
|
+
<ThemeContext.Provider value={contextValue}>
|
|
191
|
+
{children}
|
|
192
|
+
</ThemeContext.Provider>
|
|
193
|
+
</NextThemesProvider>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { EnhancedThemeProvider } from "../enhanced-theme-provider";
|
|
5
|
-
import type { ThemeVariant } from "../../lib/themes";
|
|
6
|
-
|
|
7
|
-
type BlocksAppProvidersProps = {
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
defaultThemeVariant?: ThemeVariant;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Client-safe provider wrapper for Nextworks blocks (kit-local).
|
|
14
|
-
*
|
|
15
|
-
* This intentionally avoids importing providers/hooks from @nextworks/blocks-core
|
|
16
|
-
* to prevent duplicate React context instances in Turbopack dev.
|
|
17
|
-
*/
|
|
18
|
-
export function BlocksAppProviders({
|
|
19
|
-
children,
|
|
20
|
-
defaultThemeVariant = "monochrome",
|
|
21
|
-
}: BlocksAppProvidersProps) {
|
|
22
|
-
return (
|
|
23
|
-
<EnhancedThemeProvider defaultThemeVariant={defaultThemeVariant}>
|
|
24
|
-
{children}
|
|
25
|
-
</EnhancedThemeProvider>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { EnhancedThemeProvider } from "../enhanced-theme-provider";
|
|
5
|
+
import type { ThemeVariant } from "../../lib/themes";
|
|
6
|
+
|
|
7
|
+
type BlocksAppProvidersProps = {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
defaultThemeVariant?: ThemeVariant;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Client-safe provider wrapper for Nextworks blocks (kit-local).
|
|
14
|
+
*
|
|
15
|
+
* This intentionally avoids importing providers/hooks from @nextworks/blocks-core
|
|
16
|
+
* to prevent duplicate React context instances in Turbopack dev.
|
|
17
|
+
*/
|
|
18
|
+
export function BlocksAppProviders({
|
|
19
|
+
children,
|
|
20
|
+
defaultThemeVariant = "monochrome",
|
|
21
|
+
}: BlocksAppProvidersProps) {
|
|
22
|
+
return (
|
|
23
|
+
<EnhancedThemeProvider defaultThemeVariant={defaultThemeVariant}>
|
|
24
|
+
{children}
|
|
25
|
+
</EnhancedThemeProvider>
|
|
26
|
+
);
|
|
27
|
+
}
|