@designcrowd/library.brand-page 6.1.7 → 6.1.8-ast-header
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/lib/src/{CreatedOnBrandCrowd-de-de-Dh3Paq4X.js → CreatedOnBrandCrowd-de-de-CmXTpyAA.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-DLWYV4xe.js → CreatedOnBrandCrowd-en-us-FUfcPskv.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-CcjzRbm_.js → CreatedOnBrandCrowd-es-es-BkRUovXn.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-UuUNeB_L.js → CreatedOnBrandCrowd-fr-ca-xsLZEhPK.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-UuUNeB_L.js → CreatedOnBrandCrowd-fr-fr-xsLZEhPK.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-ZVYZ5AnV.js → CreatedOnBrandCrowd-pt-br-BJ4DkilI.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-ZVYZ5AnV.js → CreatedOnBrandCrowd-pt-pt-BJ4DkilI.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-BPVyqOPL.js → CreatedOnDcom-de-de-D7f4iceH.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-BUSRV01e.js → CreatedOnDcom-en-us-BHbqZcVl.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-BuABJnvQ.js → CreatedOnDcom-es-es-BT_eFhYg.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-sjHceLRY.js → CreatedOnDcom-fr-ca-DCWCvJTS.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-D_qGXL3E.js → CreatedOnDcom-fr-fr-DpLretAn.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-D3Sb_YEi.js → CreatedOnDcom-pt-br-DmyQqot9.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-BI47Hv58.js → CreatedOnDcom-pt-pt-CRLWHfnY.js} +1 -1
- package/lib/src/brand-page/components/page-footer/PageFooter.mixin.d.ts +0 -1
- package/lib/src/brand-page/components/page-footer/PageFooter.mixin.js +1 -4
- package/lib/src/brand-page/utils/route.util.d.ts +12 -0
- package/lib/src/brand-page/utils/route.util.js +56 -0
- package/lib/src/brand-page-maker/components/index.d.ts +1 -0
- package/lib/src/brand-page-maker/components/index.js +1 -0
- package/lib/src/bundled-translations-BlUyLdcg.js +179 -0
- package/lib/src/bundled-translations.de-DE-DZm_F46B.js +179 -0
- package/lib/src/bundled-translations.es-ES-DiOMEwZz.js +179 -0
- package/lib/src/bundled-translations.fr-CA-BPBNxV69.js +179 -0
- package/lib/src/bundled-translations.fr-FR-bCNdWkJW.js +179 -0
- package/lib/src/bundled-translations.pt-BR-CC6okekB.js +179 -0
- package/lib/src/bundled-translations.pt-PT-CSgMSLFn.js +179 -0
- package/lib/src/bundles/bundled-translations.de-DE.json +5 -4
- package/lib/src/bundles/bundled-translations.es-ES.json +5 -4
- package/lib/src/bundles/bundled-translations.fr-CA.json +5 -4
- package/lib/src/bundles/bundled-translations.fr-FR.json +5 -4
- package/lib/src/bundles/bundled-translations.json +9 -4
- package/lib/src/bundles/bundled-translations.pt-BR.json +5 -4
- package/lib/src/bundles/bundled-translations.pt-PT.json +5 -4
- package/lib/src/css/library.brand-page-brandCrowd.min.css +159 -222
- package/lib/src/css/library.brand-page-brandPage.min.css +159 -222
- package/lib/src/css/library.brand-page-designCom.min.css +159 -222
- package/lib/src/css/library.brand-page-preview.min.css +159 -222
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.mjs +110 -109
- package/lib/src/{lib-BBX3eBci.js → lib-CZMytXbN.js} +19842 -19669
- package/lib/src/lib.js +1 -1
- package/lib/src/shared/components/live-preview-modal/live-preview-modal.utils.d.ts +4 -0
- package/lib/src/shared/components/live-preview-modal/live-preview-modal.utils.js +3 -0
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +3 -1
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.js +23 -11
- package/package.json +1 -1
- package/src/brand-page/components/button/Button.vue +41 -18
- package/src/brand-page/components/button/Button.vue.test.ts +211 -0
- package/src/brand-page/components/images-section/ImagesSection.test.ts +91 -0
- package/src/brand-page/components/images-section/ImagesSection.vue +29 -10
- package/src/brand-page/components/page-footer/PageFooter.mixin.ts +1 -4
- package/src/brand-page/components/page-footer/PageFooter.vue +0 -1
- package/src/brand-page/components/payment/Payment.vue +0 -3
- package/src/brand-page/components/payment/request-payment/RequestPayment.vue +0 -1
- package/src/brand-page/components/payment/support-me/SupportMe.vue +0 -3
- package/src/brand-page/components/save-contact/SaveContactWidget.vue +1 -0
- package/src/brand-page/components/save-contact/popup-card/PopupCard.vue +1 -0
- package/src/brand-page/components/shop/CartModal.test.ts +51 -0
- package/src/brand-page/components/shop/CartModal.vue +1 -0
- package/src/brand-page/components/shop/FeaturedDisplay.vue +8 -3
- package/src/brand-page/components/shop/Shop.vue +5 -5
- package/src/brand-page/components/shop/Shop.vue.test.ts +104 -2
- package/src/brand-page/components/social-links/SocialLinks.vue +1 -9
- package/src/brand-page/components/social-links/SocialLinks.vue.test.ts +28 -8
- package/src/brand-page/components/social-links/SocialLinksItems.vue +6 -2
- package/src/brand-page/components/testimonial-section/TestimonialSection.vue +2 -2
- package/src/brand-page/components/video/Video.vue +0 -3
- package/src/brand-page/utils/route.util.test.ts +116 -0
- package/src/brand-page/utils/route.util.ts +82 -0
- package/src/brand-page-maker/components/action-bar/ActionBarNavigation.test.ts +23 -0
- package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.preview-gate.test.ts +68 -3
- package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.vue +1 -0
- package/src/brand-page-maker/components/index.ts +1 -0
- package/src/brand-page-maker/components/preview-modal/PreviewModalWithState.test.ts +61 -41
- package/src/brand-page-maker/components/preview-modal/PreviewModalWithState.vue +37 -42
- package/src/bundles/bundled-translations.de-DE.json +5 -4
- package/src/bundles/bundled-translations.es-ES.json +5 -4
- package/src/bundles/bundled-translations.fr-CA.json +5 -4
- package/src/bundles/bundled-translations.fr-FR.json +5 -4
- package/src/bundles/bundled-translations.json +9 -4
- package/src/bundles/bundled-translations.pt-BR.json +5 -4
- package/src/bundles/bundled-translations.pt-PT.json +5 -4
- package/src/lib.ts +1 -0
- package/src/{brand-page-maker/components/preview-modal/PreviewModal.test.ts → shared/components/live-preview-modal/LivePreviewModal.test.ts} +96 -3
- package/src/{brand-page-maker/components/preview-modal/PreviewModal.vue → shared/components/live-preview-modal/LivePreviewModal.vue} +103 -89
- package/src/shared/components/live-preview-modal/i18n/preview-modal.de-DE.json +7 -0
- package/src/shared/components/live-preview-modal/i18n/preview-modal.es-ES.json +7 -0
- package/src/shared/components/live-preview-modal/i18n/preview-modal.fr-CA.json +7 -0
- package/src/shared/components/live-preview-modal/i18n/preview-modal.fr-FR.json +7 -0
- package/src/shared/components/live-preview-modal/i18n/preview-modal.json +7 -0
- package/src/shared/components/live-preview-modal/i18n/preview-modal.pt-BR.json +7 -0
- package/src/shared/components/live-preview-modal/i18n/preview-modal.pt-PT.json +7 -0
- package/src/shared/components/live-preview-modal/live-preview-modal.utils.ts +11 -0
- package/src/shared/ecommerce-settings/store/cart-store.test.ts +38 -0
- package/src/shared/page-settings/components/header-settings-panel/HeaderSettingsPanel.vue +205 -0
- package/src/shared/page-settings/components/page-settings/PageSettings.header-settings-panel.test.ts +97 -0
- package/src/shared/page-settings/components/page-settings/PageSettings.mixin.ts +27 -12
- package/src/shared/page-settings/components/page-settings/PageSettings.vue +113 -92
- package/src/shared/page-settings/components/page-settings/i18n/page-settings.json +4 -0
- package/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.vue +1 -57
- package/lib/src/bundled-translations-D42tE0D2.js +0 -179
- package/lib/src/bundled-translations.de-DE-D9aWGgFt.js +0 -179
- package/lib/src/bundled-translations.es-ES-lk4B0xQ7.js +0 -179
- package/lib/src/bundled-translations.fr-CA-DhOBNt6q.js +0 -179
- package/lib/src/bundled-translations.fr-FR-CnpafQeG.js +0 -179
- package/lib/src/bundled-translations.pt-BR-C4PnKrd9.js +0 -179
- package/lib/src/bundled-translations.pt-PT-CfKDVQC-.js +0 -179
- package/src/brand-page-maker/components/preview-modal/i18n/preview-modal.de-DE.json +0 -6
- package/src/brand-page-maker/components/preview-modal/i18n/preview-modal.es-ES.json +0 -6
- package/src/brand-page-maker/components/preview-modal/i18n/preview-modal.fr-CA.json +0 -6
- package/src/brand-page-maker/components/preview-modal/i18n/preview-modal.fr-FR.json +0 -6
- package/src/brand-page-maker/components/preview-modal/i18n/preview-modal.json +0 -6
- package/src/brand-page-maker/components/preview-modal/i18n/preview-modal.pt-BR.json +0 -6
- package/src/brand-page-maker/components/preview-modal/i18n/preview-modal.pt-PT.json +0 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, test, expect, afterEach, vi } from 'vitest';
|
|
2
2
|
import { mount } from '@vue/test-utils';
|
|
3
|
-
import
|
|
3
|
+
import LivePreviewModal from './LivePreviewModal.vue';
|
|
4
4
|
import { LIVE_PREVIEW_MESSAGES } from '@src/constants/live-preview.constants';
|
|
5
5
|
|
|
6
6
|
vi.mock('@designcrowd/fe-shared-lib', () => ({
|
|
@@ -20,7 +20,7 @@ vi.mock('@src/composables/useTranslate', () => ({
|
|
|
20
20
|
const PREVIEW_URL = 'https://brand.site/_p/request?token=signed';
|
|
21
21
|
|
|
22
22
|
const mountModal = (props: Record<string, unknown> = {}) =>
|
|
23
|
-
mount(
|
|
23
|
+
mount(LivePreviewModal, {
|
|
24
24
|
attachTo: document.body,
|
|
25
25
|
props: { visible: true, previewUrl: PREVIEW_URL, ...props },
|
|
26
26
|
});
|
|
@@ -44,7 +44,7 @@ const postReady = () =>
|
|
|
44
44
|
}),
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
-
describe('
|
|
47
|
+
describe('LivePreviewModal', () => {
|
|
48
48
|
// `load` fires while a banner video still has no displayable frame, so revealing
|
|
49
49
|
// on it showed an empty banner. Only the preview's own `ready` reveals now.
|
|
50
50
|
test('holds the loader through frame load, and reveals on ready', async () => {
|
|
@@ -66,6 +66,23 @@ describe('PreviewModal', () => {
|
|
|
66
66
|
expect(frame().className).not.toContain('tw-opacity-0');
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
// No URL yet (the save is still in flight) → the loader covers the wait, and it
|
|
70
|
+
// clears once the frame reports painted.
|
|
71
|
+
test('shows the loader while there is no url, and hides once the frame is ready', async () => {
|
|
72
|
+
const wrapper = mountModal({ previewUrl: '' });
|
|
73
|
+
|
|
74
|
+
expect(loader()).not.toBeNull();
|
|
75
|
+
|
|
76
|
+
await wrapper.setProps({ previewUrl: PREVIEW_URL });
|
|
77
|
+
expect(loader()).not.toBeNull();
|
|
78
|
+
|
|
79
|
+
await frame().dispatchEvent(new Event('load'));
|
|
80
|
+
postReady();
|
|
81
|
+
await wrapper.vm.$nextTick();
|
|
82
|
+
|
|
83
|
+
expect(loader()).toBeNull();
|
|
84
|
+
});
|
|
85
|
+
|
|
69
86
|
// A preview that never reports must not strand the customer on a spinner.
|
|
70
87
|
test('reveals on the fallback timer when ready never arrives', async () => {
|
|
71
88
|
vi.useFakeTimers();
|
|
@@ -101,6 +118,82 @@ describe('PreviewModal', () => {
|
|
|
101
118
|
expect(loader()).not.toBeNull();
|
|
102
119
|
});
|
|
103
120
|
|
|
121
|
+
const deviceToggle = (mode: 'desktop' | 'mobile') =>
|
|
122
|
+
document.body.querySelector<HTMLButtonElement>(
|
|
123
|
+
`[data-test-preview-device-${mode}]`,
|
|
124
|
+
) as HTMLButtonElement;
|
|
125
|
+
|
|
126
|
+
// The toggle drives the frame off internal state — no parent has to re-pass a prop.
|
|
127
|
+
test('clicking the mobile toggle switches the frame to the mobile bezel on its own', async () => {
|
|
128
|
+
const wrapper = mountModal();
|
|
129
|
+
|
|
130
|
+
expect(frame().className).toContain('tw-w-full');
|
|
131
|
+
|
|
132
|
+
deviceToggle('mobile').click();
|
|
133
|
+
await wrapper.vm.$nextTick();
|
|
134
|
+
|
|
135
|
+
expect(frame().className).toContain('tw-w-[358px]');
|
|
136
|
+
|
|
137
|
+
deviceToggle('desktop').click();
|
|
138
|
+
await wrapper.vm.$nextTick();
|
|
139
|
+
|
|
140
|
+
expect(frame().className).toContain('tw-w-full');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Each open re-seeds from defaultDeviceMode regardless of the last session's toggle.
|
|
144
|
+
test('resets to the default device mode on each open', async () => {
|
|
145
|
+
const wrapper = mountModal({
|
|
146
|
+
visible: false,
|
|
147
|
+
defaultDeviceMode: 'desktop',
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
await wrapper.setProps({ visible: true });
|
|
151
|
+
expect(frame().className).toContain('tw-w-full');
|
|
152
|
+
|
|
153
|
+
deviceToggle('mobile').click();
|
|
154
|
+
await wrapper.vm.$nextTick();
|
|
155
|
+
expect(frame().className).toContain('tw-w-[358px]');
|
|
156
|
+
|
|
157
|
+
await wrapper.setProps({ visible: false });
|
|
158
|
+
await wrapper.setProps({ visible: true });
|
|
159
|
+
|
|
160
|
+
expect(frame().className).toContain('tw-w-full');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// happy-dom has no matchMedia so isSmallScreen stays false and the toggle shows.
|
|
164
|
+
test('shows the device toggle when the screen is not small', () => {
|
|
165
|
+
mountModal();
|
|
166
|
+
|
|
167
|
+
expect(deviceToggle('desktop')).not.toBeNull();
|
|
168
|
+
expect(deviceToggle('mobile')).not.toBeNull();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// The shell owns this now (no consumer prop): on a small screen it hides the toggle
|
|
172
|
+
// and pins the frame to desktop, since a phone bezel inside a phone makes no sense.
|
|
173
|
+
test('hides the toggle and forces desktop on a small screen', async () => {
|
|
174
|
+
const matchMedia = vi.fn().mockReturnValue({
|
|
175
|
+
matches: true,
|
|
176
|
+
addEventListener: vi.fn(),
|
|
177
|
+
removeEventListener: vi.fn(),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
vi.stubGlobal('matchMedia', matchMedia);
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
const wrapper = mountModal({ defaultDeviceMode: 'mobile' });
|
|
184
|
+
|
|
185
|
+
await wrapper.vm.$nextTick();
|
|
186
|
+
|
|
187
|
+
expect(matchMedia).toHaveBeenCalledWith('(max-width: 1023px)');
|
|
188
|
+
expect(deviceToggle('desktop')).toBeNull();
|
|
189
|
+
expect(deviceToggle('mobile')).toBeNull();
|
|
190
|
+
// 'mobile' default notwithstanding, a phone gets the full-bleed frame.
|
|
191
|
+
expect(frame().className).toContain('tw-w-full');
|
|
192
|
+
} finally {
|
|
193
|
+
vi.unstubAllGlobals();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
104
197
|
test('escape closes the preview', async () => {
|
|
105
198
|
const wrapper = mountModal();
|
|
106
199
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<Teleport to="body">
|
|
3
3
|
<div
|
|
4
4
|
v-if="visible"
|
|
5
|
-
data-component="preview-modal"
|
|
5
|
+
data-component="live-preview-modal"
|
|
6
6
|
class="c-preview-modal tw-fixed tw-inset-0 tw-flex tw-flex-col tw-bg-grayscale-800"
|
|
7
7
|
:class="flowModalOpen ? 'tw-z-40' : 'tw-z-[1000]'"
|
|
8
8
|
>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<button
|
|
17
17
|
type="button"
|
|
18
18
|
data-test-preview-close-button
|
|
19
|
-
class="
|
|
19
|
+
class="tw-flex tw-items-center tw-px-4 tw-py-1.5 tw-border-2 tw-border-solid tw-border-transparent tw-rounded tw-bg-grayscale-700 tw-text-white tw-text-sm tw-font-bold hover:tw-bg-grayscale-600 tw-transition-colors"
|
|
20
20
|
:class="{ 'tw-uppercase': !isDesignCom }"
|
|
21
21
|
@click="$emit('close')"
|
|
22
22
|
>
|
|
@@ -31,24 +31,24 @@
|
|
|
31
31
|
<button
|
|
32
32
|
type="button"
|
|
33
33
|
data-test-preview-device-desktop
|
|
34
|
-
class="
|
|
34
|
+
class="tw-flex tw-items-center tw-justify-center tw-w-8 tw-h-8 tw-rounded tw-text-grayscale-400 tw-transition-colors"
|
|
35
35
|
:class="{
|
|
36
|
-
'
|
|
36
|
+
'tw-bg-grayscale-700 tw-text-white': deviceMode === 'desktop',
|
|
37
37
|
}"
|
|
38
38
|
:aria-pressed="deviceMode === 'desktop'"
|
|
39
|
-
@click="
|
|
39
|
+
@click="setDeviceMode('desktop')"
|
|
40
40
|
>
|
|
41
41
|
<Icon name="desktop" />
|
|
42
42
|
</button>
|
|
43
43
|
<button
|
|
44
44
|
type="button"
|
|
45
45
|
data-test-preview-device-mobile
|
|
46
|
-
class="
|
|
46
|
+
class="tw-flex tw-items-center tw-justify-center tw-w-8 tw-h-8 tw-rounded tw-text-grayscale-400 tw-transition-colors"
|
|
47
47
|
:class="{
|
|
48
|
-
'
|
|
48
|
+
'tw-bg-grayscale-700 tw-text-white': deviceMode === 'mobile',
|
|
49
49
|
}"
|
|
50
50
|
:aria-pressed="deviceMode === 'mobile'"
|
|
51
|
-
@click="
|
|
51
|
+
@click="setDeviceMode('mobile')"
|
|
52
52
|
>
|
|
53
53
|
<Icon name="mobile" />
|
|
54
54
|
</button>
|
|
@@ -59,15 +59,24 @@
|
|
|
59
59
|
:class="{ 'tw-w-1/3': showDeviceToggle }"
|
|
60
60
|
>
|
|
61
61
|
<button
|
|
62
|
-
v-if="cta !== 'none'"
|
|
63
62
|
type="button"
|
|
64
63
|
data-test-preview-edit-button
|
|
65
|
-
class="
|
|
66
|
-
:class="{
|
|
64
|
+
class="tw-flex tw-items-center tw-px-4 tw-py-1.5 tw-border-2 tw-border-solid tw-border-transparent tw-rounded tw-bg-grayscale-700 tw-text-white tw-text-sm tw-font-bold hover:tw-bg-grayscale-600 tw-transition-colors"
|
|
65
|
+
:class="{
|
|
66
|
+
'tw-bg-primary-500 hover:tw-bg-primary-600':
|
|
67
|
+
cta === 'edit' && isDesignCom,
|
|
68
|
+
'tw-bg-success-500 hover:tw-bg-success-600':
|
|
69
|
+
cta === 'edit' && !isDesignCom,
|
|
70
|
+
'tw-uppercase': !isDesignCom,
|
|
71
|
+
}"
|
|
67
72
|
@click="$emit('edit')"
|
|
68
73
|
>
|
|
69
74
|
<Icon name="edit" class="tw-mr-2" />
|
|
70
|
-
{{
|
|
75
|
+
{{
|
|
76
|
+
cta === 'publish'
|
|
77
|
+
? previewModalTr('backToEditor')
|
|
78
|
+
: previewModalTr('edit')
|
|
79
|
+
}}
|
|
71
80
|
</button>
|
|
72
81
|
<Button
|
|
73
82
|
v-if="cta === 'publish'"
|
|
@@ -106,10 +115,11 @@
|
|
|
106
115
|
ref="iframe"
|
|
107
116
|
:src="previewUrl"
|
|
108
117
|
:title="constantsTr('previewDisplayName')"
|
|
109
|
-
class="
|
|
118
|
+
class="tw-bg-white tw-border-0 tw-transition-all tw-duration-300 tw-ease-out"
|
|
110
119
|
:class="{
|
|
111
|
-
'
|
|
112
|
-
|
|
120
|
+
'tw-w-[358px] tw-h-[734px] tw-max-h-[calc(100%_-_4rem)] tw-rounded-[3rem] tw-shadow-[0_0_0_0.625rem_#3a3a3a] tw-my-auto':
|
|
121
|
+
frameDeviceMode === 'mobile',
|
|
122
|
+
'tw-w-full tw-h-full': frameDeviceMode === 'desktop',
|
|
113
123
|
'tw-opacity-0': !frameReady,
|
|
114
124
|
}"
|
|
115
125
|
data-test-preview-iframe
|
|
@@ -128,7 +138,7 @@
|
|
|
128
138
|
<!-- Blocks the whole modal with a spinner while a publish is in flight. -->
|
|
129
139
|
<div
|
|
130
140
|
v-if="publishing"
|
|
131
|
-
class="
|
|
141
|
+
class="tw-absolute tw-inset-0 tw-z-10 tw-flex tw-items-center tw-justify-center tw-bg-black tw-bg-opacity-60"
|
|
132
142
|
data-test-preview-publishing
|
|
133
143
|
>
|
|
134
144
|
<Loader />
|
|
@@ -138,9 +148,15 @@
|
|
|
138
148
|
</template>
|
|
139
149
|
|
|
140
150
|
<script setup lang="ts">
|
|
141
|
-
import {
|
|
151
|
+
import {
|
|
152
|
+
computed,
|
|
153
|
+
onBeforeUnmount,
|
|
154
|
+
onMounted,
|
|
155
|
+
ref,
|
|
156
|
+
watch,
|
|
157
|
+
type PropType,
|
|
158
|
+
} from 'vue';
|
|
142
159
|
import { Button, Icon, Loader } from '@designcrowd/fe-shared-lib';
|
|
143
|
-
// Labels reuse existing translated keys so no new Smartling strings are needed.
|
|
144
160
|
import {
|
|
145
161
|
actionBarTr,
|
|
146
162
|
commonTr,
|
|
@@ -150,29 +166,27 @@ import {
|
|
|
150
166
|
} from '@src/composables/useTranslate';
|
|
151
167
|
import { LIVE_PREVIEW_MESSAGES } from '@src/constants/live-preview.constants';
|
|
152
168
|
import type { UiDeviceMode } from '@shared/models';
|
|
169
|
+
import type { LivePreviewCta } from './live-preview-modal.utils';
|
|
153
170
|
|
|
154
|
-
// Full-viewport takeover, not the centred fe-shared-lib Modal
|
|
171
|
+
// Full-viewport takeover, not the centred fe-shared-lib Modal.
|
|
155
172
|
const props = defineProps({
|
|
156
173
|
visible: { type: Boolean, default: false },
|
|
157
174
|
previewUrl: { type: String, default: '' },
|
|
158
|
-
// CTA per surface: editor = publish, pre-purchase = edit, manage = none.
|
|
159
175
|
cta: {
|
|
160
|
-
type: String as PropType<
|
|
176
|
+
type: String as PropType<LivePreviewCta>,
|
|
161
177
|
default: 'publish',
|
|
162
178
|
},
|
|
163
|
-
|
|
164
|
-
|
|
179
|
+
// Seeds the toggle on each open; the shell owns it after.
|
|
180
|
+
defaultDeviceMode: {
|
|
165
181
|
type: String as PropType<UiDeviceMode>,
|
|
166
182
|
default: 'desktop',
|
|
167
183
|
},
|
|
168
|
-
|
|
169
|
-
// BrandCrowd uppercases button labels, Design.com doesn't (BP-5957).
|
|
184
|
+
// BrandCrowd uppercases labels, Design.com doesn't (BP-5957).
|
|
170
185
|
isDesignCom: { type: Boolean, default: false },
|
|
171
|
-
loading: { type: Boolean, default: false },
|
|
172
186
|
errored: { type: Boolean, default: false },
|
|
173
|
-
//
|
|
187
|
+
// Full-modal blocking overlay while a publish is in flight.
|
|
174
188
|
publishing: { type: Boolean, default: false },
|
|
175
|
-
//
|
|
189
|
+
// Let a host flow modal (publish/upgrade) stack above the preview.
|
|
176
190
|
flowModalOpen: { type: Boolean, default: false },
|
|
177
191
|
});
|
|
178
192
|
|
|
@@ -181,19 +195,36 @@ const emit = defineEmits<{
|
|
|
181
195
|
edit: [];
|
|
182
196
|
publish: [];
|
|
183
197
|
retry: [];
|
|
184
|
-
'update:deviceMode': [mode: UiDeviceMode];
|
|
185
198
|
}>();
|
|
186
199
|
|
|
200
|
+
// Owned here so any consumer gets a working toggle for free.
|
|
201
|
+
const deviceMode = ref<UiDeviceMode>(props.defaultDeviceMode);
|
|
202
|
+
|
|
203
|
+
const setDeviceMode = (mode: UiDeviceMode): void => {
|
|
204
|
+
deviceMode.value = mode;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// Small screens hide the toggle and force desktop (no phone bezel inside a phone).
|
|
208
|
+
// Breakpoint mirrors the editor's MAKER_MOBILE_BREAKPOINT (1024) — hence no prop.
|
|
209
|
+
const isSmallScreen = ref(false);
|
|
210
|
+
let deviceQuery: MediaQueryList | undefined;
|
|
211
|
+
const onDeviceQueryChange = (event: MediaQueryListEvent): void => {
|
|
212
|
+
isSmallScreen.value = event.matches;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const showDeviceToggle = computed(() => !isSmallScreen.value);
|
|
216
|
+
|
|
217
|
+
const frameDeviceMode = computed<UiDeviceMode>(() =>
|
|
218
|
+
isSmallScreen.value ? 'desktop' : deviceMode.value,
|
|
219
|
+
);
|
|
220
|
+
|
|
187
221
|
const iframe = ref<HTMLIFrameElement | null>(null);
|
|
188
222
|
const frameReady = ref(false);
|
|
189
223
|
let revealFallbackTimer: ReturnType<typeof setTimeout> | undefined;
|
|
224
|
+
let scrollLockedByUs = false;
|
|
190
225
|
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
// which covers a preview that never reports (older web-renderer, or a dropped
|
|
194
|
-
// message). Better a late reveal than a spinner that never clears.
|
|
195
|
-
// MUST stay above the preview page's own paint cap (12s in `preview.vue`), or this
|
|
196
|
-
// fires first and reveals a frame that was about to report itself painted.
|
|
226
|
+
// Reveal on the preview's `ready` postMessage; `load` fires before media paints.
|
|
227
|
+
// Fallback for a preview that never reports — must exceed preview.vue's 12s paint cap.
|
|
197
228
|
const REVEAL_FALLBACK_MS = 15_000;
|
|
198
229
|
|
|
199
230
|
const clearRevealFallback = (): void => {
|
|
@@ -208,12 +239,9 @@ const reveal = (): void => {
|
|
|
208
239
|
frameReady.value = true;
|
|
209
240
|
};
|
|
210
241
|
|
|
211
|
-
//
|
|
212
|
-
// white box while the frame fetched, redirected and booted.
|
|
242
|
+
// Hold the loader until the frame paints — else the URL swap flashes a white box.
|
|
213
243
|
const showLoader = computed(
|
|
214
|
-
() =>
|
|
215
|
-
props.loading ||
|
|
216
|
-
(!props.errored && !!props.previewUrl && !frameReady.value),
|
|
244
|
+
() => !props.errored && (!props.previewUrl || !frameReady.value),
|
|
217
245
|
);
|
|
218
246
|
|
|
219
247
|
const previewOrigin = computed(() => {
|
|
@@ -248,8 +276,7 @@ const onKeydown = (event: KeyboardEvent): void => {
|
|
|
248
276
|
}
|
|
249
277
|
};
|
|
250
278
|
|
|
251
|
-
// Escape reaches
|
|
252
|
-
// inside, the preview page posts it back up.
|
|
279
|
+
// Escape reaches here only when focus is outside the frame; inside, it's posted up.
|
|
253
280
|
const onMessage = (event: MessageEvent): void => {
|
|
254
281
|
if (
|
|
255
282
|
!previewOrigin.value ||
|
|
@@ -274,74 +301,61 @@ const stopListening = (): void => {
|
|
|
274
301
|
window.removeEventListener('keydown', onKeydown);
|
|
275
302
|
window.removeEventListener('message', onMessage);
|
|
276
303
|
clearRevealFallback();
|
|
304
|
+
|
|
305
|
+
// Only release a lock we took — a host modal may own it (this runs on mount too).
|
|
306
|
+
if (scrollLockedByUs) {
|
|
307
|
+
document.body.classList.remove('tw-overflow-hidden');
|
|
308
|
+
scrollLockedByUs = false;
|
|
309
|
+
}
|
|
277
310
|
};
|
|
278
311
|
|
|
279
312
|
watch(
|
|
280
313
|
() => props.visible,
|
|
281
314
|
(isVisible) => {
|
|
282
315
|
if (isVisible) {
|
|
316
|
+
// Reset to the default on each open.
|
|
317
|
+
deviceMode.value = props.defaultDeviceMode;
|
|
283
318
|
window.addEventListener('keydown', onKeydown);
|
|
284
319
|
window.addEventListener('message', onMessage);
|
|
320
|
+
// Lock host scroll behind the takeover (mirrors fe-shared-lib Modal).
|
|
321
|
+
document.body.classList.add('tw-overflow-hidden');
|
|
322
|
+
scrollLockedByUs = true;
|
|
285
323
|
} else {
|
|
286
324
|
frameReady.value = false;
|
|
287
325
|
stopListening();
|
|
288
326
|
}
|
|
289
327
|
},
|
|
290
|
-
// Immediate
|
|
328
|
+
// Immediate: a modal mounted already-visible still listens.
|
|
291
329
|
{ immediate: true },
|
|
292
330
|
);
|
|
293
331
|
|
|
294
|
-
//
|
|
295
|
-
//
|
|
332
|
+
// Fresh signed URL each open — send the frame back behind the loader. The reveal
|
|
333
|
+
// fallback starts here, not just on `load`, so a frame that never loads still reveals.
|
|
296
334
|
watch(
|
|
297
335
|
() => props.previewUrl,
|
|
298
|
-
() => {
|
|
336
|
+
(url) => {
|
|
299
337
|
clearRevealFallback();
|
|
300
338
|
frameReady.value = false;
|
|
339
|
+
|
|
340
|
+
if (url) {
|
|
341
|
+
revealFallbackTimer = setTimeout(reveal, REVEAL_FALLBACK_MS);
|
|
342
|
+
}
|
|
301
343
|
},
|
|
302
344
|
);
|
|
303
345
|
|
|
304
|
-
|
|
305
|
-
|
|
346
|
+
// SSR/happy-dom may lack matchMedia; unset → isSmallScreen false → toggle shows.
|
|
347
|
+
onMounted(() => {
|
|
348
|
+
if (typeof window === 'undefined' || !window.matchMedia) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
deviceQuery = window.matchMedia('(max-width: 1023px)');
|
|
353
|
+
isSmallScreen.value = deviceQuery.matches;
|
|
354
|
+
deviceQuery.addEventListener('change', onDeviceQueryChange);
|
|
355
|
+
});
|
|
306
356
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
.c-preview-modal__device--active {
|
|
313
|
-
@apply tw-bg-grayscale-700 tw-text-white;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/* Dark chrome buttons in the header — must not compete with the Publish CTA.
|
|
317
|
-
Padding/size mirror fe-shared-lib's `small-medium`; the transparent border
|
|
318
|
-
matches its `tw-border-2` so these line up with Publish at 36px. `border-solid`
|
|
319
|
-
is required — preflight is off for these themes, so a width-only border
|
|
320
|
-
computes to zero (same reason every fe-shared-lib variant spells it out). */
|
|
321
|
-
.c-preview-modal__close,
|
|
322
|
-
.c-preview-modal__chrome-btn {
|
|
323
|
-
@apply tw-flex tw-items-center tw-px-4 tw-py-1.5 tw-border-2 tw-border-solid tw-border-transparent tw-rounded tw-bg-grayscale-700 tw-text-white tw-text-sm tw-font-bold hover:tw-bg-grayscale-600 tw-transition-colors;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
.c-preview-modal__publishing {
|
|
327
|
-
@apply tw-absolute tw-inset-0 tw-z-10 tw-flex tw-items-center tw-justify-center tw-bg-black tw-bg-opacity-60;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
.c-preview-modal__frame {
|
|
331
|
-
@apply tw-transition-all tw-duration-300 tw-ease-out;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
.c-preview-modal__frame--desktop {
|
|
335
|
-
@apply tw-w-full tw-h-full;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/* Phone-frame the mobile preview, reusing the editor Device.vue geometry. */
|
|
339
|
-
.c-preview-modal__frame--mobile {
|
|
340
|
-
width: 358px;
|
|
341
|
-
height: 734px;
|
|
342
|
-
max-height: calc(100% - 4rem);
|
|
343
|
-
border-radius: 3rem;
|
|
344
|
-
box-shadow: 0 0 0 0.625rem #3a3a3a;
|
|
345
|
-
@apply tw-my-auto;
|
|
346
|
-
}
|
|
347
|
-
</style>
|
|
357
|
+
onBeforeUnmount(() => {
|
|
358
|
+
stopListening();
|
|
359
|
+
deviceQuery?.removeEventListener('change', onDeviceQueryChange);
|
|
360
|
+
});
|
|
361
|
+
</script>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BrandPageType } from '@brand-page';
|
|
2
|
+
import type { UiDeviceMode } from '@shared/models';
|
|
3
|
+
|
|
4
|
+
// Per surface: editor = publish, manage = edit.
|
|
5
|
+
export type LivePreviewCta = 'publish' | 'edit';
|
|
6
|
+
|
|
7
|
+
// brandSite is desktop-first; others mobile-first. Type-only BrandPageType import keeps
|
|
8
|
+
// the `/preview-modal` subpath free of the renderer runtime graph.
|
|
9
|
+
export const getDefaultPreviewDeviceMode = (
|
|
10
|
+
brandPageType: BrandPageType,
|
|
11
|
+
): UiDeviceMode => (brandPageType === 'brandSite' ? 'desktop' : 'mobile');
|
|
@@ -166,6 +166,44 @@ describe('Cart Store', () => {
|
|
|
166
166
|
expect(cartStore.cartItems[0].enableEdit).toBe(false);
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
+
// Mirrors ProductDetailModal.onAdd: the product is registered in the shop store
|
|
170
|
+
// (as the preview now does), and Add to Cart resolves the SKU + price from it. This
|
|
171
|
+
// is the in-memory add-to-cart path that the live preview exercises — no network.
|
|
172
|
+
it('adds a product to the cart via the shop store (ProductDetailModal.onAdd path)', () => {
|
|
173
|
+
shopConfigStoreMock.addProduct({
|
|
174
|
+
id: 'product-1',
|
|
175
|
+
name: 'Test Product',
|
|
176
|
+
hasVariants: false,
|
|
177
|
+
skus: [{ skuKey: 'sku-123', id: 'sku-id-1', price: 100, variant: [] }],
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
cartStore.addOrUpdateSkuItemToCart({
|
|
181
|
+
skuKey: 'sku-123',
|
|
182
|
+
productId: 'product-1',
|
|
183
|
+
quantity: 2,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
expect(cartStore.cartItems).toHaveLength(1);
|
|
187
|
+
expect(cartStore.cartItems[0]).toEqual({
|
|
188
|
+
productId: 'product-1',
|
|
189
|
+
productSkuId: 'sku-id-1',
|
|
190
|
+
skuKey: 'sku-123',
|
|
191
|
+
unitPrice: 100,
|
|
192
|
+
quantity: 2,
|
|
193
|
+
notes: undefined,
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('does not add to the cart when the product is not in the shop store', () => {
|
|
198
|
+
cartStore.addOrUpdateSkuItemToCart({
|
|
199
|
+
skuKey: 'sku-123',
|
|
200
|
+
productId: 'missing-product',
|
|
201
|
+
quantity: 1,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
expect(cartStore.cartItems).toHaveLength(0);
|
|
205
|
+
});
|
|
206
|
+
|
|
169
207
|
it('should handle decimal prices correctly', () => {
|
|
170
208
|
cartStore.cartItems.push({
|
|
171
209
|
skuKey: 'sku-789',
|