@akinon/projectzero 2.0.0-beta.20 → 2.0.0-beta.22
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/CHANGELOG.md +14 -0
- package/app-template/CHANGELOG.md +170 -0
- package/app-template/next.config.mjs +0 -1
- package/app-template/package.json +31 -30
- package/app-template/src/app/[pz]/[...prettyurl]/page.tsx +2 -2
- package/app-template/src/app/[pz]/account/layout.tsx +2 -1
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/blog/[slug]/page.tsx +4 -2
- package/app-template/src/app/[pz]/category/[pk]/page.tsx +11 -1
- package/app-template/src/app/[pz]/group-product/[pk]/page.tsx +2 -2
- package/app-template/src/app/[pz]/layout.tsx +3 -1
- package/app-template/src/app/[pz]/list/page.tsx +11 -1
- package/app-template/src/app/[pz]/page.tsx +13 -35
- package/app-template/src/app/[pz]/pages/[slug]/page.tsx +19 -0
- package/app-template/src/app/[pz]/product/[pk]/page.tsx +2 -2
- package/app-template/src/app/api/barcode-search/route.ts +1 -1
- package/app-template/src/app/api/cache/route.ts +1 -1
- package/app-template/src/app/api/image-proxy/route.ts +1 -1
- package/app-template/src/app/api/logout/route.ts +1 -1
- package/app-template/src/app/api/product-categories/route.ts +1 -1
- package/app-template/src/app/api/similar-product-list/route.ts +1 -1
- package/app-template/src/app/api/similar-products/route.ts +1 -1
- package/app-template/src/app/api/virtual-try-on/route.ts +1 -1
- package/app-template/src/app/api/web-vitals/route.ts +1 -1
- package/app-template/src/components/quantity-selector.tsx +16 -4
- package/app-template/src/components/widget-content.tsx +3 -3
- package/app-template/src/routes/index.ts +6 -6
- package/app-template/src/utils/__tests__/theme-page-context.test.ts +145 -0
- package/app-template/src/utils/theme-page-context.ts +309 -0
- package/app-template/src/views/basket/basket-item.tsx +107 -691
- package/app-template/src/views/basket/index.ts +0 -2
- package/app-template/src/views/basket/summary.tsx +75 -496
- package/app-template/src/views/breadcrumb.tsx +38 -13
- package/app-template/src/views/category/category-header.tsx +66 -289
- package/app-template/src/views/category/category-info.tsx +24 -173
- package/app-template/src/views/category/filters/index.tsx +48 -208
- package/app-template/src/views/category/layout.tsx +5 -7
- package/app-template/src/views/checkout/index.tsx +0 -5
- package/app-template/src/views/checkout/steps/payment/index.tsx +2 -5
- package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +1 -72
- package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +40 -171
- package/app-template/src/views/checkout/steps/shipping/address-box.tsx +12 -74
- package/app-template/src/views/checkout/steps/shipping/addresses.tsx +45 -128
- package/app-template/src/views/checkout/steps/shipping/shipping-options.tsx +27 -232
- package/app-template/src/views/checkout/summary.tsx +29 -303
- package/app-template/src/views/footer.tsx +13 -415
- package/app-template/src/views/guest-login/index.tsx +1 -1
- package/app-template/src/views/header/action-menu.tsx +45 -277
- package/app-template/src/views/header/band.tsx +21 -6
- package/app-template/src/views/header/index.tsx +47 -109
- package/app-template/src/views/header/mini-basket.tsx +45 -820
- package/app-template/src/views/header/navbar.tsx +111 -178
- package/app-template/src/views/header/search/index.tsx +32 -71
- package/app-template/src/views/header/search/results.tsx +65 -127
- package/app-template/src/views/product/accordion-wrapper.tsx +43 -135
- package/app-template/src/views/product/index.ts +1 -1
- package/app-template/src/views/product/layout.tsx +7 -2
- package/app-template/src/views/product/misc-buttons.tsx +25 -339
- package/app-template/src/views/product/product-actions.tsx +8 -137
- package/app-template/src/views/product/product-info.tsx +31 -69
- package/app-template/src/views/product/product-share.tsx +8 -11
- package/app-template/src/views/product/slider.tsx +79 -117
- package/app-template/src/views/product-item/index.tsx +46 -119
- package/app-template/src/widgets/footer-social.tsx +16 -47
- package/app-template/src/widgets/footer-subscription/index.tsx +17 -183
- package/codemods/migrate-auth-v5/index.js +339 -0
- package/codemods/migrate-auth-v5/transform.js +86 -0
- package/dist/commands/plugins.js +23 -2
- package/package.json +1 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/pages/[slug]/page.tsx +0 -15
- package/app-template/src/views/basket/basket-summary-context.tsx +0 -560
- package/app-template/src/views/basket/designer-context.tsx +0 -617
- package/app-template/src/views/breadcrumb/breadcrumb-client.tsx +0 -190
- package/app-template/src/views/breadcrumb/breadcrumb-registrar.tsx +0 -286
- package/app-template/src/views/breadcrumb/constants.ts +0 -15
- package/app-template/src/views/breadcrumb/index.tsx +0 -127
- package/app-template/src/views/category/native-widget-context.tsx +0 -257
- package/app-template/src/views/category/product-list-registrar.tsx +0 -665
- package/app-template/src/views/checkout/checkout-address-registrar.tsx +0 -254
- package/app-template/src/views/checkout/checkout-buttons-registrar.tsx +0 -183
- package/app-template/src/views/checkout/checkout-delivery-method-registrar.tsx +0 -259
- package/app-template/src/views/checkout/checkout-payment-options-registrar.tsx +0 -253
- package/app-template/src/views/checkout/checkout-summary-registrar.tsx +0 -183
- package/app-template/src/views/checkout/constants.ts +0 -5
- package/app-template/src/views/checkout/steps/payment/options/masterpass-rest.tsx +0 -15
- package/app-template/src/views/checkout/steps/payment/options/saved-card.tsx +0 -18
- package/app-template/src/views/footer/footer-app-banner-context.tsx +0 -326
- package/app-template/src/views/footer/footer-bottom-context.tsx +0 -215
- package/app-template/src/views/footer/footer-bottom-wrapper.tsx +0 -74
- package/app-template/src/views/footer/footer-layout-constants.ts +0 -35
- package/app-template/src/views/footer/footer-layout-registrar.tsx +0 -342
- package/app-template/src/views/footer/footer-layout-switcher.tsx +0 -110
- package/app-template/src/views/footer/footer-menu-context.tsx +0 -211
- package/app-template/src/views/footer/footer-native-widgets.tsx +0 -60
- package/app-template/src/views/footer/footer-social-context.tsx +0 -254
- package/app-template/src/views/footer/footer-subscription-context.tsx +0 -210
- package/app-template/src/views/footer/footer-utils.ts +0 -43
- package/app-template/src/views/footer/footer-value-props-context.tsx +0 -326
- package/app-template/src/views/footer/logo-settings.ts +0 -183
- package/app-template/src/views/footer/native-widget-config.ts +0 -262
- package/app-template/src/views/footer/subscription-settings.ts +0 -122
- package/app-template/src/views/footer/use-footer-logo.ts +0 -162
- package/app-template/src/views/header/designer-context.tsx +0 -261
- package/app-template/src/views/header/header-announcement-registrar.tsx +0 -267
- package/app-template/src/views/header/header-client-wrapper.tsx +0 -496
- package/app-template/src/views/header/header-content.tsx +0 -1026
- package/app-template/src/views/header/header-currency-registrar.tsx +0 -348
- package/app-template/src/views/header/header-icons-context.tsx +0 -262
- package/app-template/src/views/header/header-language-registrar.tsx +0 -348
- package/app-template/src/views/header/header-layout-context.tsx +0 -143
- package/app-template/src/views/header/header-layout-registrar.tsx +0 -658
- package/app-template/src/views/header/header-logo-context.tsx +0 -228
- package/app-template/src/views/header/header-logo.tsx +0 -118
- package/app-template/src/views/header/header-mini-basket-context.tsx +0 -524
- package/app-template/src/views/header/header-search-registrar.tsx +0 -511
- package/app-template/src/views/header/header-text-slider-registrar.tsx +0 -382
- package/app-template/src/views/header/inline-search.tsx +0 -262
- package/app-template/src/views/header/navbar-menu-context.tsx +0 -219
- package/app-template/src/views/header/search/search-input.tsx +0 -61
- package/app-template/src/views/header/server-settings-parser.ts +0 -1105
- package/app-template/src/views/header/use-header-icons.ts +0 -241
- package/app-template/src/views/header/use-header-logo.ts +0 -213
- package/app-template/src/views/header/use-navbar-menu.ts +0 -179
- package/app-template/src/views/product/accordion-section.tsx +0 -61
- package/app-template/src/views/product/custom-button-group.tsx +0 -69
- package/app-template/src/views/product/favorites-button-section.tsx +0 -69
- package/app-template/src/views/product/find-in-store-section.tsx +0 -60
- package/app-template/src/views/product/product-info-section.tsx +0 -140
- package/app-template/src/views/product/quantity-section.tsx +0 -73
- package/app-template/src/views/product/sale-tag.tsx +0 -10
- package/app-template/src/views/product/share-section.tsx +0 -357
- package/app-template/src/views/product/variants-section.tsx +0 -126
- package/app-template/src/views/product-detail/constants.ts +0 -272
- package/app-template/src/views/product-detail/index.ts +0 -10
- package/app-template/src/views/product-detail/product-detail-registrar.tsx +0 -616
- package/app-template/src/widgets/footer-app-banner.tsx +0 -444
- package/app-template/src/widgets/footer-bottom.tsx +0 -127
- package/app-template/src/widgets/footer-menu-compact.tsx +0 -238
- package/app-template/src/widgets/footer-menu-two.tsx +0 -298
- package/app-template/src/widgets/footer-social-client.tsx +0 -251
- package/app-template/src/widgets/footer-value-props.tsx +0 -201
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
createContext,
|
|
5
|
-
PropsWithChildren,
|
|
6
|
-
useCallback,
|
|
7
|
-
useContext,
|
|
8
|
-
useEffect,
|
|
9
|
-
useRef,
|
|
10
|
-
useState
|
|
11
|
-
} from 'react';
|
|
12
|
-
import { useExternalDesigner } from '@akinon/next/components/theme-editor/hooks/use-external-designer';
|
|
13
|
-
import { useNativeWidgetData } from '@akinon/next/components/theme-editor/hooks/use-native-widget-data';
|
|
14
|
-
|
|
15
|
-
export const HEADER_LOGO_PLACEHOLDER_ID = 'header';
|
|
16
|
-
export const HEADER_LOGO_SECTION_ID = 'header-logo';
|
|
17
|
-
export const HEADER_LOGO_WIDGET_SLUG = 'header-logo-settings-2';
|
|
18
|
-
|
|
19
|
-
export const HEADER_LOGO_BLOCK = {
|
|
20
|
-
id: 'header-logo-image',
|
|
21
|
-
type: 'image',
|
|
22
|
-
label: 'Logo Image'
|
|
23
|
-
} as const;
|
|
24
|
-
|
|
25
|
-
const BLOCK_META = [HEADER_LOGO_BLOCK];
|
|
26
|
-
|
|
27
|
-
interface ThemeBlock {
|
|
28
|
-
id: string;
|
|
29
|
-
type: string;
|
|
30
|
-
label: string;
|
|
31
|
-
styles?: Record<string, unknown>;
|
|
32
|
-
properties?: Record<string, unknown>;
|
|
33
|
-
value?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface ThemeSection {
|
|
37
|
-
id: string;
|
|
38
|
-
blocks: ThemeBlock[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface ThemePlaceholder {
|
|
42
|
-
slug: string;
|
|
43
|
-
sections: ThemeSection[];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface HeaderLogoContextValue {
|
|
47
|
-
isDesigner: boolean;
|
|
48
|
-
selectedBlockId: string | null;
|
|
49
|
-
getBlockStyles: (blockId: string) => Record<string, unknown> | undefined;
|
|
50
|
-
getBlockProperties: (blockId: string) => Record<string, unknown> | undefined;
|
|
51
|
-
getBlockValue: (blockId: string) => string | undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const HeaderLogoContext = createContext<HeaderLogoContextValue>({
|
|
55
|
-
isDesigner: false,
|
|
56
|
-
selectedBlockId: null,
|
|
57
|
-
getBlockStyles: () => undefined,
|
|
58
|
-
getBlockProperties: () => undefined,
|
|
59
|
-
getBlockValue: () => undefined
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export const HeaderLogoProvider = ({ children }: PropsWithChildren) => {
|
|
63
|
-
const designerState = useExternalDesigner({
|
|
64
|
-
placeholderId: HEADER_LOGO_PLACEHOLDER_ID
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const isDesignerRef = useRef(false);
|
|
68
|
-
const [isDesignerChecked, setIsDesignerChecked] = useState(false);
|
|
69
|
-
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (typeof window === 'undefined') return;
|
|
72
|
-
isDesignerRef.current = window.self !== window.top;
|
|
73
|
-
setIsDesignerChecked(true);
|
|
74
|
-
}, []);
|
|
75
|
-
|
|
76
|
-
const isDesigner = isDesignerRef.current;
|
|
77
|
-
|
|
78
|
-
const [themeBlocks, setThemeBlocks] = useState<Map<string, ThemeBlock>>(
|
|
79
|
-
new Map()
|
|
80
|
-
);
|
|
81
|
-
const hasReceivedThemeStyles = useRef(false);
|
|
82
|
-
const hasRegisteredNativeWidget = useRef(false);
|
|
83
|
-
const themeBlocksRef = useRef<Map<string, ThemeBlock>>(new Map());
|
|
84
|
-
|
|
85
|
-
const widgetData = useNativeWidgetData({
|
|
86
|
-
widgetSlug: HEADER_LOGO_WIDGET_SLUG,
|
|
87
|
-
sectionId: HEADER_LOGO_SECTION_ID,
|
|
88
|
-
skip: !isDesignerChecked || isDesigner,
|
|
89
|
-
blockMeta: BLOCK_META
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const getBlockWithStyles = useCallback(
|
|
93
|
-
(blockDef: typeof HEADER_LOGO_BLOCK) => {
|
|
94
|
-
const existingBlock = themeBlocksRef.current.get(blockDef.id);
|
|
95
|
-
return {
|
|
96
|
-
id: blockDef.id,
|
|
97
|
-
type: blockDef.type,
|
|
98
|
-
label: blockDef.label,
|
|
99
|
-
properties: existingBlock?.properties || {},
|
|
100
|
-
styles: existingBlock?.styles || {},
|
|
101
|
-
value: existingBlock?.value
|
|
102
|
-
};
|
|
103
|
-
},
|
|
104
|
-
[]
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
if (hasRegisteredNativeWidget.current) return;
|
|
109
|
-
|
|
110
|
-
const isInIframe =
|
|
111
|
-
typeof window !== 'undefined' && window.self !== window.top;
|
|
112
|
-
if (!isInIframe || !window.parent) return;
|
|
113
|
-
|
|
114
|
-
const nativeWidgetConfig = {
|
|
115
|
-
placeholderId: HEADER_LOGO_PLACEHOLDER_ID,
|
|
116
|
-
section: {
|
|
117
|
-
id: HEADER_LOGO_SECTION_ID,
|
|
118
|
-
type: 'native',
|
|
119
|
-
label: 'Logo',
|
|
120
|
-
blocks: [getBlockWithStyles(HEADER_LOGO_BLOCK)]
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
window.parent.postMessage(
|
|
125
|
-
{
|
|
126
|
-
type: 'REGISTER_NATIVE_WIDGETS',
|
|
127
|
-
data: { widgets: [nativeWidgetConfig] }
|
|
128
|
-
},
|
|
129
|
-
'*'
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
hasRegisteredNativeWidget.current = true;
|
|
133
|
-
}, [getBlockWithStyles]);
|
|
134
|
-
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (!isDesignerChecked || isDesigner || widgetData.isLoading) return;
|
|
137
|
-
if (hasReceivedThemeStyles.current) return;
|
|
138
|
-
|
|
139
|
-
const blockMap = new Map<string, ThemeBlock>();
|
|
140
|
-
widgetData.blocks.forEach((block) => {
|
|
141
|
-
blockMap.set(block.id, {
|
|
142
|
-
id: block.id,
|
|
143
|
-
type: block.type || 'image',
|
|
144
|
-
label: block.label || block.id,
|
|
145
|
-
styles: block.styles,
|
|
146
|
-
properties: block.properties,
|
|
147
|
-
value: block.value as string | undefined
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
if (blockMap.size > 0) {
|
|
152
|
-
setThemeBlocks(blockMap);
|
|
153
|
-
themeBlocksRef.current = blockMap;
|
|
154
|
-
}
|
|
155
|
-
}, [isDesignerChecked, isDesigner, widgetData.isLoading, widgetData.blocks]);
|
|
156
|
-
|
|
157
|
-
const indexBlocks = useCallback(
|
|
158
|
-
(blocks: ThemeBlock[], map: Map<string, ThemeBlock>) => {
|
|
159
|
-
blocks.forEach((block) => {
|
|
160
|
-
map.set(block.id, block);
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
[]
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
const handleMessage = (event: MessageEvent) => {
|
|
168
|
-
const { type, data } = event.data || {};
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
(type === 'UPDATE_THEME' || type === 'LOAD_THEME') &&
|
|
172
|
-
data?.theme?.placeholders
|
|
173
|
-
) {
|
|
174
|
-
const placeholder = data.theme.placeholders?.find(
|
|
175
|
-
(p: ThemePlaceholder) => p.slug === HEADER_LOGO_PLACEHOLDER_ID
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
const headerLogoSection = placeholder?.sections?.find(
|
|
179
|
-
(s: ThemeSection) => s.id === HEADER_LOGO_SECTION_ID
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
if (headerLogoSection) {
|
|
183
|
-
const blockMap = new Map<string, ThemeBlock>();
|
|
184
|
-
indexBlocks(headerLogoSection.blocks, blockMap);
|
|
185
|
-
|
|
186
|
-
if (blockMap.size > 0) {
|
|
187
|
-
hasReceivedThemeStyles.current = true;
|
|
188
|
-
setThemeBlocks(blockMap);
|
|
189
|
-
themeBlocksRef.current = blockMap;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
window.addEventListener('message', handleMessage);
|
|
196
|
-
return () => window.removeEventListener('message', handleMessage);
|
|
197
|
-
}, [indexBlocks]);
|
|
198
|
-
|
|
199
|
-
const getBlockStyles = useCallback(
|
|
200
|
-
(blockId: string) => themeBlocks.get(blockId)?.styles,
|
|
201
|
-
[themeBlocks]
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const getBlockProperties = useCallback(
|
|
205
|
-
(blockId: string) => themeBlocks.get(blockId)?.properties,
|
|
206
|
-
[themeBlocks]
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
const getBlockValue = useCallback(
|
|
210
|
-
(blockId: string) => themeBlocks.get(blockId)?.value,
|
|
211
|
-
[themeBlocks]
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<HeaderLogoContext.Provider
|
|
216
|
-
value={{
|
|
217
|
-
...designerState,
|
|
218
|
-
getBlockStyles,
|
|
219
|
-
getBlockProperties,
|
|
220
|
-
getBlockValue
|
|
221
|
-
}}
|
|
222
|
-
>
|
|
223
|
-
{children}
|
|
224
|
-
</HeaderLogoContext.Provider>
|
|
225
|
-
);
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
export const useHeaderLogoDesigner = () => useContext(HeaderLogoContext);
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Link } from '@theme/components';
|
|
4
|
-
import { ROUTES } from '@theme/routes';
|
|
5
|
-
import { Image } from '@akinon/next/components/image';
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
import { useHeaderLogoSettings } from './use-header-logo';
|
|
8
|
-
import { useDesignerFeatures } from '@akinon/next/components/theme-editor/hooks/use-designer-features';
|
|
9
|
-
import {
|
|
10
|
-
HeaderLogoProvider,
|
|
11
|
-
useHeaderLogoDesigner,
|
|
12
|
-
HEADER_LOGO_PLACEHOLDER_ID,
|
|
13
|
-
HEADER_LOGO_SECTION_ID,
|
|
14
|
-
HEADER_LOGO_BLOCK
|
|
15
|
-
} from './header-logo-context';
|
|
16
|
-
import { LogoSettings } from './server-settings-parser';
|
|
17
|
-
|
|
18
|
-
interface SelectableLogoProps {
|
|
19
|
-
fallbackSrc: string;
|
|
20
|
-
initialSettings?: LogoSettings;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function SelectableLogo({ fallbackSrc, initialSettings }: SelectableLogoProps) {
|
|
24
|
-
const logoSettings = useHeaderLogoSettings(initialSettings);
|
|
25
|
-
const { isDesigner, selectedBlockId } = useHeaderLogoDesigner();
|
|
26
|
-
|
|
27
|
-
const { handleClick } = useDesignerFeatures({
|
|
28
|
-
blockId: HEADER_LOGO_BLOCK.id,
|
|
29
|
-
placeholderId: HEADER_LOGO_PLACEHOLDER_ID,
|
|
30
|
-
sectionId: HEADER_LOGO_SECTION_ID,
|
|
31
|
-
isDesigner,
|
|
32
|
-
blockInfo: {
|
|
33
|
-
id: HEADER_LOGO_BLOCK.id,
|
|
34
|
-
type: HEADER_LOGO_BLOCK.type,
|
|
35
|
-
label: HEADER_LOGO_BLOCK.label
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const isSelected = selectedBlockId === HEADER_LOGO_BLOCK.id;
|
|
40
|
-
const logoSrc = logoSettings.src || fallbackSrc;
|
|
41
|
-
|
|
42
|
-
// Parse width/height - could be number or string with unit
|
|
43
|
-
const parseSize = (
|
|
44
|
-
value: number | string | undefined,
|
|
45
|
-
defaultValue: number
|
|
46
|
-
): number | string => {
|
|
47
|
-
if (value === undefined) return defaultValue;
|
|
48
|
-
if (typeof value === 'number') return value;
|
|
49
|
-
// If it's a string with unit like "120px" or "100%", return as is
|
|
50
|
-
if (typeof value === 'string') {
|
|
51
|
-
const numValue = parseInt(value, 10);
|
|
52
|
-
return isNaN(numValue) ? defaultValue : numValue;
|
|
53
|
-
}
|
|
54
|
-
return defaultValue;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const width = parseSize(logoSettings.width, 80);
|
|
58
|
-
const height = parseSize(logoSettings.height, 20);
|
|
59
|
-
|
|
60
|
-
const logoElement = (
|
|
61
|
-
<Image
|
|
62
|
-
src={logoSrc}
|
|
63
|
-
alt="Logo"
|
|
64
|
-
width={typeof width === 'number' ? width : 80}
|
|
65
|
-
height={typeof height === 'number' ? height : 20}
|
|
66
|
-
className="block w-full"
|
|
67
|
-
style={{
|
|
68
|
-
maxWidth: logoSettings.maxWidth,
|
|
69
|
-
maxHeight: logoSettings.maxHeight,
|
|
70
|
-
objectFit: logoSettings.objectFit
|
|
71
|
-
}}
|
|
72
|
-
unoptimized
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
if (isDesigner) {
|
|
77
|
-
return (
|
|
78
|
-
<span
|
|
79
|
-
data-block-id={HEADER_LOGO_BLOCK.id}
|
|
80
|
-
onClick={handleClick}
|
|
81
|
-
className={clsx(
|
|
82
|
-
'relative cursor-pointer inline-block',
|
|
83
|
-
isSelected && 'ring-2 ring-blue-500 ring-offset-1 rounded'
|
|
84
|
-
)}
|
|
85
|
-
>
|
|
86
|
-
{logoElement}
|
|
87
|
-
</span>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return logoElement;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface HeaderLogoProps {
|
|
95
|
-
fallbackSrc: string;
|
|
96
|
-
initialSettings?: LogoSettings;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export default function HeaderLogo({
|
|
100
|
-
fallbackSrc,
|
|
101
|
-
initialSettings
|
|
102
|
-
}: HeaderLogoProps) {
|
|
103
|
-
return (
|
|
104
|
-
<HeaderLogoProvider>
|
|
105
|
-
<Link
|
|
106
|
-
href={ROUTES.HOME}
|
|
107
|
-
passHref={true}
|
|
108
|
-
className="self-center block pl-3 sm:justify-self-center sm:p-0"
|
|
109
|
-
aria-label="Homepage"
|
|
110
|
-
>
|
|
111
|
-
<SelectableLogo
|
|
112
|
-
fallbackSrc={fallbackSrc}
|
|
113
|
-
initialSettings={initialSettings}
|
|
114
|
-
/>
|
|
115
|
-
</Link>
|
|
116
|
-
</HeaderLogoProvider>
|
|
117
|
-
);
|
|
118
|
-
}
|