Skip to content

Commit f187931

Browse files
authored
Button Color A/B Test (#2469)
1 parent a685a19 commit f187931

File tree

13 files changed

+186
-34
lines changed

13 files changed

+186
-34
lines changed

Diff for: package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@
8585
"conventional-changelog-cli": "^2.0.34",
8686
"cross-env": "^7.0.3",
8787
"flow-bin": "0.155.0",
88+
"flow-remove-types": "2.246.0",
8889
"flow-typed": "^3.8.0",
8990
"fs-extra": "^10.0.0",
91+
"hermes-parser": "0.23.1",
9092
"husky": "^7.0.4",
9193
"imagemagick": "^0.1.3",
9294
"imgur": "^0.3.1",
@@ -105,9 +107,7 @@
105107
"puppeteer": "^1.20.0",
106108
"serve": "^14.0.0",
107109
"vite": "^3.2.4",
108-
"vitest": "^1.3.1",
109-
"flow-remove-types": "2.246.0",
110-
"hermes-parser": "0.23.1"
110+
"vitest": "^1.3.1"
111111
},
112112
"dependencies": {
113113
"@krakenjs/beaver-logger": "^5.7.0",
@@ -122,7 +122,7 @@
122122
"@paypal/funding-components": "^1.0.31",
123123
"@paypal/sdk-client": "^4.0.194",
124124
"@paypal/sdk-constants": "^1.0.146",
125-
"@paypal/sdk-logos": "^2.2.6"
125+
"@paypal/sdk-logos": "^2.2.8"
126126
},
127127
"lint-staged": {
128128
"**/*": "prettier --write --ignore-unknown"

Diff for: src/constants/button.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const BUTTON_LABEL = {
1212

1313
export const BUTTON_COLOR = {
1414
DEFAULT: ("default": "default"),
15+
DEFAULT_BLUE_LIGHT_BLUE: ("defaultBlue_lightBlue": "defaultBlue_lightBlue"),
16+
DEFAULT_BLUE_DARK_BLUE: ("defaultBlue_darkBlue": "defaultBlue_darkBlue"),
1517
GOLD: ("gold": "gold"),
1618
BLUE: ("blue": "blue"),
1719
SILVER: ("silver": "silver"),

Diff for: src/funding/paypal/config.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export function getPayPalConfig(): FundingSourceConfig {
3434
BUTTON_COLOR.SILVER,
3535
BUTTON_COLOR.BLACK,
3636
BUTTON_COLOR.WHITE,
37+
BUTTON_COLOR.DEFAULT_BLUE_LIGHT_BLUE,
38+
BUTTON_COLOR.DEFAULT_BLUE_DARK_BLUE,
3739
],
3840

3941
logoColors: {
@@ -42,6 +44,8 @@ export function getPayPalConfig(): FundingSourceConfig {
4244
[BUTTON_COLOR.BLUE]: LOGO_COLOR.WHITE,
4345
[BUTTON_COLOR.BLACK]: LOGO_COLOR.WHITE,
4446
[BUTTON_COLOR.WHITE]: LOGO_COLOR.BLUE,
47+
[BUTTON_COLOR.DEFAULT_BLUE_LIGHT_BLUE]: LOGO_COLOR.BLACK,
48+
[BUTTON_COLOR.DEFAULT_BLUE_DARK_BLUE]: LOGO_COLOR.BLUE,
4549
},
4650

4751
labelText: ({ content, label, period }) => {

Diff for: src/funding/paypal/template.jsx

+23-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import {
1111
PPLogoExternalImage,
1212
PPLogoInlineSVG,
1313
PayPalLogoExternalImage,
14+
PayPalRebrandLogoExternalImage,
1415
PayPalLogoInlineSVG,
16+
PayPalRebrandLogoInlineSVG,
1517
CreditLogoExternalImage,
1618
CreditLogoInlineSVG,
1719
CreditMarkExternalImage,
@@ -46,11 +48,29 @@ import {
4648

4749
import css from "./style.scoped.scss";
4850

49-
export function Logo({ logoColor }: LogoOptions): ChildType {
51+
export function Logo({ logoColor, experiment }: LogoOptions): ChildType {
52+
const { isPaypalRebrandEnabled, defaultBlueButtonColor } = experiment;
53+
54+
if (defaultBlueButtonColor === "gold" || !isPaypalRebrandEnabled) {
55+
// csnw globals.js
56+
return __WEB__ ? (
57+
// helps reduce bundle size by fetching logos
58+
<PayPalLogoExternalImage logoColor={logoColor} />
59+
) : (
60+
// cdnx/sdk-logo/xxxx/paypal-gold.svg
61+
// use for server side rendering
62+
<PayPalLogoInlineSVG logoColor={logoColor} />
63+
);
64+
}
65+
66+
// csnw globals.js
5067
return __WEB__ ? (
51-
<PayPalLogoExternalImage logoColor={logoColor} />
68+
// helps reduce bundle size by fetching logos
69+
<PayPalRebrandLogoExternalImage logoColor={logoColor} />
5270
) : (
53-
<PayPalLogoInlineSVG logoColor={logoColor} />
71+
// cdnx/sdk-logo/xxxx/paypal-gold.svg
72+
// use for server side rendering
73+
<PayPalRebrandLogoInlineSVG logoColor={logoColor} />
5474
);
5575
}
5676

Diff for: src/types.js

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { CARD, WALLET_INSTRUMENT } from "@paypal/sdk-constants/src";
44

5+
import { BUTTON_COLOR } from "./constants";
6+
57
export type SecondaryInstruments = $ReadOnlyArray<{|
68
type: string,
79
label: string,
@@ -62,6 +64,8 @@ export type Experiment = {|
6264
venmoWebEnabled?: boolean,
6365
// first render experiments
6466
venmoVaultWithoutPurchase?: boolean,
67+
isPaypalRebrandEnabled?: boolean,
68+
defaultBlueButtonColor?: $Values<typeof BUTTON_COLOR>,
6569
venmoEnableWebOnNonNativeBrowser?: boolean,
6670
|};
6771

Diff for: src/ui/buttons/button.jsx

+7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export function Button({
9797
vault,
9898
}: IndividualButtonProps): ElementNode {
9999
const { layout, shape, borderRadius } = style;
100+
const { isPaypalRebrandEnabled, defaultBlueButtonColor } = experiment;
100101

101102
const fundingConfig = getFundingConfig()[fundingSource];
102103

@@ -126,6 +127,12 @@ export function Button({
126127
color = colors[0];
127128
}
128129

130+
if (isPaypalRebrandEnabled) {
131+
const shouldRenderButtonColorControl = defaultBlueButtonColor === "gold";
132+
const experimentButtonColor = defaultBlueButtonColor || "gold";
133+
134+
color = shouldRenderButtonColorControl ? color : experimentButtonColor;
135+
}
129136
// The secondary colors are used to render the smart stack (multiple buttons)
130137
// they keep track of the mapping of the color style prop to the
131138
if (multiple && i > 0) {

Diff for: src/ui/buttons/buttons.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ export function Buttons(props: ButtonsProps): ElementNode {
251251
].join(" ")}
252252
>
253253
<Style
254+
experiment={experiment}
254255
nonce={nonce}
255256
style={style}
256257
fundingEligibility={fundingEligibility}

Diff for: src/ui/buttons/props.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,8 @@ export function normalizeButtonStyle(
648648
}
649649

650650
props = props || getDefaultButtonPropsInput();
651-
const { fundingSource } = props;
651+
const { fundingSource, experiment } = props;
652+
const { isPaypalRebrandEnabled, defaultBlueButtonColor } = experiment || {};
652653

653654
const FUNDING_CONFIG = getFundingConfig();
654655
const fundingConfig =
@@ -677,6 +678,14 @@ export function normalizeButtonStyle(
677678
borderRadius,
678679
} = style;
679680

681+
// This sets the button color so it gets passed to the query string parameter style.color to scnw
682+
if (isPaypalRebrandEnabled) {
683+
const shouldRenderButtonColorControl = defaultBlueButtonColor === "gold";
684+
const experimentButtonColor = defaultBlueButtonColor || "gold";
685+
686+
color = shouldRenderButtonColorControl ? color : experimentButtonColor;
687+
}
688+
680689
// $FlowFixMe
681690
if (tagline === "false") {
682691
// $FlowFixMe

Diff for: src/ui/buttons/style.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44
import { node, type ElementNode } from "@krakenjs/jsx-pragmatic/src";
55
import { type FundingEligibilityType } from "@paypal/sdk-constants/src";
66

7+
import type { Experiment } from "../../types";
8+
79
import { type ButtonStyle } from "./props";
810
import { componentStyle } from "./styles";
911

1012
type StyleProps = {|
1113
style: ButtonStyle,
1214
nonce: string,
1315
fundingEligibility: FundingEligibilityType,
16+
experiment: Experiment,
1417
|};
1518

1619
export function Style({
1720
style,
1821
nonce,
1922
fundingEligibility,
23+
experiment,
2024
}: StyleProps): ElementNode {
2125
const { height, disableMaxWidth, disableMaxHeight, borderRadius } = style;
2226
const css = componentStyle({
@@ -25,6 +29,7 @@ export function Style({
2529
disableMaxWidth,
2630
disableMaxHeight,
2731
borderRadius,
32+
experiment,
2833
});
2934

3035
return <style nonce={nonce} innerHTML={css} />;

Diff for: src/ui/buttons/styles/base.js

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { type FundingEligibilityType } from "@paypal/sdk-constants/src";
44

5+
import type { Experiment } from "../../../types";
6+
57
import { pageStyle } from "./page";
68
import { buttonStyle } from "./button";
79
import { labelStyle } from "./labels";
@@ -14,12 +16,14 @@ export function componentStyle({
1416
disableMaxWidth,
1517
disableMaxHeight,
1618
borderRadius,
19+
experiment,
1720
}: {|
1821
height?: ?number,
1922
fundingEligibility: FundingEligibilityType,
2023
disableMaxWidth?: ?boolean,
2124
disableMaxHeight?: ?boolean,
2225
borderRadius?: ?number,
26+
experiment: Experiment,
2327
|}): string {
2428
return `
2529
${pageStyle}
@@ -32,6 +36,7 @@ export function componentStyle({
3236
disableMaxWidth,
3337
disableMaxHeight,
3438
borderRadius,
39+
experiment,
3540
})}
3641
`;
3742
}

Diff for: src/ui/buttons/styles/color.js

+38
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,44 @@ export const buttonColorStyle = `
2525
border-top-color: rgba(255, 255, 255, .85);
2626
}
2727
28+
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT_BLUE_LIGHT_BLUE},
29+
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT_BLUE_LIGHT_BLUE} .menu-button {
30+
background: #60CDFF;
31+
}
32+
33+
@media (hover:hover) {
34+
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT_BLUE_LIGHT_BLUE}:hover {
35+
background: #008CFF;
36+
overflow: inherit;
37+
}
38+
}
39+
40+
@media (hover:hover) {
41+
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT_BLUE_LIGHT_BLUE}:active {
42+
background: #E3F7FF;
43+
overflow: inherit;
44+
}
45+
}
46+
47+
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT_BLUE_DARK_BLUE},
48+
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT_BLUE_DARK_BLUE} .menu-button {
49+
background: #002991;
50+
}
51+
52+
@media (hover:hover) {
53+
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT_BLUE_DARK_BLUE}:hover {
54+
background: #0038BA;
55+
overflow: inherit;
56+
}
57+
}
58+
59+
@media (hover:hover) {
60+
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.DEFAULT_BLUE_DARK_BLUE}:active {
61+
background: #0057D9;
62+
overflow: inherit;
63+
}
64+
}
65+
2866
.${CLASS.BUTTON}.${CLASS.COLOR}-${BUTTON_COLOR.GOLD},
2967
.${CLASS.BUTTON_ROW}.${CLASS.COLOR}-${BUTTON_COLOR.GOLD} .menu-button {
3068
background: #ffc439;

0 commit comments

Comments
 (0)