@designcrowd/library.brand-page 6.2.15 → 6.2.16
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-CYdJJjNJ.js → CreatedOnBrandCrowd-de-de-B_-PPZBi.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-BSGwyIBg.js → CreatedOnBrandCrowd-en-us-BO1Kj3iA.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-C0cogd_P.js → CreatedOnBrandCrowd-es-es-BoDJWRn2.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-DR4TbHdK.js → CreatedOnBrandCrowd-fr-ca-DUJZmdAy.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-DR4TbHdK.js → CreatedOnBrandCrowd-fr-fr-DUJZmdAy.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-D3QLE-Rk.js → CreatedOnBrandCrowd-pt-br-pIlAG13E.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-D3QLE-Rk.js → CreatedOnBrandCrowd-pt-pt-pIlAG13E.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-CwRHSP3M.js → CreatedOnDcom-de-de-BNJtDtvi.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-BEn36py1.js → CreatedOnDcom-en-us-uL6WU_1S.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-CQt-H117.js → CreatedOnDcom-es-es-DGZQISoF.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-Cc1tyCJh.js → CreatedOnDcom-fr-ca-CvYWKqNh.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-52ucQbtE.js → CreatedOnDcom-fr-fr-CpohVgCR.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-BPMJmtaC.js → CreatedOnDcom-pt-br-CaKS-48n.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-D9RqaBx4.js → CreatedOnDcom-pt-pt-D4g-iecQ.js} +1 -1
- package/lib/src/brand-page/utils/migration/migration-22.d.ts +10 -4
- package/lib/src/brand-page/utils/migration/migration-22.js +59 -5
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-roR8wIA2.js → lib-DwDFHSzX.js} +8862 -8818
- package/package.json +1 -1
- package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +1 -0
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/edited-brandsite-sections.v22.json +6 -3
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/new-brandcontact-every-section.v22.json +26 -13
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/new-brandpage-every-section.v22.json +24 -12
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/new-brandsite-every-section.v22.json +24 -12
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandcontact.v22.json +8 -4
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandpage-general-link.v22.json +6 -3
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandpage-links.v22.json +6 -3
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandsite-header-banner.v22.json +2 -1
- package/src/brand-page/utils/migration/__snapshots__/migration-22-output/real-brandsite-sections.v22.json +6 -3
- package/src/brand-page/utils/migration/migration-22.ts +103 -4
|
@@ -745,6 +745,66 @@ const captureNoRoleTextStyles = (
|
|
|
745
745
|
return locations;
|
|
746
746
|
};
|
|
747
747
|
|
|
748
|
+
type ButtonLabelRole = {
|
|
749
|
+
holder: Record<string, unknown>;
|
|
750
|
+
key: string;
|
|
751
|
+
role: string | undefined;
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* A button label drew its own colour, else its role's colour, else inherited
|
|
756
|
+
* `buttonStyles.style.color` — never the base coat or a container default. B moves every label to
|
|
757
|
+
* Button text whatever role it was on, so record the role each colourless label drew before B;
|
|
758
|
+
* D bakes that colour onto the label (E hasn't cleared it yet).
|
|
759
|
+
*/
|
|
760
|
+
const captureButtonLabelRoles = (
|
|
761
|
+
brandPageModel: BrandPageModel,
|
|
762
|
+
): ButtonLabelRole[] => {
|
|
763
|
+
const labels: ButtonLabelRole[] = [];
|
|
764
|
+
const record = (
|
|
765
|
+
holder: Record<string, unknown>,
|
|
766
|
+
key: string,
|
|
767
|
+
style: RawStyleObject | undefined,
|
|
768
|
+
): void => {
|
|
769
|
+
if (style && isBlankColorValue(style.color)) {
|
|
770
|
+
labels.push({ holder, key, role: style.textStyleType });
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
for (const page of brandPageModel.pages ?? []) {
|
|
775
|
+
for (const content of page.contents ?? []) {
|
|
776
|
+
const fields = content as unknown as Record<string, unknown>;
|
|
777
|
+
|
|
778
|
+
for (const key of Object.keys(
|
|
779
|
+
CONTENT_TEXT_STYLE_PROPERTY_KEYS,
|
|
780
|
+
) as ContentTextStylePropertyKey[]) {
|
|
781
|
+
if (key === 'buttonTextStyle' || isButtonLabelField(content, key)) {
|
|
782
|
+
record(fields, key, fields[key] as RawStyleObject | undefined);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
for (const header of [
|
|
789
|
+
brandPageModel.pageHeaderDesktop,
|
|
790
|
+
brandPageModel.pageHeaderMobile,
|
|
791
|
+
]) {
|
|
792
|
+
const headerButton = header?.headerButton;
|
|
793
|
+
|
|
794
|
+
if (headerButton) {
|
|
795
|
+
record(
|
|
796
|
+
headerButton as unknown as Record<string, unknown>,
|
|
797
|
+
'buttonTextStyle',
|
|
798
|
+
(headerButton.buttonTextStyle as RawStyleObject | undefined) ?? {
|
|
799
|
+
textStyleType: TEXT_STYLE_TYPES.buttons,
|
|
800
|
+
},
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
return labels;
|
|
806
|
+
};
|
|
807
|
+
|
|
748
808
|
/**
|
|
749
809
|
* An RTE-eligible field that is a plain string, not a Tiptap doc. On an old site nothing
|
|
750
810
|
* converts plain text → doc (migration-20 only converts HTML), so such a field renders via
|
|
@@ -777,14 +837,16 @@ const roleColour = (
|
|
|
777
837
|
* and the role colour (E) changes no pixels. migration-21 already baked element→frame→role
|
|
778
838
|
* colour into RTE runs, so the only uncoloured runs reaching here inherit the base coat;
|
|
779
839
|
* non-RTE fields (21 left them alone) resolve element→container-default→role→base coat.
|
|
780
|
-
* `buttonTextStyle
|
|
781
|
-
*
|
|
782
|
-
*
|
|
840
|
+
* A button label (`buttonTextStyle`, a link button's `titleStyle`, the header button, Save
|
|
841
|
+
* Contact) never takes the base coat: it bakes the colour of the role it drew before B
|
|
842
|
+
* (`captureButtonLabelRoles`), else `buttonStyles.style.color`. A social-links section's unset
|
|
843
|
+
* icon fill is frozen here too.
|
|
783
844
|
*/
|
|
784
845
|
export const bakeElementColours = (
|
|
785
846
|
brandPageModel: BrandPageModel,
|
|
786
847
|
options: TextStyleOptions,
|
|
787
848
|
noRoleTextStyles: NoRoleTextStyles = new WeakMap(),
|
|
849
|
+
buttonLabelRoles: ButtonLabelRole[] = [],
|
|
788
850
|
): void => {
|
|
789
851
|
const baseCoat = roleColour(options, 'paragraph1');
|
|
790
852
|
|
|
@@ -916,6 +978,37 @@ export const bakeElementColours = (
|
|
|
916
978
|
}
|
|
917
979
|
}
|
|
918
980
|
|
|
981
|
+
const buttonStyleColour = brandPageModel.styles?.buttonStyles?.style?.color;
|
|
982
|
+
const bakeLabel = (
|
|
983
|
+
style: RawStyleObject | undefined,
|
|
984
|
+
roleColourValue: string | undefined,
|
|
985
|
+
): void => {
|
|
986
|
+
const colour = !isBlankColorValue(roleColourValue)
|
|
987
|
+
? roleColourValue
|
|
988
|
+
: buttonStyleColour;
|
|
989
|
+
|
|
990
|
+
if (style && isBlankColorValue(style.color) && !isBlankColorValue(colour)) {
|
|
991
|
+
style.color = colour;
|
|
992
|
+
}
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
for (const { holder, key, role } of buttonLabelRoles) {
|
|
996
|
+
bakeLabel(
|
|
997
|
+
holder[key] as RawStyleObject | undefined,
|
|
998
|
+
roleColour(options, role),
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// Save Contact drew the Buttons role's colour whatever its stored style held.
|
|
1003
|
+
if (brandPageModel.brandPageType === BRAND_PAGE_TYPES.brandContact) {
|
|
1004
|
+
bakeLabel(
|
|
1005
|
+
brandPageModel.saveContactSettings?.buttonTextStyle as
|
|
1006
|
+
| RawStyleObject
|
|
1007
|
+
| undefined,
|
|
1008
|
+
roleColour(options, TEXT_STYLE_TYPES.buttons),
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
919
1012
|
// Footer copyright is non-RTE text that resolved through role → base coat, but lives
|
|
920
1013
|
// OUTSIDE `pages[].contents`, so freeze it here too — else it loses its colour when E
|
|
921
1014
|
// clears the role and F removes the base coat (the copyright-on-dark-footer regression).
|
|
@@ -1328,11 +1421,17 @@ export const migration22 = async (
|
|
|
1328
1421
|
seedRoleFonts(brandPageModel, options); // A2 — count the site's fonts onto each role family
|
|
1329
1422
|
|
|
1330
1423
|
const noRoleTextStyles = captureNoRoleTextStyles(brandPageModel);
|
|
1424
|
+
const buttonLabelRoles = captureButtonLabelRoles(brandPageModel);
|
|
1331
1425
|
|
|
1332
1426
|
reconnectContentRoles(brandPageModel, targets, options); // B — seed button styles, reconnect every text field
|
|
1333
1427
|
stripLiftContentRte(brandPageModel, options); // C — RTE baked → override
|
|
1334
1428
|
await convertPlainRteFields(brandPageModel, options); // B1 — plain text → Tiptap doc (after C)
|
|
1335
|
-
bakeElementColours(
|
|
1429
|
+
bakeElementColours(
|
|
1430
|
+
brandPageModel,
|
|
1431
|
+
options,
|
|
1432
|
+
noRoleTextStyles,
|
|
1433
|
+
buttonLabelRoles,
|
|
1434
|
+
); // D — freeze resolved colour
|
|
1336
1435
|
clearRoleColours(options); // E — retire role colour
|
|
1337
1436
|
stripRteStyleColours(brandPageModel); // G — colour-decouple RTE style objects
|
|
1338
1437
|
}
|