@paypal/checkout-components 5.0.413 → 5.0.414
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/dist/button.js +1 -1
- package/dist/test/button.js +1 -1
- package/package.json +2 -2
- package/src/funding/common.jsx +6 -0
- package/src/funding/funding.js +8 -1
- package/src/funding/funding.test.js +69 -0
- package/src/funding/itau/config.jsx +21 -8
- package/src/funding/paylater/config.jsx +7 -12
- package/src/funding/sepa/config.jsx +29 -1
- package/src/marks/component.jsx +4 -0
- package/src/ui/buttons/buttons.jsx +2 -0
- package/src/ui/buttons/config.js +50 -26
- package/src/ui/buttons/poweredBy.jsx +8 -3
- package/src/ui/buttons/props.js +7 -29
- package/src/ui/buttons/props.test.js +0 -42
- package/src/ui/buttons/script.jsx +0 -47
- package/src/ui/buttons/styles/button.js +21 -4
- package/src/ui/buttons/styles/color.js +67 -41
- package/src/ui/buttons/styles/disableMaxHeightConfig.test.js +71 -0
- package/src/ui/buttons/styles/labels.js +23 -0
- package/src/ui/buttons/styles/responsive.js +124 -88
- package/src/ui/buttons/styles/styleUtils.js +9 -7
- package/src/ui/buttons/styles/styleUtils.test.js +23 -76
- package/src/ui/buttons/tagline.jsx +8 -4
- package/src/zoid/buttons/component.jsx +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paypal/checkout-components",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.414",
|
|
4
4
|
"description": "PayPal Checkout components, for integrating checkout products.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"@paypal/funding-components": "^1.0.31",
|
|
124
124
|
"@paypal/sdk-client": "^4.0.199",
|
|
125
125
|
"@paypal/sdk-constants": "^1.0.156",
|
|
126
|
-
"@paypal/sdk-logos": "^2.3.
|
|
126
|
+
"@paypal/sdk-logos": "^2.3.7"
|
|
127
127
|
},
|
|
128
128
|
"lint-staged": {
|
|
129
129
|
"**/*": "prettier --write --ignore-unknown"
|
package/src/funding/common.jsx
CHANGED
|
@@ -256,6 +256,8 @@ export const DEFAULT_APM_FUNDING_CONFIG: FundingSourceConfig = {
|
|
|
256
256
|
BUTTON_COLOR.SILVER,
|
|
257
257
|
BUTTON_COLOR.WHITE,
|
|
258
258
|
BUTTON_COLOR.BLACK,
|
|
259
|
+
BUTTON_COLOR.REBRAND_BLACK,
|
|
260
|
+
BUTTON_COLOR.REBRAND_WHITE,
|
|
259
261
|
],
|
|
260
262
|
|
|
261
263
|
logoColors: {
|
|
@@ -263,6 +265,8 @@ export const DEFAULT_APM_FUNDING_CONFIG: FundingSourceConfig = {
|
|
|
263
265
|
[BUTTON_COLOR.SILVER]: LOGO_COLOR.BLACK,
|
|
264
266
|
[BUTTON_COLOR.WHITE]: LOGO_COLOR.BLACK,
|
|
265
267
|
[BUTTON_COLOR.BLACK]: LOGO_COLOR.WHITE,
|
|
268
|
+
[BUTTON_COLOR.REBRAND_BLACK]: LOGO_COLOR.WHITE,
|
|
269
|
+
[BUTTON_COLOR.REBRAND_WHITE]: LOGO_COLOR.BLACK,
|
|
266
270
|
},
|
|
267
271
|
|
|
268
272
|
textColors: {
|
|
@@ -270,6 +274,8 @@ export const DEFAULT_APM_FUNDING_CONFIG: FundingSourceConfig = {
|
|
|
270
274
|
[BUTTON_COLOR.BLACK]: TEXT_COLOR.WHITE,
|
|
271
275
|
[BUTTON_COLOR.SILVER]: TEXT_COLOR.BLACK,
|
|
272
276
|
[BUTTON_COLOR.WHITE]: TEXT_COLOR.BLACK,
|
|
277
|
+
[BUTTON_COLOR.REBRAND_BLACK]: TEXT_COLOR.WHITE,
|
|
278
|
+
[BUTTON_COLOR.REBRAND_WHITE]: TEXT_COLOR.BLACK,
|
|
273
279
|
},
|
|
274
280
|
|
|
275
281
|
secondaryColors: {
|
package/src/funding/funding.js
CHANGED
|
@@ -24,6 +24,7 @@ type IsFundingEligibleOptions = {|
|
|
|
24
24
|
flow: $Values<typeof BUTTON_FLOW>,
|
|
25
25
|
fundingEligibility: FundingEligibilityType,
|
|
26
26
|
enableFunding?: $ReadOnlyArray<?$Values<typeof FUNDING>>,
|
|
27
|
+
disableFunding?: $ReadOnlyArray<?$Values<typeof FUNDING>>,
|
|
27
28
|
components: $ReadOnlyArray<$Values<typeof COMPONENTS>>,
|
|
28
29
|
onShippingChange: ?Function,
|
|
29
30
|
onShippingAddressChange: ?Function,
|
|
@@ -75,6 +76,7 @@ export function isFundingEligible(
|
|
|
75
76
|
fundingSource,
|
|
76
77
|
fundingEligibility,
|
|
77
78
|
enableFunding,
|
|
79
|
+
disableFunding,
|
|
78
80
|
components,
|
|
79
81
|
onShippingChange,
|
|
80
82
|
onShippingAddressChange,
|
|
@@ -93,10 +95,12 @@ export function isFundingEligible(
|
|
|
93
95
|
}: IsFundingEligibleOptions
|
|
94
96
|
): boolean {
|
|
95
97
|
// Temporary: Force credit to be eligible if the experiment is enabled
|
|
98
|
+
// but honor merchant opt-out via disableFunding
|
|
96
99
|
if (
|
|
97
100
|
source === FUNDING.CREDIT &&
|
|
98
101
|
experiment?.paypalCreditButtonCreateVaultSetupTokenExists &&
|
|
99
|
-
flow === BUTTON_FLOW.VAULT_WITHOUT_PURCHASE
|
|
102
|
+
flow === BUTTON_FLOW.VAULT_WITHOUT_PURCHASE &&
|
|
103
|
+
!(disableFunding || []).includes(FUNDING.CREDIT)
|
|
100
104
|
) {
|
|
101
105
|
return true;
|
|
102
106
|
}
|
|
@@ -212,6 +216,7 @@ export function determineEligibleFunding({
|
|
|
212
216
|
platform,
|
|
213
217
|
fundingEligibility,
|
|
214
218
|
enableFunding,
|
|
219
|
+
disableFunding,
|
|
215
220
|
components,
|
|
216
221
|
onShippingChange,
|
|
217
222
|
onShippingAddressChange,
|
|
@@ -234,6 +239,7 @@ export function determineEligibleFunding({
|
|
|
234
239
|
platform: $Values<typeof PLATFORM>,
|
|
235
240
|
fundingEligibility: FundingEligibilityType,
|
|
236
241
|
enableFunding?: $ReadOnlyArray<?$Values<typeof FUNDING>>,
|
|
242
|
+
disableFunding?: $ReadOnlyArray<?$Values<typeof FUNDING>>,
|
|
237
243
|
components: $ReadOnlyArray<$Values<typeof COMPONENTS>>,
|
|
238
244
|
onShippingChange?: ?Function,
|
|
239
245
|
onShippingAddressChange?: ?Function,
|
|
@@ -261,6 +267,7 @@ export function determineEligibleFunding({
|
|
|
261
267
|
fundingSource,
|
|
262
268
|
fundingEligibility,
|
|
263
269
|
enableFunding,
|
|
270
|
+
disableFunding,
|
|
264
271
|
components,
|
|
265
272
|
onShippingChange,
|
|
266
273
|
onShippingAddressChange,
|
|
@@ -431,5 +431,74 @@ describe("Funding eligibility", () => {
|
|
|
431
431
|
expect(result2).toBe(true);
|
|
432
432
|
});
|
|
433
433
|
});
|
|
434
|
+
|
|
435
|
+
describe("createVaultSetupToken credit experiment", () => {
|
|
436
|
+
const creditExperimentOptions = {
|
|
437
|
+
...defaultMockFundingOptions,
|
|
438
|
+
fundingSource: FUNDING.CREDIT,
|
|
439
|
+
flow: BUTTON_FLOW.VAULT_WITHOUT_PURCHASE,
|
|
440
|
+
experiment: {
|
|
441
|
+
paypalCreditButtonCreateVaultSetupTokenExists: true,
|
|
442
|
+
},
|
|
443
|
+
fundingEligibility: {
|
|
444
|
+
...defaultMockFundingOptions.fundingEligibility,
|
|
445
|
+
credit: {
|
|
446
|
+
eligible: false,
|
|
447
|
+
branded: false,
|
|
448
|
+
vaultable: false,
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
beforeEach(() => {
|
|
454
|
+
vi.mocked(getFundingConfig).mockReturnValue({
|
|
455
|
+
...vi.mocked(getFundingConfig)(),
|
|
456
|
+
[FUNDING.CREDIT]: {
|
|
457
|
+
enabled: true,
|
|
458
|
+
automatic: true,
|
|
459
|
+
},
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
test("should force credit eligible when experiment is enabled and disableFunding does not include credit", () => {
|
|
464
|
+
const result = isFundingEligible(FUNDING.CREDIT, {
|
|
465
|
+
...creditExperimentOptions,
|
|
466
|
+
disableFunding: [],
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
expect(result).toBe(true);
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
test("should not force credit eligible when merchant has disableFunding=credit", () => {
|
|
473
|
+
const result = isFundingEligible(FUNDING.CREDIT, {
|
|
474
|
+
...creditExperimentOptions,
|
|
475
|
+
disableFunding: [FUNDING.CREDIT],
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
expect(result).toBe(false);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
test("should not force credit eligible when experiment is disabled", () => {
|
|
482
|
+
const result = isFundingEligible(FUNDING.CREDIT, {
|
|
483
|
+
...creditExperimentOptions,
|
|
484
|
+
disableFunding: [],
|
|
485
|
+
experiment: {
|
|
486
|
+
paypalCreditButtonCreateVaultSetupTokenExists: false,
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
expect(result).toBe(false);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
test("should not force credit eligible when flow is not VAULT_WITHOUT_PURCHASE", () => {
|
|
494
|
+
const result = isFundingEligible(FUNDING.CREDIT, {
|
|
495
|
+
...creditExperimentOptions,
|
|
496
|
+
disableFunding: [],
|
|
497
|
+
flow: BUTTON_FLOW.PURCHASE,
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
expect(result).toBe(false);
|
|
501
|
+
});
|
|
502
|
+
});
|
|
434
503
|
});
|
|
435
504
|
});
|
|
@@ -8,11 +8,14 @@ import {
|
|
|
8
8
|
} from "@paypal/sdk-logos/src";
|
|
9
9
|
|
|
10
10
|
import { BUTTON_COLOR, BUTTON_LAYOUT, DEFAULT } from "../../constants";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_APM_FUNDING_CONFIG,
|
|
13
|
+
type FundingSourceConfig,
|
|
14
|
+
} from "../common";
|
|
12
15
|
|
|
13
16
|
export function getItauConfig(): FundingSourceConfig {
|
|
14
17
|
return {
|
|
15
|
-
...
|
|
18
|
+
...DEFAULT_APM_FUNDING_CONFIG,
|
|
16
19
|
|
|
17
20
|
layouts: [BUTTON_LAYOUT.HORIZONTAL, BUTTON_LAYOUT.VERTICAL],
|
|
18
21
|
|
|
@@ -24,22 +27,32 @@ export function getItauConfig(): FundingSourceConfig {
|
|
|
24
27
|
return ItauLogoInlineSVG({ logoColor, optional });
|
|
25
28
|
},
|
|
26
29
|
|
|
27
|
-
colors: [
|
|
30
|
+
colors: [
|
|
31
|
+
BUTTON_COLOR.DEFAULT,
|
|
32
|
+
BUTTON_COLOR.DARKBLUE,
|
|
33
|
+
BUTTON_COLOR.BLUE,
|
|
34
|
+
BUTTON_COLOR.BLACK,
|
|
35
|
+
BUTTON_COLOR.REBRAND_BLACK,
|
|
36
|
+
BUTTON_COLOR.REBRAND_WHITE,
|
|
37
|
+
],
|
|
28
38
|
|
|
29
39
|
logoColors: {
|
|
40
|
+
[BUTTON_COLOR.DEFAULT]: LOGO_COLOR.WHITE,
|
|
30
41
|
[BUTTON_COLOR.DARKBLUE]: LOGO_COLOR.WHITE,
|
|
31
42
|
[BUTTON_COLOR.BLUE]: LOGO_COLOR.WHITE,
|
|
32
43
|
[BUTTON_COLOR.BLACK]: LOGO_COLOR.WHITE,
|
|
44
|
+
[BUTTON_COLOR.REBRAND_BLACK]: LOGO_COLOR.WHITE,
|
|
45
|
+
[BUTTON_COLOR.REBRAND_WHITE]: LOGO_COLOR.BLACK,
|
|
33
46
|
},
|
|
34
47
|
|
|
35
48
|
secondaryColors: {
|
|
36
|
-
...
|
|
49
|
+
...DEFAULT_APM_FUNDING_CONFIG.secondaryColors,
|
|
37
50
|
|
|
38
|
-
[DEFAULT]: BUTTON_COLOR.
|
|
39
|
-
[BUTTON_COLOR.GOLD]: BUTTON_COLOR.
|
|
51
|
+
[DEFAULT]: BUTTON_COLOR.DEFAULT,
|
|
52
|
+
[BUTTON_COLOR.GOLD]: BUTTON_COLOR.DEFAULT,
|
|
40
53
|
[BUTTON_COLOR.BLUE]: BUTTON_COLOR.BLUE,
|
|
41
|
-
[BUTTON_COLOR.SILVER]: BUTTON_COLOR.
|
|
42
|
-
[BUTTON_COLOR.WHITE]: BUTTON_COLOR.
|
|
54
|
+
[BUTTON_COLOR.SILVER]: BUTTON_COLOR.DEFAULT,
|
|
55
|
+
[BUTTON_COLOR.WHITE]: BUTTON_COLOR.DEFAULT,
|
|
43
56
|
},
|
|
44
57
|
};
|
|
45
58
|
}
|
|
@@ -22,8 +22,7 @@ import css from "./style.scoped.scss";
|
|
|
22
22
|
|
|
23
23
|
function getLabelText(
|
|
24
24
|
fundingEligibility: FundingEligibilityType,
|
|
25
|
-
locale?: LocaleType
|
|
26
|
-
shouldApplyRebrandedStyles?: boolean
|
|
25
|
+
locale?: LocaleType
|
|
27
26
|
): ?string {
|
|
28
27
|
const { paylater } = fundingEligibility;
|
|
29
28
|
const { lang } = locale || {};
|
|
@@ -68,10 +67,12 @@ function getLabelText(
|
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
if (
|
|
71
|
-
paylater?.products?.payIn4?.eligible &&
|
|
72
|
-
|
|
70
|
+
(paylater?.products?.payIn4?.eligible &&
|
|
71
|
+
paylater?.products?.payIn4?.variant === "FR") ||
|
|
72
|
+
(paylater?.products?.paylater?.eligible &&
|
|
73
|
+
paylater?.products?.paylater?.variant === "FR")
|
|
73
74
|
) {
|
|
74
|
-
labelText =
|
|
75
|
+
labelText = "Payer en plusieurs fois";
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
return labelText;
|
|
@@ -136,13 +137,7 @@ export function getPaylaterConfig(): FundingSourceConfig {
|
|
|
136
137
|
) : (
|
|
137
138
|
<PPRebrandLogoInlineSVG logoColor={logoColorPP} />
|
|
138
139
|
)}
|
|
139
|
-
<Text>
|
|
140
|
-
{getLabelText(
|
|
141
|
-
fundingEligibility,
|
|
142
|
-
locale,
|
|
143
|
-
shouldApplyRebrandedStyles
|
|
144
|
-
) || "Pay Later"}
|
|
145
|
-
</Text>
|
|
140
|
+
<Text>{getLabelText(fundingEligibility, locale) || "Pay Later"}</Text>
|
|
146
141
|
</Style>
|
|
147
142
|
);
|
|
148
143
|
},
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
import {
|
|
5
5
|
SepaLogoInlineSVG,
|
|
6
6
|
SepaLogoExternalImage,
|
|
7
|
+
LOGO_COLOR,
|
|
7
8
|
} from "@paypal/sdk-logos/src";
|
|
8
9
|
|
|
9
|
-
import { BUTTON_LAYOUT } from "../../constants";
|
|
10
|
+
import { BUTTON_COLOR, BUTTON_LAYOUT, TEXT_COLOR } from "../../constants";
|
|
10
11
|
import { DEFAULT_FUNDING_CONFIG, type FundingSourceConfig } from "../common";
|
|
11
12
|
|
|
12
13
|
export function getSepaConfig(): FundingSourceConfig {
|
|
@@ -15,6 +16,33 @@ export function getSepaConfig(): FundingSourceConfig {
|
|
|
15
16
|
|
|
16
17
|
layouts: [BUTTON_LAYOUT.VERTICAL],
|
|
17
18
|
|
|
19
|
+
colors: [
|
|
20
|
+
BUTTON_COLOR.DEFAULT,
|
|
21
|
+
BUTTON_COLOR.SILVER,
|
|
22
|
+
BUTTON_COLOR.BLACK,
|
|
23
|
+
BUTTON_COLOR.WHITE,
|
|
24
|
+
BUTTON_COLOR.REBRAND_BLACK,
|
|
25
|
+
BUTTON_COLOR.REBRAND_WHITE,
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
logoColors: {
|
|
29
|
+
[BUTTON_COLOR.DEFAULT]: LOGO_COLOR.BLACK,
|
|
30
|
+
[BUTTON_COLOR.SILVER]: LOGO_COLOR.BLACK,
|
|
31
|
+
[BUTTON_COLOR.WHITE]: LOGO_COLOR.BLACK,
|
|
32
|
+
[BUTTON_COLOR.BLACK]: LOGO_COLOR.WHITE,
|
|
33
|
+
[BUTTON_COLOR.REBRAND_BLACK]: LOGO_COLOR.WHITE,
|
|
34
|
+
[BUTTON_COLOR.REBRAND_WHITE]: LOGO_COLOR.BLACK,
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
textColors: {
|
|
38
|
+
[BUTTON_COLOR.DEFAULT]: TEXT_COLOR.BLACK,
|
|
39
|
+
[BUTTON_COLOR.SILVER]: TEXT_COLOR.BLACK,
|
|
40
|
+
[BUTTON_COLOR.WHITE]: TEXT_COLOR.BLACK,
|
|
41
|
+
[BUTTON_COLOR.BLACK]: TEXT_COLOR.WHITE,
|
|
42
|
+
[BUTTON_COLOR.REBRAND_BLACK]: TEXT_COLOR.WHITE,
|
|
43
|
+
[BUTTON_COLOR.REBRAND_WHITE]: TEXT_COLOR.BLACK,
|
|
44
|
+
},
|
|
45
|
+
|
|
18
46
|
Logo: ({ logoColor, optional }) => {
|
|
19
47
|
if (__WEB__) {
|
|
20
48
|
return SepaLogoExternalImage({ logoColor, optional });
|
package/src/marks/component.jsx
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { getRememberedFunding } from "@paypal/funding-components/src";
|
|
20
20
|
import {
|
|
21
21
|
getEnableFunding,
|
|
22
|
+
getDisableFunding,
|
|
22
23
|
getComponents,
|
|
23
24
|
getFundingEligibility,
|
|
24
25
|
getEnv,
|
|
@@ -78,6 +79,7 @@ export const getMarksComponent: () => MarksComponent = memoize(() => {
|
|
|
78
79
|
const remembered = getRememberedFunding();
|
|
79
80
|
const layout = BUTTON_LAYOUT.VERTICAL;
|
|
80
81
|
const enableFunding = getEnableFunding();
|
|
82
|
+
const disableFunding = getDisableFunding();
|
|
81
83
|
const components = getComponents();
|
|
82
84
|
const flow = BUTTON_FLOW.PURCHASE;
|
|
83
85
|
const applePaySupport = fundingEligibility?.applepay?.eligible
|
|
@@ -103,6 +105,7 @@ export const getMarksComponent: () => MarksComponent = memoize(() => {
|
|
|
103
105
|
fundingSource,
|
|
104
106
|
fundingEligibility,
|
|
105
107
|
enableFunding,
|
|
108
|
+
disableFunding,
|
|
106
109
|
components,
|
|
107
110
|
platform,
|
|
108
111
|
remembered,
|
|
@@ -134,6 +137,7 @@ export const getMarksComponent: () => MarksComponent = memoize(() => {
|
|
|
134
137
|
fundingSource,
|
|
135
138
|
fundingEligibility,
|
|
136
139
|
enableFunding,
|
|
140
|
+
disableFunding,
|
|
137
141
|
components,
|
|
138
142
|
onShippingChange,
|
|
139
143
|
onShippingAddressChange,
|
|
@@ -143,6 +143,7 @@ export function Buttons(props: ButtonsProps): ElementNode {
|
|
|
143
143
|
components,
|
|
144
144
|
content,
|
|
145
145
|
customerId,
|
|
146
|
+
disableFunding,
|
|
146
147
|
displayOnly,
|
|
147
148
|
enableFunding,
|
|
148
149
|
env,
|
|
@@ -181,6 +182,7 @@ export function Buttons(props: ButtonsProps): ElementNode {
|
|
|
181
182
|
platform,
|
|
182
183
|
fundingEligibility,
|
|
183
184
|
enableFunding,
|
|
185
|
+
disableFunding,
|
|
184
186
|
components,
|
|
185
187
|
onShippingChange,
|
|
186
188
|
onShippingAddressChange,
|
package/src/ui/buttons/config.js
CHANGED
|
@@ -27,6 +27,22 @@ export const BUTTON_RELATIVE_STYLE = {
|
|
|
27
27
|
VERTICAL_MARGIN: 30,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
// Rebrand label container height as a ratio of button height (0.5 = 50%).
|
|
31
|
+
// The PayPal logo's translateY is derived from this value to keep the logo
|
|
32
|
+
// visually centered. If this ratio changes, the translateY percentage must
|
|
33
|
+
// be recalculated: translateY = LOGO_VISUAL_OFFSET / LABEL_HEIGHT_RATIO.
|
|
34
|
+
// Additionally, the Venmo and Card glyph viewBox/height in @paypal/sdk-logos
|
|
35
|
+
// must be updated to match the new label container height.
|
|
36
|
+
export const REBRAND_LABEL_HEIGHT_RATIO = 0.5;
|
|
37
|
+
|
|
38
|
+
// Fixed visual offset of the PayPal logo as a fraction of total button height.
|
|
39
|
+
// translateY percentage = LOGO_VISUAL_OFFSET / LABEL_HEIGHT_RATIO
|
|
40
|
+
// Current: 0.05 / 0.5 = 0.10 (10%)
|
|
41
|
+
const LOGO_VISUAL_OFFSET = 0.05;
|
|
42
|
+
export const REBRAND_LOGO_TRANSLATE_Y: number = Math.round(
|
|
43
|
+
(LOGO_VISUAL_OFFSET / REBRAND_LABEL_HEIGHT_RATIO) * 100
|
|
44
|
+
);
|
|
45
|
+
|
|
30
46
|
type ButtonStyleMap = {
|
|
31
47
|
[$Values<typeof BUTTON_SIZE>]: {|
|
|
32
48
|
defaultWidth: number,
|
|
@@ -53,8 +69,8 @@ type ButtonRedesignStyleMap = {
|
|
|
53
69
|
maxHeight: number,
|
|
54
70
|
minWidth: number,
|
|
55
71
|
maxWidth: number,
|
|
56
|
-
gap
|
|
57
|
-
fontSize
|
|
72
|
+
gap: number,
|
|
73
|
+
fontSize: number,
|
|
58
74
|
|},
|
|
59
75
|
};
|
|
60
76
|
|
|
@@ -169,7 +185,7 @@ export const BUTTON_REDESIGN_STYLE: ButtonRedesignStyleMap = {
|
|
|
169
185
|
minWidth: 50,
|
|
170
186
|
maxWidth: 75,
|
|
171
187
|
gap: 3,
|
|
172
|
-
fontSize:
|
|
188
|
+
fontSize: 10,
|
|
173
189
|
},
|
|
174
190
|
|
|
175
191
|
[BUTTON_REDESIGN_SIZE.TINY]: {
|
|
@@ -179,7 +195,7 @@ export const BUTTON_REDESIGN_STYLE: ButtonRedesignStyleMap = {
|
|
|
179
195
|
minWidth: 75,
|
|
180
196
|
maxWidth: 200,
|
|
181
197
|
gap: 3,
|
|
182
|
-
fontSize:
|
|
198
|
+
fontSize: 10,
|
|
183
199
|
},
|
|
184
200
|
|
|
185
201
|
[BUTTON_REDESIGN_SIZE.SMALL]: {
|
|
@@ -188,8 +204,8 @@ export const BUTTON_REDESIGN_STYLE: ButtonRedesignStyleMap = {
|
|
|
188
204
|
maxHeight: 35,
|
|
189
205
|
minWidth: 200,
|
|
190
206
|
maxWidth: 250,
|
|
191
|
-
gap:
|
|
192
|
-
fontSize:
|
|
207
|
+
gap: 4,
|
|
208
|
+
fontSize: 12,
|
|
193
209
|
},
|
|
194
210
|
|
|
195
211
|
[BUTTON_REDESIGN_SIZE.MEDIUM_SMALL]: {
|
|
@@ -199,7 +215,7 @@ export const BUTTON_REDESIGN_STYLE: ButtonRedesignStyleMap = {
|
|
|
199
215
|
minWidth: 250,
|
|
200
216
|
maxWidth: 300,
|
|
201
217
|
gap: 4,
|
|
202
|
-
fontSize:
|
|
218
|
+
fontSize: 14,
|
|
203
219
|
},
|
|
204
220
|
|
|
205
221
|
[BUTTON_REDESIGN_SIZE.MEDIUM_BIG]: {
|
|
@@ -208,8 +224,8 @@ export const BUTTON_REDESIGN_STYLE: ButtonRedesignStyleMap = {
|
|
|
208
224
|
maxHeight: 45,
|
|
209
225
|
minWidth: 300,
|
|
210
226
|
maxWidth: 350,
|
|
211
|
-
gap:
|
|
212
|
-
fontSize:
|
|
227
|
+
gap: 5,
|
|
228
|
+
fontSize: 14,
|
|
213
229
|
},
|
|
214
230
|
|
|
215
231
|
[BUTTON_REDESIGN_SIZE.LARGE_SMALL]: {
|
|
@@ -219,17 +235,17 @@ export const BUTTON_REDESIGN_STYLE: ButtonRedesignStyleMap = {
|
|
|
219
235
|
minWidth: 350,
|
|
220
236
|
maxWidth: 425,
|
|
221
237
|
gap: 5,
|
|
222
|
-
fontSize:
|
|
238
|
+
fontSize: 16,
|
|
223
239
|
},
|
|
224
240
|
|
|
225
241
|
[BUTTON_REDESIGN_SIZE.LARGE_BIG]: {
|
|
226
|
-
defaultHeight:
|
|
242
|
+
defaultHeight: 50,
|
|
227
243
|
minHeight: 50,
|
|
228
244
|
maxHeight: 55,
|
|
229
245
|
minWidth: 425,
|
|
230
246
|
maxWidth: 500,
|
|
231
247
|
gap: 5,
|
|
232
|
-
fontSize:
|
|
248
|
+
fontSize: 18,
|
|
233
249
|
},
|
|
234
250
|
|
|
235
251
|
[BUTTON_REDESIGN_SIZE.XL_SMALL]: {
|
|
@@ -237,28 +253,36 @@ export const BUTTON_REDESIGN_STYLE: ButtonRedesignStyleMap = {
|
|
|
237
253
|
minHeight: 55,
|
|
238
254
|
maxHeight: 60,
|
|
239
255
|
minWidth: 500,
|
|
240
|
-
maxWidth:
|
|
256
|
+
maxWidth: 750,
|
|
241
257
|
gap: 6,
|
|
242
|
-
fontSize:
|
|
258
|
+
fontSize: 18,
|
|
243
259
|
},
|
|
260
|
+
};
|
|
244
261
|
|
|
245
|
-
|
|
246
|
-
|
|
262
|
+
export const BUTTON_REDESIGN_DISABLEMAXHEIGHT_STYLE = {
|
|
263
|
+
...BUTTON_REDESIGN_STYLE,
|
|
264
|
+
XL_BIG: {
|
|
247
265
|
minHeight: 60,
|
|
248
266
|
maxHeight: 65,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
gap: 7,
|
|
252
|
-
fontSize: 24,
|
|
267
|
+
gap: 6,
|
|
268
|
+
fontSize: 20,
|
|
253
269
|
},
|
|
254
|
-
|
|
255
|
-
[BUTTON_REDESIGN_SIZE.XXL]: {
|
|
256
|
-
defaultHeight: 55,
|
|
270
|
+
XXL_SMALL: {
|
|
257
271
|
minHeight: 65,
|
|
258
|
-
maxHeight:
|
|
259
|
-
|
|
260
|
-
|
|
272
|
+
maxHeight: 70,
|
|
273
|
+
gap: 7,
|
|
274
|
+
fontSize: 22,
|
|
275
|
+
},
|
|
276
|
+
XXL_BIG: {
|
|
277
|
+
minHeight: 70,
|
|
278
|
+
maxHeight: 75,
|
|
261
279
|
gap: 7,
|
|
280
|
+
fontSize: 24,
|
|
281
|
+
},
|
|
282
|
+
XXXL: {
|
|
283
|
+
minHeight: 75,
|
|
284
|
+
maxHeight: 200,
|
|
285
|
+
gap: 8,
|
|
262
286
|
fontSize: 26,
|
|
263
287
|
},
|
|
264
288
|
};
|
|
@@ -9,6 +9,7 @@ import { CLASS, BUTTON_COLOR_REBRAND } from "../../constants";
|
|
|
9
9
|
import { Text } from "../text";
|
|
10
10
|
|
|
11
11
|
import { buttonContent } from "./content";
|
|
12
|
+
import { REBRAND_LOGO_TRANSLATE_Y } from "./config";
|
|
12
13
|
|
|
13
14
|
const POWERED_BY_PAYPAL_STYLE = `
|
|
14
15
|
.${CLASS.POWERED_BY} {
|
|
@@ -81,7 +82,7 @@ export function PoweredByPayPal({
|
|
|
81
82
|
.${CLASS.POWERED_BY} {
|
|
82
83
|
text-align: center;
|
|
83
84
|
margin: 10px auto;
|
|
84
|
-
height:
|
|
85
|
+
height: 12px;
|
|
85
86
|
font-family: PayPal Plain, system-ui, -apple-system, Roboto, "Segoe UI", Helvetica-Neue, Helvetica, Arial, sans-serif;
|
|
86
87
|
font-size: 10px;
|
|
87
88
|
font-weight: 400;
|
|
@@ -96,9 +97,13 @@ export function PoweredByPayPal({
|
|
|
96
97
|
.${CLASS.POWERED_BY} > .${LOGO_CLASS.LOGO} {
|
|
97
98
|
display: inline-block;
|
|
98
99
|
vertical-align: middle;
|
|
99
|
-
height:
|
|
100
|
-
line-height:
|
|
100
|
+
height: 12px;
|
|
101
|
+
line-height: 12px;
|
|
101
102
|
font-size: 10px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.${CLASS.POWERED_BY} > .${LOGO_CLASS.LOGO} {
|
|
106
|
+
transform: translateY(${REBRAND_LOGO_TRANSLATE_Y}%);
|
|
102
107
|
}
|
|
103
108
|
`;
|
|
104
109
|
|
package/src/ui/buttons/props.js
CHANGED
|
@@ -473,6 +473,7 @@ export type RenderButtonProps = {|
|
|
|
473
473
|
buttonSessionID: string,
|
|
474
474
|
nonce: string,
|
|
475
475
|
enableFunding?: $ReadOnlyArray<?$Values<typeof FUNDING>>,
|
|
476
|
+
disableFunding?: $ReadOnlyArray<?$Values<typeof FUNDING>>,
|
|
476
477
|
components: $ReadOnlyArray<$Values<typeof COMPONENTS>>,
|
|
477
478
|
onShippingChange: ?OnShippingChange,
|
|
478
479
|
onShippingAddressChange: ?OnShippingAddressChange,
|
|
@@ -675,6 +676,7 @@ export type ButtonPropsInputs = {
|
|
|
675
676
|
shopperSessionId?: string,
|
|
676
677
|
nonce: string,
|
|
677
678
|
enableFunding?: $ReadOnlyArray<?$Values<typeof FUNDING>>,
|
|
679
|
+
disableFunding?: $ReadOnlyArray<?$Values<typeof FUNDING>>,
|
|
678
680
|
components: $ReadOnlyArray<$Values<typeof COMPONENTS>>,
|
|
679
681
|
onShippingChange: ?Function,
|
|
680
682
|
onShippingAddressChange: ?Function,
|
|
@@ -813,27 +815,6 @@ export function determineRandomButtonColor({
|
|
|
813
815
|
};
|
|
814
816
|
}
|
|
815
817
|
|
|
816
|
-
export function hasInvalidScriptOptionsForFullRedesign({
|
|
817
|
-
fundingSource,
|
|
818
|
-
}: {|
|
|
819
|
-
fundingSource?: ?$Values<typeof FUNDING>,
|
|
820
|
-
|}): boolean {
|
|
821
|
-
const validFundingSourcesForRedesign = [
|
|
822
|
-
undefined,
|
|
823
|
-
FUNDING.PAYPAL,
|
|
824
|
-
FUNDING.VENMO,
|
|
825
|
-
FUNDING.PAYLATER,
|
|
826
|
-
FUNDING.CREDIT,
|
|
827
|
-
FUNDING.CARD,
|
|
828
|
-
];
|
|
829
|
-
|
|
830
|
-
if (validFundingSourcesForRedesign.includes(fundingSource)) {
|
|
831
|
-
return false;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
return true;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
818
|
export function throwErrorForInvalidButtonColor({
|
|
838
819
|
fundingSource,
|
|
839
820
|
fundingSourceColors,
|
|
@@ -918,13 +899,10 @@ export function getColorForFullRedesign({
|
|
|
918
899
|
[BUTTON_COLOR.BLUE]: BUTTON_COLOR.REBRAND_BLUE,
|
|
919
900
|
[BUTTON_COLOR.DARKBLUE]: BUTTON_COLOR.REBRAND_BLUE,
|
|
920
901
|
[BUTTON_COLOR.GOLD]: BUTTON_COLOR.REBRAND_BLUE,
|
|
921
|
-
|
|
922
|
-
// not mapped yet since the styles are not setup
|
|
923
|
-
// These should never be hit since legacy experience should be set
|
|
924
902
|
[BUTTON_COLOR.BLACK]: BUTTON_COLOR.REBRAND_BLACK,
|
|
925
903
|
[BUTTON_COLOR.WHITE]: BUTTON_COLOR.REBRAND_WHITE,
|
|
926
904
|
[BUTTON_COLOR.SILVER]: BUTTON_COLOR.REBRAND_WHITE,
|
|
927
|
-
[BUTTON_COLOR.DEFAULT]: BUTTON_COLOR.
|
|
905
|
+
[BUTTON_COLOR.DEFAULT]: BUTTON_COLOR.DEFAULT,
|
|
928
906
|
|
|
929
907
|
// normalizeButtonStyle gets called multiple times and
|
|
930
908
|
// it can be called after color is already be mapped to rebranded style
|
|
@@ -964,9 +942,6 @@ export function getButtonColorExperience({
|
|
|
964
942
|
}: GetButtonColorExperienceArgs): "abTest" | "fullRebrand" | "legacy" {
|
|
965
943
|
const { isPaypalRebrandEnabled, isPaypalRebrandABTestEnabled } =
|
|
966
944
|
experiment || {};
|
|
967
|
-
const rejectRedesign = hasInvalidScriptOptionsForFullRedesign({
|
|
968
|
-
fundingSource,
|
|
969
|
-
});
|
|
970
945
|
|
|
971
946
|
if (!isPaypalRebrandEnabled) {
|
|
972
947
|
return "legacy";
|
|
@@ -977,7 +952,7 @@ export function getButtonColorExperience({
|
|
|
977
952
|
return fundingSource === FUNDING.PAYPAL ? "abTest" : "legacy";
|
|
978
953
|
}
|
|
979
954
|
|
|
980
|
-
return
|
|
955
|
+
return "fullRebrand";
|
|
981
956
|
}
|
|
982
957
|
|
|
983
958
|
export function getButtonColor({
|
|
@@ -1372,6 +1347,7 @@ export function normalizeButtonProps(
|
|
|
1372
1347
|
sessionID = uniqueID(),
|
|
1373
1348
|
buttonSessionID = uniqueID(),
|
|
1374
1349
|
enableFunding,
|
|
1350
|
+
disableFunding,
|
|
1375
1351
|
components = [COMPONENTS.BUTTONS],
|
|
1376
1352
|
nonce,
|
|
1377
1353
|
onShippingChange,
|
|
@@ -1441,6 +1417,7 @@ export function normalizeButtonProps(
|
|
|
1441
1417
|
fundingSource,
|
|
1442
1418
|
fundingEligibility,
|
|
1443
1419
|
enableFunding,
|
|
1420
|
+
disableFunding,
|
|
1444
1421
|
experiment,
|
|
1445
1422
|
components,
|
|
1446
1423
|
onShippingChange,
|
|
@@ -1485,6 +1462,7 @@ export function normalizeButtonProps(
|
|
|
1485
1462
|
sessionID,
|
|
1486
1463
|
nonce,
|
|
1487
1464
|
enableFunding,
|
|
1465
|
+
disableFunding,
|
|
1488
1466
|
components,
|
|
1489
1467
|
onShippingChange,
|
|
1490
1468
|
onShippingAddressChange,
|