Fix button roundtrip in editor, alignment persistence, and test email rendering
This commit is contained in:
@@ -56,22 +56,42 @@ const getAppearanceSettings = () => {
|
||||
return (window as any).woonoowCustomer?.appearanceSettings || {};
|
||||
};
|
||||
|
||||
// Get initial route from data attribute (set by PHP based on SPA mode)
|
||||
// Get initial route from data attribute or derive from SPA mode
|
||||
const getInitialRoute = () => {
|
||||
const appEl = document.getElementById('woonoow-customer-app');
|
||||
const initialRoute = appEl?.getAttribute('data-initial-route');
|
||||
return initialRoute || '/shop'; // Default to shop if not specified
|
||||
if (initialRoute) return initialRoute;
|
||||
|
||||
// Derive from SPA mode if no explicit route
|
||||
const spaMode = (window as any).woonoowCustomer?.spaMode || 'full';
|
||||
if (spaMode === 'checkout_only') return '/checkout';
|
||||
return '/shop'; // Default for full mode
|
||||
};
|
||||
|
||||
// Get front page slug from config
|
||||
const getFrontPageSlug = () => {
|
||||
return (window as any).woonoowCustomer?.frontPageSlug || null;
|
||||
};
|
||||
|
||||
// Router wrapper component that uses hooks requiring Router context
|
||||
function AppRoutes() {
|
||||
const initialRoute = getInitialRoute();
|
||||
const frontPageSlug = getFrontPageSlug();
|
||||
|
||||
return (
|
||||
<BaseLayout>
|
||||
<Routes>
|
||||
{/* Root route redirects to initial route based on SPA mode */}
|
||||
<Route path="/" element={<Navigate to={initialRoute} replace />} />
|
||||
{/* Root route: If frontPageSlug exists, render it. Else redirect to initialRoute (e.g. /shop) */}
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
frontPageSlug ? (
|
||||
<DynamicPageRenderer slug={frontPageSlug} />
|
||||
) : (
|
||||
<Navigate to={initialRoute === '/' ? '/shop' : initialRoute} replace />
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
{/* Shop Routes */}
|
||||
<Route path="/shop" element={<Shop />} />
|
||||
@@ -128,6 +148,24 @@ function App() {
|
||||
const appearanceSettings = getAppearanceSettings();
|
||||
const toastPosition = (appearanceSettings?.general?.toast_position || 'top-right') as any;
|
||||
|
||||
// Inject gradient CSS variables
|
||||
React.useEffect(() => {
|
||||
// appearanceSettings is already the 'data' object from Assets.php injection
|
||||
// Structure: { general: { colors: { primary, secondary, accent, text, background, gradientStart, gradientEnd } } }
|
||||
const colors = appearanceSettings?.general?.colors;
|
||||
if (colors) {
|
||||
const root = document.documentElement;
|
||||
// Inject all color settings as CSS variables
|
||||
if (colors.primary) root.style.setProperty('--wn-primary', colors.primary);
|
||||
if (colors.secondary) root.style.setProperty('--wn-secondary', colors.secondary);
|
||||
if (colors.accent) root.style.setProperty('--wn-accent', colors.accent);
|
||||
if (colors.text) root.style.setProperty('--wn-text', colors.text);
|
||||
if (colors.background) root.style.setProperty('--wn-background', colors.background);
|
||||
if (colors.gradientStart) root.style.setProperty('--wn-gradient-start', colors.gradientStart);
|
||||
if (colors.gradientEnd) root.style.setProperty('--wn-gradient-end', colors.gradientEnd);
|
||||
}
|
||||
}, [appearanceSettings]);
|
||||
|
||||
return (
|
||||
<HelmetProvider>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
|
||||
Reference in New Issue
Block a user