@designcrowd/library.brand-page 5.17.28-ast-padding → 5.17.28-ast-padding-2

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.
Files changed (45) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-BKiqBMgr.js → CreatedOnBrandCrowd-de-de-B8LzXe5g.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-BE9ztLEZ.js → CreatedOnBrandCrowd-en-us-Bma0CjMV.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-isBp-_KV.js → CreatedOnBrandCrowd-es-es-DpzZiHuW.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-BHkyP1Ym.js → CreatedOnBrandCrowd-fr-ca-DZasmAHP.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-fr-ca-BHkyP1Ym.js → CreatedOnBrandCrowd-fr-fr-DZasmAHP.js} +1 -1
  6. package/lib/src/{CreatedOnBrandCrowd-pt-pt-D4EXIp5p.js → CreatedOnBrandCrowd-pt-br-CjqDeNHj.js} +1 -1
  7. package/lib/src/{CreatedOnBrandCrowd-pt-br-D4EXIp5p.js → CreatedOnBrandCrowd-pt-pt-CjqDeNHj.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-de-de-DCyTITAn.js → CreatedOnDcom-de-de-BAoLQEiG.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-en-us-Bwr-eCqH.js → CreatedOnDcom-en-us-DqmMg8Di.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-es-es-DBMJ7xE-.js → CreatedOnDcom-es-es-DQRnkU0R.js} +1 -1
  11. package/lib/src/{CreatedOnDcom-fr-ca-itsxeehe.js → CreatedOnDcom-fr-ca-Bl1ZQD9t.js} +1 -1
  12. package/lib/src/{CreatedOnDcom-fr-fr-B8CIK3Dc.js → CreatedOnDcom-fr-fr-uOM-pJRl.js} +1 -1
  13. package/lib/src/{CreatedOnDcom-pt-br-mV_AMZNj.js → CreatedOnDcom-pt-br-CKVlVEWf.js} +1 -1
  14. package/lib/src/{CreatedOnDcom-pt-pt-mwvCkhOd.js → CreatedOnDcom-pt-pt-CSmMPFAJ.js} +1 -1
  15. package/lib/src/brand-page/components/contact-form/ContactForm.mixin.d.ts +4 -0
  16. package/lib/src/brand-page/components/contact-form/ContactForm.mixin.js +8 -4
  17. package/lib/src/brand-page/constants/misc.constants.d.ts +11 -0
  18. package/lib/src/brand-page/constants/misc.constants.js +19 -0
  19. package/lib/src/brand-page/utils/migration/migration-16.js +6 -1
  20. package/lib/src/brand-page/utils/migration.util.js +1 -1
  21. package/lib/src/brand-page-maker/constants/config-settings-constant.js +1 -0
  22. package/lib/src/brand-page-maker/convertors/contact-layout-style.convertor.js +6 -1
  23. package/lib/src/brand-page-maker/models/content-settings.js +8 -2
  24. package/lib/src/css/library.brand-page-brandCrowd.min.css +15 -19
  25. package/lib/src/css/library.brand-page-brandPage.min.css +15 -19
  26. package/lib/src/css/library.brand-page-designCom.min.css +15 -19
  27. package/lib/src/css/library.brand-page-preview.min.css +15 -19
  28. package/lib/src/index.mjs +1 -1
  29. package/lib/src/{lib-ro9XYcgh.js → lib-DfTRY-pF.js} +12224 -12195
  30. package/lib/src/shared/content-settings/components/slider-field/SliderField.mixin.js +9 -0
  31. package/package.json +1 -1
  32. package/src/brand-page/components/contact-form/ContactForm.mixin.ts +12 -6
  33. package/src/brand-page/components/contact-form/ContactForm.vue +115 -118
  34. package/src/brand-page/constants/misc.constants.ts +20 -0
  35. package/src/brand-page/utils/content-padding.util.test.ts +29 -0
  36. package/src/brand-page/utils/migration/migration-16.ts +10 -1
  37. package/src/brand-page/utils/migration.util.test.ts +64 -0
  38. package/src/brand-page/utils/migration.util.ts +1 -1
  39. package/src/brand-page-maker/constants/config-settings-constant.ts +1 -0
  40. package/src/brand-page-maker/convertors/contact-layout-style.convertor.test.ts +50 -0
  41. package/src/brand-page-maker/convertors/contact-layout-style.convertor.ts +8 -0
  42. package/src/brand-page-maker/models/content-settings.ts +10 -2
  43. package/src/shared/content-settings/components/content-settings-item/ContentSettingsItem.vue +1 -1
  44. package/src/shared/content-settings/components/focused-content-item-settings/FocusedContentItemSettings.vue +2 -2
  45. package/src/shared/content-settings/components/slider-field/SliderField.mixin.ts +9 -0
@@ -39,6 +39,15 @@ export default defineComponent({
39
39
  sliderValue: value,
40
40
  };
41
41
  },
42
+ watch: {
43
+ // The value can change outside the slider (e.g. a layout switch
44
+ // re-applying default padding, or undo) — keep the display in sync.
45
+ value(newValue) {
46
+ this.sliderValue = this.valueConvertor
47
+ ? this.valueConvertor.convert(newValue)
48
+ : newValue;
49
+ },
50
+ },
42
51
  computed: {
43
52
  innerMinLength() {
44
53
  return this.minLength ?? 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@designcrowd/library.brand-page",
3
3
  "description": "A collection of Maker/Designer applications",
4
- "version": "5.17.28-ast-padding",
4
+ "version": "5.17.28-ast-padding-2",
5
5
  "author": "Design.com Eng",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",
@@ -25,7 +25,10 @@ import {
25
25
  RECAPTCHA_ACTION_CONTACT_FORM,
26
26
  TEXT_ONLY,
27
27
  } from '../../constants';
28
- import { getRenderText } from '@brand-page/utils';
28
+ import {
29
+ getRenderText,
30
+ contentPaddingStyle as toContentPaddingStyle,
31
+ } from '@brand-page/utils';
29
32
  import { hasRTEContent } from '@brand-page-maker/utils';
30
33
  import { useReCaptcha } from '../../composables/recaptcha.composable';
31
34
 
@@ -97,6 +100,10 @@ export default defineComponent({
97
100
  return buttonTextStyle;
98
101
  },
99
102
 
103
+ contentPaddingStyle(): { paddingTop: string; paddingBottom: string } {
104
+ return toContentPaddingStyle(this.viewModel);
105
+ },
106
+
100
107
  hasCard(): boolean {
101
108
  return (
102
109
  this.viewModel.layoutStyle === ALIGN_CARD_CENTER ||
@@ -109,11 +116,10 @@ export default defineComponent({
109
116
  },
110
117
 
111
118
  hasBgColor(): boolean {
112
- return (
113
- this.viewModel.layoutStyle === ALIGN_CARD_CENTER ||
114
- this.viewModel.layoutStyle === TEXT_ONLY ||
115
- this.viewModel.layoutStyle === ALIGN_CENTERED
116
- );
119
+ // Every brandSite layout applies the background colour on the section
120
+ // root (banner-style) so the padding control reveals it; for the image
121
+ // layouts it only shows in the padding bands around the image block.
122
+ return Boolean(this.viewModel.layoutStyle);
117
123
  },
118
124
 
119
125
  isCenteredLayout(): boolean {
@@ -1,24 +1,12 @@
1
1
  <template>
2
2
  <section data-component="contact-form">
3
3
  <div
4
- :class="{
5
- 'tw-flex': isCenteredLayout && !hasBgImage,
6
- 'tw-block': !viewModel.layoutStyle,
7
- 'tw-relative': hasBgImage,
8
- }"
9
- :style="hasBgColor ? viewModel.backgroundStyle : {}"
4
+ :class="{ 'tw-block': !viewModel.layoutStyle }"
5
+ :style="[
6
+ hasBgColor ? viewModel.backgroundStyle : {},
7
+ contentPaddingStyle,
8
+ ]"
10
9
  >
11
- <Media
12
- v-if="hasBgImage && isCenteredLayout"
13
- :image-url="viewModel.imageUrl"
14
- :color-replacements="viewModel.colorReplacements"
15
- :context="context"
16
- :media-type="viewModel.mediaType"
17
- :role="viewModel.role"
18
- :size="viewModel.size"
19
- :content-index="contentIndex"
20
- img-classes="tw-w-full tw-h-full tw-object-cover tw-absolute tw-left-0 tw-top-0 tw-overflow-hidden"
21
- />
22
10
  <Collapsible
23
11
  v-if="
24
12
  !viewModel.layoutStyle ||
@@ -108,110 +96,125 @@
108
96
  </Collapsible>
109
97
  <div
110
98
  v-else-if="isCenteredLayout"
111
- class="contact-container tw-py-4"
112
- :class="{
113
- 'tw-px-6 tw-py-8': hasCard,
114
- 'tw-py-6': !hasCard,
115
- 'tw-w-full': !hasBgImage,
116
- }"
99
+ :class="{ 'tw-relative': hasBgImage, 'tw-flex': !hasBgImage }"
117
100
  >
101
+ <Media
102
+ v-if="hasBgImage"
103
+ :image-url="viewModel.imageUrl"
104
+ :color-replacements="viewModel.colorReplacements"
105
+ :context="context"
106
+ :media-type="viewModel.mediaType"
107
+ :role="viewModel.role"
108
+ :size="viewModel.size"
109
+ :content-index="contentIndex"
110
+ img-classes="tw-w-full tw-h-full tw-object-cover tw-absolute tw-left-0 tw-top-0 tw-overflow-hidden"
111
+ />
118
112
  <div
119
- :style="hasCard ? viewModel.cardStyle : {}"
120
- class="tw-relative tw-block tw-px-6 tw-py-8 tw-rounded-2xl"
113
+ class="contact-container"
114
+ :class="{
115
+ 'tw-px-6': hasCard,
116
+ 'tw-py-8': hasBgImage,
117
+ 'tw-w-full': !hasBgImage,
118
+ }"
121
119
  >
122
- <form v-if="!hasSubmitted" @submit.prevent="submitContactForm">
123
- <TextWrapper
124
- v-if="viewModel.title"
125
- :text-style="viewModel.titleStyle"
126
- :text="viewModel.title"
127
- element="h1"
128
- class="tw-mb-4 tw-text-base"
129
- />
130
- <TextWrapper
131
- v-if="renderText"
132
- :text-style="viewModel.descriptionStyle"
133
- :text="renderText"
134
- element="div"
135
- class="tw-mb-4 tw-text-base"
136
- />
137
- <div v-if="!isSubmitting" class="tw-grid tw-grid-cols-2 tw-gap-4">
138
- <div
139
- v-for="(value, index) in values"
140
- :key="index"
141
- class="tw-text-secondary-500 c-col-span-2"
142
- :class="{
143
- 'tw-col-span-2':
144
- value.field.type === 'text-area' || isMobileDevice,
145
- }"
146
- >
147
- <TextInput
148
- v-if="value.field.type !== 'text-area'"
149
- v-model="value.value"
150
- :placeholder="`${value.field.name}${
151
- value.field.required ? '*' : ''
152
- }`"
153
- :label="`${value.field.name}${value.field.required ? '*' : ''}`"
154
- :show-label-screen-reader-only="true"
155
- size="sm"
156
- :error="!!value.error"
157
- :type="getTextInputTypeByFieldType(value.field.type)"
158
- class="tw-w-full"
159
- @input="onValueChange(index)"
160
- />
161
- <Textarea
162
- v-if="value.field.type === 'text-area'"
163
- v-model="value.value"
164
- :placeholder="`${value.field.name}${
165
- value.field.required ? '*' : ''
166
- }`"
167
- :label="`${value.field.name}${value.field.required ? '*' : ''}`"
168
- :show-label-screen-reader-only="true"
169
- size="sm"
170
- :error="!!value.error"
171
- :resize="false"
172
- class="tw-w-full"
173
- @input="onValueChange(index)"
174
- />
175
- <p v-if="!!value.error" class="form-error">
176
- {{ value.error }}
177
- </p>
178
- </div>
179
- <div class="tw-flex tw-w-full tw-justify-center tw-col-span-2">
180
- <button
181
- v-if="isSubmitButtonVisible"
182
- class="tw-block tw-border-0 tw-py-2 tw-select-none tw-text-base tw-text-center tw-w-fit hover:tw-cursor-pointer tw-px-8 tw-py-3 c-button-full"
183
- :style="submitButtonStyle"
184
- :class="{ 'tw-w-full': isMobileDevice }"
120
+ <div
121
+ :style="hasCard ? viewModel.cardStyle : {}"
122
+ class="tw-relative tw-block tw-px-6 tw-py-8 tw-rounded-2xl"
123
+ >
124
+ <form v-if="!hasSubmitted" @submit.prevent="submitContactForm">
125
+ <TextWrapper
126
+ v-if="viewModel.title"
127
+ :text-style="viewModel.titleStyle"
128
+ :text="viewModel.title"
129
+ element="h1"
130
+ class="tw-mb-4 tw-text-base"
131
+ />
132
+ <TextWrapper
133
+ v-if="renderText"
134
+ :text-style="viewModel.descriptionStyle"
135
+ :text="renderText"
136
+ element="div"
137
+ class="tw-mb-4 tw-text-base"
138
+ />
139
+ <div v-if="!isSubmitting" class="tw-grid tw-grid-cols-2 tw-gap-4">
140
+ <div
141
+ v-for="(value, index) in values"
142
+ :key="index"
143
+ class="tw-text-secondary-500 c-col-span-2"
144
+ :class="{
145
+ 'tw-col-span-2':
146
+ value.field.type === 'text-area' || isMobileDevice,
147
+ }"
185
148
  >
186
- <TextWrapper
187
- :text-style="submitButtonTextStyle"
188
- :text="viewModel.buttonText"
189
- class="tw-text-center tw-text-base"
149
+ <TextInput
150
+ v-if="value.field.type !== 'text-area'"
151
+ v-model="value.value"
152
+ :placeholder="`${value.field.name}${
153
+ value.field.required ? '*' : ''
154
+ }`"
155
+ :label="`${value.field.name}${value.field.required ? '*' : ''}`"
156
+ :show-label-screen-reader-only="true"
157
+ size="sm"
158
+ :error="!!value.error"
159
+ :type="getTextInputTypeByFieldType(value.field.type)"
160
+ class="tw-w-full"
161
+ @input="onValueChange(index)"
162
+ />
163
+ <Textarea
164
+ v-if="value.field.type === 'text-area'"
165
+ v-model="value.value"
166
+ :placeholder="`${value.field.name}${
167
+ value.field.required ? '*' : ''
168
+ }`"
169
+ :label="`${value.field.name}${value.field.required ? '*' : ''}`"
170
+ :show-label-screen-reader-only="true"
171
+ size="sm"
172
+ :error="!!value.error"
173
+ :resize="false"
174
+ class="tw-w-full"
175
+ @input="onValueChange(index)"
190
176
  />
191
- </button>
177
+ <p v-if="!!value.error" class="form-error">
178
+ {{ value.error }}
179
+ </p>
180
+ </div>
181
+ <div class="tw-flex tw-w-full tw-justify-center tw-col-span-2">
182
+ <button
183
+ v-if="isSubmitButtonVisible"
184
+ class="tw-block tw-border-0 tw-py-2 tw-select-none tw-text-base tw-text-center tw-w-fit hover:tw-cursor-pointer tw-px-8 tw-py-3 c-button-full"
185
+ :style="submitButtonStyle"
186
+ :class="{ 'tw-w-full': isMobileDevice }"
187
+ >
188
+ <TextWrapper
189
+ :text-style="submitButtonTextStyle"
190
+ :text="viewModel.buttonText"
191
+ class="tw-text-center tw-text-base"
192
+ />
193
+ </button>
194
+ </div>
192
195
  </div>
196
+ <div v-else class="tw-w-full tw-flex tw-justify-center">
197
+ <Loader />
198
+ </div>
199
+ <p
200
+ v-if="hasSubmitError"
201
+ class="tw-text-center tw-mt-2 form-error"
202
+ >
203
+ {{ submitError }}
204
+ </p>
205
+ </form>
206
+ <div v-else :style="successMessageColorStyle">
207
+ <TextWrapper
208
+ v-if="viewModel.successMessage"
209
+ :text="renderSuccessText"
210
+ element="p"
211
+ :class="'tw-my-0.5'"
212
+ />
193
213
  </div>
194
- <div v-else class="tw-w-full tw-flex tw-justify-center">
195
- <Loader />
196
- </div>
197
- <p v-if="hasSubmitError" class="tw-text-center tw-mt-2 form-error">
198
- {{ submitError }}
199
- </p>
200
- </form>
201
- <div v-else :style="successMessageColorStyle">
202
- <TextWrapper
203
- v-if="viewModel.successMessage"
204
- :text="renderSuccessText"
205
- element="p"
206
- :class="'tw-my-0.5'"
207
- />
208
214
  </div>
209
215
  </div>
210
216
  </div>
211
- <div
212
- v-else-if="isTextOnly"
213
- class="tw-px-6 tw-py-8 tw-gap-2 contact-container"
214
- >
217
+ <div v-else-if="isTextOnly" class="tw-px-6 tw-gap-2 contact-container">
215
218
  <span v-if="!hasSubmitted" class="tw-grid tw-grid-cols-2">
216
219
  <div
217
220
  v-if="!isSubmitting"
@@ -348,10 +351,7 @@
348
351
  }"
349
352
  >
350
353
  <div
351
- class="tw-flex tw-flex-col tw-gap-2 tw-px-8 tw-w-full tw-justify-center c-py-6"
352
- :class="{
353
- 'tw-py-6': isMobileDevice,
354
- }"
354
+ class="tw-flex tw-flex-col tw-gap-2 tw-px-8 tw-py-6 tw-w-full tw-justify-center"
355
355
  >
356
356
  <span v-if="!hasSubmitted">
357
357
  <TextWrapper
@@ -513,9 +513,6 @@ export default {
513
513
  .c-text-padding {
514
514
  @apply tw-px-0 tw-col-span-2;
515
515
  }
516
- .c-py-6 {
517
- @apply tw-py-6;
518
- }
519
516
  .c-divided-container {
520
517
  @apply tw-flex-col;
521
518
  }
@@ -32,6 +32,26 @@ export const ALIGN_LEFT_FULL_IMAGE = 'left-aligned-full-image';
32
32
  export const ALIGN_RIGHT_FULL_IMAGE = 'right-aligned-full-image';
33
33
  export const ALTERNATE_IMAGE = 'alternate-image';
34
34
 
35
+ /**
36
+ * Padding Control (BP-5699): the top/bottom padding each Contact Form layout
37
+ * had hard-coded before the sliders existed. Single source for new-block
38
+ * defaults (content-settings) and the migration backfill for existing pages.
39
+ * The image layouts (full-image divided and card-over-image) are 0: their
40
+ * padding sits on the section root and reveals the background colour around
41
+ * the image block (same as the banner), while the spacing inside/over the
42
+ * image stays fixed — existing pages rendered the image flush to the section
43
+ * edges.
44
+ */
45
+ export const CONTACT_FORM_LAYOUT_DEFAULT_PADDING: Record<string, number> = {
46
+ '': 0, // collapsible (default on Brand Page / Brand Contact)
47
+ [ALIGN_CENTERED]: 24,
48
+ [ALIGN_CARD_CENTER]: 32,
49
+ [ALIGN_CARD_CENTER_IMAGE]: 0,
50
+ [TEXT_ONLY]: 32,
51
+ [ALIGN_LEFT_FULL_IMAGE]: 0,
52
+ [ALIGN_RIGHT_FULL_IMAGE]: 0,
53
+ };
54
+
35
55
  export const BIG_IMAGE = 'big-image';
36
56
  export const MEDIA_ONLY = 'media-only';
37
57
  export const COLUMNS = 'columns';
@@ -0,0 +1,29 @@
1
+ import { describe, test, expect } from 'vitest';
2
+ import { contentPaddingStyle } from './content-padding.util';
3
+
4
+ describe('content-padding.util', () => {
5
+ test('contentPaddingStyle should map stored padding to px values', () => {
6
+ expect(contentPaddingStyle({ topPadding: 53, bottomPadding: 24 })).toEqual({
7
+ paddingTop: '53px',
8
+ paddingBottom: '24px',
9
+ });
10
+ });
11
+
12
+ test('contentPaddingStyle should default missing values to 0 for content created before the field existed', () => {
13
+ expect(contentPaddingStyle({})).toEqual({
14
+ paddingTop: '0px',
15
+ paddingBottom: '0px',
16
+ });
17
+ expect(contentPaddingStyle({ topPadding: 16 })).toEqual({
18
+ paddingTop: '16px',
19
+ paddingBottom: '0px',
20
+ });
21
+ });
22
+
23
+ test('contentPaddingStyle should keep an explicit 0 rather than treating it as unset', () => {
24
+ expect(contentPaddingStyle({ topPadding: 0, bottomPadding: 0 })).toEqual({
25
+ paddingTop: '0px',
26
+ paddingBottom: '0px',
27
+ });
28
+ });
29
+ });
@@ -1,4 +1,6 @@
1
1
  import type { MigrationData } from '../migration.util';
2
+ import type { ContactFormContent } from '../../models';
3
+ import { CONTACT_FORM_LAYOUT_DEFAULT_PADDING } from '../../constants';
2
4
 
3
5
  /**
4
6
  * Tier 2 Padding Control (BP-5699): blocks that already had hard-coded
@@ -22,7 +24,14 @@ export const migration16 = async (
22
24
 
23
25
  brandPageModel.pages.forEach((page) => {
24
26
  page.contents.forEach((content) => {
25
- const value = TIER2_DEFAULT_PADDING[content.type];
27
+ // Contact Form's previous hard-coded spacing varies by layout, so it's
28
+ // keyed by layoutStyle rather than a single per-type value.
29
+ const value =
30
+ content.type === 'contact-form'
31
+ ? CONTACT_FORM_LAYOUT_DEFAULT_PADDING[
32
+ (content as ContactFormContent).layoutStyle ?? ''
33
+ ]
34
+ : TIER2_DEFAULT_PADDING[content.type];
26
35
 
27
36
  if (value === undefined) {
28
37
  return;
@@ -24,6 +24,9 @@ import {
24
24
  createInitialTestimonialSectionContent,
25
25
  } from '@brand-page-maker/models';
26
26
  import {
27
+ ALIGN_CARD_CENTER_IMAGE,
28
+ ALIGN_LEFT_FULL_IMAGE,
29
+ ALIGN_RIGHT_FULL_IMAGE,
27
30
  DEFAULT_LETTER_SPACING,
28
31
  LINE_HEIGHT_BODY,
29
32
  LINE_HEIGHT_HEADINGS,
@@ -1464,6 +1467,67 @@ describe('migration.util', () => {
1464
1467
  expect(content.layoutStyle).toBe(TEXT_ONLY);
1465
1468
  });
1466
1469
 
1470
+ test('migration16 should backfill contact form padding from its layout style', async () => {
1471
+ const model = await migrateBrandPageModel(getBsModel(), {
1472
+ isUserDraft: false,
1473
+ isServerRender: false,
1474
+ });
1475
+
1476
+ const collapsible = model.brandPageModel.pages[3]
1477
+ .contents[0] as ContactFormContent;
1478
+ const textOnly = model.brandPageModel.pages[3]
1479
+ .contents[1] as ContactFormContent;
1480
+
1481
+ expect(collapsible.topPadding).toBe(0);
1482
+ expect(collapsible.bottomPadding).toBe(0);
1483
+ expect(textOnly.topPadding).toBe(32);
1484
+ expect(textOnly.bottomPadding).toBe(32);
1485
+ });
1486
+
1487
+ test.each([
1488
+ [ALIGN_LEFT_FULL_IMAGE],
1489
+ [ALIGN_RIGHT_FULL_IMAGE],
1490
+ [ALIGN_CARD_CENTER_IMAGE],
1491
+ ])(
1492
+ 'migration16 should backfill zero padding for the %s contact form layout',
1493
+ async (layoutStyle) => {
1494
+ const brandPageModel = getBsModel();
1495
+
1496
+ (
1497
+ brandPageModel.pages[3].contents[1] as ContactFormContent
1498
+ ).layoutStyle = layoutStyle;
1499
+
1500
+ const model = await migrateBrandPageModel(brandPageModel, {
1501
+ isUserDraft: false,
1502
+ isServerRender: false,
1503
+ });
1504
+
1505
+ const content = model.brandPageModel.pages[3]
1506
+ .contents[1] as ContactFormContent;
1507
+
1508
+ expect(content.topPadding).toBe(0);
1509
+ expect(content.bottomPadding).toBe(0);
1510
+ },
1511
+ );
1512
+
1513
+ test('migration16 should not overwrite contact form padding that is already set', async () => {
1514
+ const brandPageModel = getBsModel();
1515
+
1516
+ (brandPageModel.pages[3].contents[1] as ContactFormContent).topPadding =
1517
+ 10;
1518
+
1519
+ const model = await migrateBrandPageModel(brandPageModel, {
1520
+ isUserDraft: false,
1521
+ isServerRender: false,
1522
+ });
1523
+
1524
+ const content = model.brandPageModel.pages[3]
1525
+ .contents[1] as ContactFormContent;
1526
+
1527
+ expect(content.topPadding).toBe(10);
1528
+ expect(content.bottomPadding).toBe(32);
1529
+ });
1530
+
1467
1531
  test('migrateNewLogoLogic should migrate logoDraftToken and logoVariation', () => {
1468
1532
  const oldTemplate: BrandPageData = {
1469
1533
  pages: [
@@ -146,7 +146,7 @@ const MIGRATION_TABLE = [
146
146
  version: 16,
147
147
  migrateFn: migration16,
148
148
  description:
149
- 'Tier 2 Padding Control (BP-5699): backfill existing top/bottom spacing as explicit padding for text (12px) and images, social links, shapes and booking (32px)',
149
+ 'Tier 2 Padding Control (BP-5699): backfill existing top/bottom spacing as explicit padding for text (12px), images, social links, shapes and booking (32px), and contact form (per layout)',
150
150
  },
151
151
  ] as MigrationTableItem[];
152
152
 
@@ -2228,6 +2228,7 @@ export const CONTACT_FORM_SETTINGS_CONFIG =
2228
2228
  title: contentSettingsTr(`backgroundColorTitle`),
2229
2229
  valueConvertor: backgroundColorConvertor,
2230
2230
  },
2231
+ ...PADDING_CONTROL_FIELDS(CONTACT_FORM_GROUPS.style),
2231
2232
  },
2232
2233
  isEnabled: true,
2233
2234
  isLocked: (features) => !features.canAddContactFormContents,
@@ -0,0 +1,50 @@
1
+ import { describe, test, expect } from 'vitest';
2
+ import { contactLayoutStyleConvertor } from './contact-layout-style.convertor';
3
+ import {
4
+ ALIGN_CENTERED,
5
+ ALIGN_CARD_CENTER,
6
+ ALIGN_CARD_CENTER_IMAGE,
7
+ ALIGN_LEFT_FULL_IMAGE,
8
+ TEXT_ONLY,
9
+ } from '@brand-page/constants';
10
+
11
+ const configWithSelected = (selected: string) => ({
12
+ options: contactLayoutStyleConvertor
13
+ .convert(selected)
14
+ .options.map((option) => ({
15
+ ...option,
16
+ isSelected: option.value === selected,
17
+ })),
18
+ });
19
+
20
+ describe('contact-layout-style.convertor', () => {
21
+ test.each([
22
+ [ALIGN_CARD_CENTER, 32, 'center'],
23
+ [ALIGN_CENTERED, 24, 'center'],
24
+ [ALIGN_CARD_CENTER_IMAGE, 0, 'center'],
25
+ [TEXT_ONLY, 32, 'left'],
26
+ [ALIGN_LEFT_FULL_IMAGE, 0, 'left'],
27
+ ])(
28
+ 'convertBack should apply the default padding and text alignment for %s',
29
+ (layoutStyle, padding, textAlign) => {
30
+ const result = contactLayoutStyleConvertor.convertBack(
31
+ configWithSelected(layoutStyle),
32
+ );
33
+
34
+ expect(result).toStrictEqual({
35
+ layoutStyle,
36
+ topPadding: padding,
37
+ bottomPadding: padding,
38
+ titleStyle: {
39
+ textAlign,
40
+ },
41
+ descriptionStyle: {
42
+ textAlign,
43
+ },
44
+ buttonTextStyle: {
45
+ textAlign: 'center',
46
+ },
47
+ });
48
+ },
49
+ );
50
+ });
@@ -6,6 +6,7 @@ import {
6
6
  ALIGN_CARD_CENTER_IMAGE,
7
7
  TEXT_ONLY,
8
8
  ALIGN_CARD_CENTER,
9
+ CONTACT_FORM_LAYOUT_DEFAULT_PADDING,
9
10
  } from '@brand-page/constants';
10
11
  import type { ContactFormContent } from '@brand-page';
11
12
 
@@ -84,8 +85,15 @@ export const contactLayoutStyleConvertor: ValueConvertor<
84
85
  textAlign = 'left';
85
86
  }
86
87
 
88
+ // Switching layout adopts that layout's canonical look — same as the
89
+ // textAlign resets below — including its default block padding.
90
+ const padding =
91
+ CONTACT_FORM_LAYOUT_DEFAULT_PADDING[selectedOption?.value ?? ''] ?? 0;
92
+
87
93
  return {
88
94
  layoutStyle: selectedOption?.value,
95
+ topPadding: padding,
96
+ bottomPadding: padding,
89
97
  titleStyle: {
90
98
  textAlign,
91
99
  },
@@ -24,6 +24,7 @@ import {
24
24
  EMPTY_LOGO_IMAGE_MODEL,
25
25
  BRAND_PAGE_TYPES,
26
26
  SENSITIVE_CONTENT_TYPES,
27
+ CONTACT_FORM_LAYOUT_DEFAULT_PADDING,
27
28
  } from '@brand-page';
28
29
  import type {
29
30
  ButtonContent,
@@ -467,14 +468,21 @@ export const createInitialContactFormContent: CreateInitialContentFunction<
467
468
  console.error('userState.emailAddress should not be undefined');
468
469
  }
469
470
 
471
+ // New blocks inherit the padding their initial layout previously had
472
+ // hard-coded — same source as the migration backfill for existing pages.
473
+ const layoutStyle =
474
+ options?.brandPageType === 'brandSite' ? 'center-card-aligned' : '';
475
+ const padding = CONTACT_FORM_LAYOUT_DEFAULT_PADDING[layoutStyle] ?? 0;
476
+
470
477
  return {
471
478
  id: uuid.v4(),
472
479
  title: contentSettingsTr(`contactUsTitle`),
473
480
  description: '',
474
481
  buttonText: contentSettingsTr(`sendPlaceholder`),
475
482
  displayStyle: DISPLAY_STYLE_PREVIEW,
476
- layoutStyle:
477
- options?.brandPageType === 'brandSite' ? 'center-card-aligned' : '',
483
+ layoutStyle,
484
+ topPadding: padding,
485
+ bottomPadding: padding,
478
486
  imageUrl: '',
479
487
  fields: [
480
488
  {
@@ -56,7 +56,7 @@
56
56
  >
57
57
  <li
58
58
  v-for="(field, index) in fields"
59
- :key="`content-settings-item-field-${id}-${index}`"
59
+ :key="`content-settings-item-field-${id}-${field.name}`"
60
60
  class="tw-cursor-pointer"
61
61
  :class="{
62
62
  'tw-mb-3': index !== fields.length - 1,
@@ -25,8 +25,8 @@
25
25
  >
26
26
  <ul>
27
27
  <li
28
- v-for="(field, fieldIndex) in group.fields"
29
- :key="`content-settings-item-group-field-${id}-${group.id}-${fieldIndex}`"
28
+ v-for="field in group.fields"
29
+ :key="`content-settings-item-group-field-${id}-${group.id}-${field.name}`"
30
30
  >
31
31
  <ContentSettingsItemField
32
32
  v-if="
@@ -45,6 +45,15 @@ export default defineComponent({
45
45
  sliderValue: value,
46
46
  };
47
47
  },
48
+ watch: {
49
+ // The value can change outside the slider (e.g. a layout switch
50
+ // re-applying default padding, or undo) — keep the display in sync.
51
+ value(newValue: string | undefined) {
52
+ this.sliderValue = this.valueConvertor
53
+ ? this.valueConvertor.convert(newValue as any)
54
+ : newValue;
55
+ },
56
+ },
48
57
  computed: {
49
58
  innerMinLength(): number {
50
59
  return this.minLength ?? 0;