feat/fix: checkout email tracing, UI tweaks for add-to-cart, cart page overflow fix, implement hide admin bar setting
This commit is contained in:
47
customer-spa/src/lib/sectionStyles.ts
Normal file
47
customer-spa/src/lib/sectionStyles.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Shared utility to compute background styles from section styles.
|
||||
* Used by all customer SPA section components.
|
||||
*/
|
||||
export function getSectionBackground(styles?: Record<string, any>): {
|
||||
style: React.CSSProperties;
|
||||
hasOverlay: boolean;
|
||||
overlayOpacity: number;
|
||||
backgroundImage?: string;
|
||||
} {
|
||||
if (!styles) {
|
||||
return { style: {}, hasOverlay: false, overlayOpacity: 0 };
|
||||
}
|
||||
|
||||
const bgType = styles.backgroundType || 'solid';
|
||||
let style: React.CSSProperties = {};
|
||||
let hasOverlay = false;
|
||||
let overlayOpacity = 0;
|
||||
let backgroundImage: string | undefined;
|
||||
|
||||
switch (bgType) {
|
||||
case 'gradient':
|
||||
style.background = `linear-gradient(${styles.gradientAngle ?? 135}deg, ${styles.gradientFrom || '#9333ea'}, ${styles.gradientTo || '#3b82f6'})`;
|
||||
break;
|
||||
case 'image':
|
||||
if (styles.backgroundImage) {
|
||||
backgroundImage = styles.backgroundImage;
|
||||
overlayOpacity = (styles.backgroundOverlay || 0) / 100;
|
||||
hasOverlay = overlayOpacity > 0;
|
||||
}
|
||||
break;
|
||||
case 'solid':
|
||||
default:
|
||||
if (styles.backgroundColor) {
|
||||
style.backgroundColor = styles.backgroundColor;
|
||||
}
|
||||
// Legacy: if backgroundImage exists without explicit type
|
||||
if (!styles.backgroundType && styles.backgroundImage) {
|
||||
backgroundImage = styles.backgroundImage;
|
||||
overlayOpacity = (styles.backgroundOverlay || 0) / 100;
|
||||
hasOverlay = overlayOpacity > 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return { style, hasOverlay, overlayOpacity, backgroundImage };
|
||||
}
|
||||
Reference in New Issue
Block a user