Skip to content

Commit 6a5f65c

Browse files
authored
Merge pull request #19360 from mozilla/FXA-12188
feat(cms): Allow background-images and split layout
2 parents 3356b39 + add0cb8 commit 6a5f65c

24 files changed

Lines changed: 314 additions & 176 deletions

File tree

210 KB
Loading
1.81 MB
Loading
202 KB
Loading

libs/shared/cms/src/__generated__/gql.ts

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/shared/cms/src/__generated__/graphql.ts

Lines changed: 43 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/shared/cms/src/lib/queries/relying-party/factories.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const RelyingPartyResultFactory = (
2828
description: faker.string.sample(),
2929
primaryButtonText: faker.string.sample(),
3030
pageTitle: faker.string.sample(),
31+
splitLayout: faker.datatype.boolean(),
3132
},
3233
SignupSetPasswordPage: {
3334
logoUrl: faker.internet.url(),
@@ -36,6 +37,7 @@ export const RelyingPartyResultFactory = (
3637
description: faker.string.sample(),
3738
primaryButtonText: faker.string.sample(),
3839
pageTitle: faker.string.sample(),
40+
splitLayout: faker.datatype.boolean(),
3941
},
4042
SignupConfirmCodePage: {
4143
logoUrl: faker.internet.url(),
@@ -44,6 +46,7 @@ export const RelyingPartyResultFactory = (
4446
description: faker.string.sample(),
4547
primaryButtonText: faker.string.sample(),
4648
pageTitle: faker.string.sample(),
49+
splitLayout: faker.datatype.boolean(),
4750
},
4851
SignupConfirmedSyncPage: {
4952
logoUrl: faker.internet.url(),
@@ -56,6 +59,7 @@ export const RelyingPartyResultFactory = (
5659
url: faker.internet.url(),
5760
altText: faker.string.sample(),
5861
},
62+
splitLayout: faker.datatype.boolean(),
5963
},
6064
shared: {
6165
buttonColor: faker.color.rgb(),
@@ -65,8 +69,12 @@ export const RelyingPartyResultFactory = (
6569
emailLogoUrl: faker.internet.url(),
6670
emailLogoAltText: faker.string.sample(),
6771
emailLogoWidth: `${faker.number.int({ min: 10, max: 1000 })}px`,
68-
backgroundColor: faker.color.rgb(),
69-
headerBackground: faker.color.rgb(),
72+
backgrounds: {
73+
defaultLayout: faker.color.rgb(),
74+
splitLayout: faker.color.rgb(),
75+
header: faker.color.rgb(),
76+
splitLayoutAltText: faker.string.sample(),
77+
},
7078
pageTitle: faker.string.sample(),
7179
headerLogoUrl: faker.internet.url(),
7280
headerLogoAltText: faker.string.sample(),
@@ -82,20 +90,23 @@ export const RelyingPartyResultFactory = (
8290
subject: faker.string.sample(),
8391
headline: faker.string.sample(),
8492
description: faker.string.sample(),
93+
splitLayout: faker.datatype.boolean(),
8594
},
8695
VerifyLoginCodeEmail: {
8796
logoUrl: faker.internet.url(),
8897
logoAltText: faker.internet.url(),
8998
subject: faker.string.sample(),
9099
headline: faker.string.sample(),
91100
description: faker.string.sample(),
101+
splitLayout: faker.datatype.boolean(),
92102
},
93103
VerifyShortCodeEmail: {
94104
logoUrl: faker.internet.url(),
95105
logoAltText: faker.internet.url(),
96106
subject: faker.string.sample(),
97107
headline: faker.string.sample(),
98108
description: faker.string.sample(),
109+
splitLayout: faker.datatype.boolean(),
99110
},
100111
SigninPage: {
101112
logoUrl: faker.internet.url(),
@@ -104,6 +115,7 @@ export const RelyingPartyResultFactory = (
104115
description: faker.string.sample(),
105116
primaryButtonText: faker.string.sample(),
106117
pageTitle: faker.string.sample(),
118+
splitLayout: faker.datatype.boolean(),
107119
},
108120
SigninTokenCodePage: {
109121
logoUrl: faker.internet.url(),
@@ -112,6 +124,7 @@ export const RelyingPartyResultFactory = (
112124
description: faker.string.sample(),
113125
primaryButtonText: faker.string.sample(),
114126
pageTitle: faker.string.sample(),
127+
splitLayout: faker.datatype.boolean(),
115128
},
116129
SigninUnblockCodePage: {
117130
logoUrl: faker.internet.url(),
@@ -120,6 +133,7 @@ export const RelyingPartyResultFactory = (
120133
description: faker.string.sample(),
121134
primaryButtonText: faker.string.sample(),
122135
pageTitle: faker.string.sample(),
136+
splitLayout: faker.datatype.boolean(),
123137
},
124138
...override,
125139
});

libs/shared/cms/src/lib/queries/relying-party/query.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ export const relyingPartyQuery = graphql(`
2121
emailLogoUrl
2222
emailLogoAltText
2323
emailLogoWidth
24-
backgroundColor
25-
headerBackground
2624
pageTitle
2725
headerLogoUrl
2826
headerLogoAltText
2927
featureFlags {
3028
syncConfirmedPageHideCTA
3129
syncHidePromoAfterLogin
3230
}
31+
backgrounds {
32+
defaultLayout
33+
header
34+
splitLayout
35+
splitLayoutAltText
36+
}
3337
favicon
3438
}
3539
EmailFirstPage {
@@ -39,6 +43,7 @@ export const relyingPartyQuery = graphql(`
3943
description
4044
primaryButtonText
4145
pageTitle
46+
splitLayout
4247
}
4348
SignupSetPasswordPage {
4449
logoUrl
@@ -47,12 +52,14 @@ export const relyingPartyQuery = graphql(`
4752
description
4853
primaryButtonText
4954
pageTitle
55+
splitLayout
5056
}
5157
SignupConfirmCodePage {
5258
headline
5359
description
5460
primaryButtonText
5561
pageTitle
62+
splitLayout
5663
}
5764
SignupConfirmedSyncPage {
5865
headline
@@ -63,33 +70,28 @@ export const relyingPartyQuery = graphql(`
6370
url
6471
altText
6572
}
73+
splitLayout
6674
}
6775
SigninPage {
6876
headline
6977
description
7078
primaryButtonText
7179
pageTitle
80+
splitLayout
7281
}
7382
SigninTokenCodePage {
7483
headline
7584
description
7685
primaryButtonText
7786
pageTitle
87+
splitLayout
7888
}
7989
SigninUnblockCodePage {
8090
headline
8191
description
8292
primaryButtonText
8393
pageTitle
84-
}
85-
shared {
86-
buttonColor
87-
logoUrl
88-
logoAltText
89-
emailFromName
90-
emailLogoUrl
91-
emailLogoAltText
92-
emailLogoWidth
94+
splitLayout
9395
}
9496
NewDeviceLoginEmail {
9597
subject

libs/shared/cms/src/lib/queries/relying-party/types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface Page {
1010
logoAltText: string | null;
1111
pageTitle: string | null;
1212
primaryImage: Image | null;
13+
splitLayout: boolean | null;
1314
}
1415

1516
export interface Email {
@@ -26,8 +27,12 @@ export interface Shared {
2627
emailLogoUrl: string | null;
2728
emailLogoAltText: string | null;
2829
emailLogoWidth: string | null;
29-
backgroundColor: string | null;
30-
headerBackground: string | null;
30+
backgrounds: {
31+
defaultLayout: string | null;
32+
header: string | null;
33+
splitLayout: string | null;
34+
splitLayoutAltText: string | null;
35+
};
3136
pageTitle: string | null;
3237
headerLogoUrl: string | null;
3338
headerLogoAltText: string | null;

packages/fxa-content-server/app/scripts/views/pair/index.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,17 @@ class PairIndexView extends FormView {
130130
}
131131
}
132132

133-
// Apply CMS background gradient
133+
// Apply CMS background
134134
if (
135135
this.cmsConfig &&
136136
this.cmsConfig.shared &&
137-
this.cmsConfig.shared.backgroundColor
137+
this.cmsConfig.shared.backgrounds.defaultLayout
138138
) {
139-
// Validate the background color is a valid CSS graident
140-
const isValidGradient = /^linear-gradient\(/.test(
141-
this.cmsConfig.shared.backgroundColor
142-
);
143139
// Not ideal, but the pairing page will be going away
144140
const screenWidth = window.innerWidth;
145-
if (isValidGradient && screenWidth > 768) {
146-
document.body.style.background = this.cmsConfig.shared.backgroundColor;
141+
if (screenWidth > 768) {
142+
document.body.style.background =
143+
this.cmsConfig.shared.backgrounds.defaultLayout;
147144
}
148145
}
149146

@@ -172,10 +169,10 @@ class PairIndexView extends FormView {
172169
if (
173170
this.cmsConfig &&
174171
this.cmsConfig.shared &&
175-
this.cmsConfig.shared.backgroundColor
172+
this.cmsConfig.shared.backgrounds.defaultLayout
176173
) {
177174
const textColorClass = getTextColorClassName(
178-
this.cmsConfig.shared.backgroundColor.trim()
175+
this.cmsConfig.shared.backgrounds.defaultLayout.trim()
179176
);
180177
switch (textColorClass) {
181178
case 'text-white':

packages/fxa-settings/src/components/AppLayout/__snapshots__/index.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ exports[`<AppLayout /> snapshots renders correctly with CMS: header logo 1`] = `
2323
/>
2424
`;
2525

26+
exports[`<AppLayout /> snapshots renders correctly with CMS: split layout main 1`] = `
27+
<main
28+
class="mobileLandscape:flex mobileLandscape:items-center mobileLandscape:flex-1"
29+
/>
30+
`;
31+
2632
exports[`<AppLayout /> snapshots renders correctly with CMS: title 1`] = `"MOCK Shared Title | Mozilla accounts"`;
2733

2834
exports[`<AppLayout /> snapshots renders correctly without CMS: background wrapper 1`] = `

0 commit comments

Comments
 (0)