@paypal/checkout-components 5.0.256 → 5.0.258
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/README.md +8 -0
- package/__sdk__.js +72 -76
- package/dist/button.js +1 -1
- package/globals.js +28 -30
- package/package.json +6 -4
- package/src/constants/button.js +37 -36
- package/src/constants/class.js +32 -30
- package/src/constants/index.js +3 -3
- package/src/constants/misc.js +14 -12
- package/src/declarations.js +19 -19
- package/src/funding/applepay/config.jsx +51 -50
- package/src/funding/applepay/index.js +1 -1
- package/src/funding/applepay/style.scoped.scss +1 -1
- package/src/funding/applepay/template.jsx +16 -11
- package/src/funding/bancontact/config.jsx +48 -37
- package/src/funding/bancontact/index.js +1 -2
- package/src/funding/blik/config.jsx +48 -37
- package/src/funding/blik/index.js +1 -2
- package/src/funding/boleto/config.jsx +50 -39
- package/src/funding/boleto/index.js +1 -2
- package/src/funding/card/amex/config.js +9 -8
- package/src/funding/card/amex/index.js +1 -2
- package/src/funding/card/config.jsx +246 -177
- package/src/funding/card/discover/config.js +9 -7
- package/src/funding/card/discover/index.js +1 -2
- package/src/funding/card/elo/config.js +6 -7
- package/src/funding/card/elo/index.js +1 -2
- package/src/funding/card/hiper/config.js +9 -7
- package/src/funding/card/hiper/index.js +1 -2
- package/src/funding/card/index.js +1 -1
- package/src/funding/card/jcb/config.js +6 -7
- package/src/funding/card/jcb/index.js +1 -2
- package/src/funding/card/mastercard/config.js +9 -7
- package/src/funding/card/mastercard/index.js +1 -2
- package/src/funding/card/visa/config.js +9 -7
- package/src/funding/card/visa/index.js +1 -2
- package/src/funding/common.jsx +242 -216
- package/src/funding/config.js +212 -65
- package/src/funding/content.jsx +1946 -337
- package/src/funding/credit/config.jsx +74 -57
- package/src/funding/credit/index.js +1 -2
- package/src/funding/eps/config.jsx +45 -37
- package/src/funding/eps/index.js +1 -2
- package/src/funding/funding.js +193 -100
- package/src/funding/giropay/config.jsx +48 -38
- package/src/funding/giropay/index.js +1 -2
- package/src/funding/ideal/config.jsx +48 -37
- package/src/funding/ideal/index.js +1 -2
- package/src/funding/index.js +2 -2
- package/src/funding/itau/config.jsx +41 -41
- package/src/funding/itau/index.js +1 -1
- package/src/funding/maxima/config.jsx +25 -19
- package/src/funding/maxima/index.js +1 -2
- package/src/funding/mercadopago/config.jsx +48 -37
- package/src/funding/mercadopago/index.js +1 -2
- package/src/funding/multibanco/config.jsx +50 -39
- package/src/funding/multibanco/index.js +1 -2
- package/src/funding/mybank/config.jsx +48 -37
- package/src/funding/mybank/index.js +1 -2
- package/src/funding/oxxo/config.jsx +50 -39
- package/src/funding/oxxo/index.js +1 -2
- package/src/funding/p24/config.jsx +45 -37
- package/src/funding/p24/index.js +1 -2
- package/src/funding/paidy/config.jsx +50 -39
- package/src/funding/paidy/index.js +1 -1
- package/src/funding/paylater/config.jsx +118 -111
- package/src/funding/paylater/index.js +1 -2
- package/src/funding/paypal/config.jsx +44 -46
- package/src/funding/paypal/index.js +1 -2
- package/src/funding/paypal/style.scoped.scss +80 -74
- package/src/funding/paypal/template.jsx +450 -354
- package/src/funding/payu/config.jsx +50 -39
- package/src/funding/payu/index.js +1 -1
- package/src/funding/satispay/config.jsx +50 -39
- package/src/funding/satispay/index.js +1 -1
- package/src/funding/sepa/config.jsx +19 -13
- package/src/funding/sepa/index.js +1 -2
- package/src/funding/sofort/config.jsx +48 -37
- package/src/funding/sofort/index.js +1 -2
- package/src/funding/trustly/config.jsx +50 -39
- package/src/funding/trustly/index.js +1 -2
- package/src/funding/venmo/config.jsx +80 -75
- package/src/funding/venmo/index.js +1 -2
- package/src/funding/venmo/style.scoped.scss +30 -32
- package/src/funding/venmo/template.jsx +56 -57
- package/src/funding/verkkopankki/config.jsx +50 -39
- package/src/funding/verkkopankki/index.js +1 -1
- package/src/funding/wechatpay/config.jsx +48 -37
- package/src/funding/wechatpay/index.js +1 -2
- package/src/funding/zimpler/config.jsx +19 -13
- package/src/funding/zimpler/index.js +1 -2
- package/src/interface/button.js +60 -44
- package/src/interface/card-fields.js +11 -8
- package/src/interface/fields.js +7 -4
- package/src/interface/marks.js +4 -4
- package/src/interface/payment-fields.js +7 -4
- package/src/interface/wallet.js +4 -4
- package/src/lib/errors.js +7 -7
- package/src/lib/index.js +5 -5
- package/src/lib/isRTLLanguage.js +3 -3
- package/src/lib/perceived-latency-instrumentation.js +54 -36
- package/src/lib/security.js +21 -17
- package/src/lib/session.js +39 -35
- package/src/marks/component.jsx +114 -65
- package/src/marks/index.js +1 -2
- package/src/marks/template.jsx +79 -65
- package/src/types.js +48 -48
- package/src/ui/buttons/button.jsx +311 -249
- package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
- package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
- package/src/ui/buttons/buttonDesigns/index.js +78 -75
- package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
- package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
- package/src/ui/buttons/buttonDesigns/types.js +6 -7
- package/src/ui/buttons/buttons.jsx +318 -212
- package/src/ui/buttons/config.js +62 -59
- package/src/ui/buttons/content.jsx +304 -119
- package/src/ui/buttons/index.js +1 -1
- package/src/ui/buttons/menu-button/index.js +1 -1
- package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
- package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
- package/src/ui/buttons/poweredBy.jsx +23 -23
- package/src/ui/buttons/props.js +680 -529
- package/src/ui/buttons/script.jsx +182 -160
- package/src/ui/buttons/spinner.jsx +4 -6
- package/src/ui/buttons/style.jsx +15 -14
- package/src/ui/buttons/styles/base.js +24 -16
- package/src/ui/buttons/styles/button.js +24 -22
- package/src/ui/buttons/styles/color.js +118 -118
- package/src/ui/buttons/styles/custom.js +30 -24
- package/src/ui/buttons/styles/index.js +1 -1
- package/src/ui/buttons/styles/labels.js +17 -13
- package/src/ui/buttons/styles/page.js +3 -3
- package/src/ui/buttons/styles/responsive.js +226 -118
- package/src/ui/buttons/tagline.jsx +53 -54
- package/src/ui/chevron.jsx +27 -16
- package/src/ui/index.js +3 -3
- package/src/ui/loading.jsx +25 -18
- package/src/ui/text/index.js +1 -1
- package/src/ui/text/style.scoped.scss +25 -26
- package/src/ui/text/text.jsx +42 -20
- package/src/ui/tracking.jsx +18 -11
- package/src/zoid/buttons/component.jsx +836 -684
- package/src/zoid/buttons/container.jsx +140 -107
- package/src/zoid/buttons/index.js +1 -1
- package/src/zoid/buttons/prerender.jsx +84 -64
- package/src/zoid/buttons/util.js +355 -254
- package/src/zoid/card-fields/component.jsx +581 -549
- package/src/zoid/card-fields/index.js +1 -1
- package/src/zoid/card-fields/prerender.jsx +20 -17
- package/src/zoid/card-form/component.js +155 -141
- package/src/zoid/card-form/index.js +1 -1
- package/src/zoid/checkout/component.jsx +314 -282
- package/src/zoid/checkout/config.js +2 -2
- package/src/zoid/checkout/content.js +190 -154
- package/src/zoid/checkout/hacks.js +31 -28
- package/src/zoid/checkout/index.js +2 -2
- package/src/zoid/checkout/props.js +27 -33
- package/src/zoid/installments/component.jsx +83 -70
- package/src/zoid/installments/index.js +1 -1
- package/src/zoid/installments/props.js +1 -1
- package/src/zoid/menu/component.jsx +53 -48
- package/src/zoid/menu/index.js +1 -1
- package/src/zoid/menu/props.js +1 -3
- package/src/zoid/modal/component.jsx +119 -106
- package/src/zoid/modal/index.js +1 -1
- package/src/zoid/modal/props.js +1 -3
- package/src/zoid/payment-fields/component.jsx +215 -191
- package/src/zoid/payment-fields/container.jsx +73 -64
- package/src/zoid/payment-fields/index.js +1 -1
- package/src/zoid/payment-fields/prerender.jsx +16 -14
- package/src/zoid/payment-fields/props.js +6 -6
- package/src/zoid/qr-code/component.jsx +131 -115
- package/src/zoid/qr-code/container.jsx +74 -68
- package/src/zoid/qr-code/index.js +1 -1
- package/src/zoid/qr-code/prerender.jsx +17 -12
- package/src/zoid/qr-code/types.js +2 -2
- package/src/zoid/wallet/component.jsx +298 -260
- package/src/zoid/wallet/container.jsx +73 -64
- package/src/zoid/wallet/index.js +1 -1
- package/src/zoid/wallet/prerender.jsx +14 -14
- package/src/zoid/wallet/props.js +4 -4
- package/src/actions/save/index.js +0 -40
- package/src/interface/actions.js +0 -14
- package/src/lib/getLogoCDNExperiment.js +0 -25
|
@@ -1,85 +1,101 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
/** @jsx node */
|
|
3
|
-
import { LOGO_CLASS } from
|
|
4
|
-
import { node, Fragment, type ChildType } from
|
|
3
|
+
import { LOGO_CLASS } from "@paypal/sdk-logos/src";
|
|
4
|
+
import { node, Fragment, type ChildType } from "@krakenjs/jsx-pragmatic/src";
|
|
5
5
|
|
|
6
|
-
import { CLASS } from
|
|
7
|
-
import { BUTTON_SIZE_STYLE } from
|
|
6
|
+
import { CLASS } from "../../../constants";
|
|
7
|
+
import { BUTTON_SIZE_STYLE } from "../config";
|
|
8
8
|
|
|
9
|
-
import { type ContentOptions } from
|
|
9
|
+
import { type ContentOptions } from "./types";
|
|
10
10
|
|
|
11
11
|
type DivideLogoAnimationProps = {|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
paypalLabelContainerElement: Object,
|
|
13
|
+
paypalLogoStartingLeftPosition: string,
|
|
14
|
+
designContainer: Object,
|
|
15
15
|
|};
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
export const DIVIDE_LOGO_CONFIG = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
min: BUTTON_SIZE_STYLE.large.minWidth,
|
|
19
|
+
max: BUTTON_SIZE_STYLE.huge.maxWidth,
|
|
20
|
+
cssUtilClasses: {
|
|
21
|
+
DOM_READY: CLASS.DOM_READY,
|
|
22
|
+
PAYPAL_LOGO: LOGO_CLASS.LOGO,
|
|
23
|
+
PAYPAL_BUTTON_LABEL: CLASS.BUTTON_LABEL,
|
|
24
|
+
PAYPAL_LOGO_PP: CLASS.LOGO_PP,
|
|
25
|
+
},
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
// Returns props necessary to render the animation as long as they are valid
|
|
30
|
-
export const getDivideLogoProps = function (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
29
|
+
export const getDivideLogoProps = function (
|
|
30
|
+
document: Object,
|
|
31
|
+
configuration: Object
|
|
32
|
+
): DivideLogoAnimationProps | null {
|
|
33
|
+
const { PAYPAL_BUTTON_LABEL, PAYPAL_LOGO, PAYPAL_LOGO_PP } =
|
|
34
|
+
configuration.cssUtilClasses;
|
|
35
|
+
|
|
36
|
+
const designContainer =
|
|
37
|
+
(document && document.querySelector(".personalized-design-container")) ||
|
|
38
|
+
null;
|
|
39
|
+
if (!designContainer) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// return null if animation should not be played for the button size
|
|
44
|
+
const designContainerWidth = designContainer.offsetWidth;
|
|
45
|
+
if (
|
|
46
|
+
designContainerWidth < configuration.min ||
|
|
47
|
+
designContainerWidth > configuration.max
|
|
48
|
+
) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// get the label container that animation will be applied to
|
|
53
|
+
const paypalLabelContainerElement =
|
|
54
|
+
designContainer.querySelector(`.${PAYPAL_BUTTON_LABEL}`) || null;
|
|
55
|
+
if (!paypalLabelContainerElement) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// get starting position for element so it doesn't flicker when animation begins
|
|
60
|
+
const paypalLogoElement =
|
|
61
|
+
(paypalLabelContainerElement &&
|
|
62
|
+
paypalLabelContainerElement.querySelector(
|
|
63
|
+
`.${PAYPAL_LOGO}.${PAYPAL_LOGO_PP}`
|
|
64
|
+
)) ||
|
|
65
|
+
null;
|
|
66
|
+
if (!paypalLogoElement) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const paypalLogoStartingLeftPosition = `${
|
|
70
|
+
(paypalLogoElement.offsetLeft / paypalLabelContainerElement.offsetWidth) *
|
|
71
|
+
100
|
|
72
|
+
}%`;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
paypalLabelContainerElement,
|
|
76
|
+
paypalLogoStartingLeftPosition,
|
|
77
|
+
designContainer,
|
|
78
|
+
};
|
|
62
79
|
};
|
|
63
80
|
|
|
64
|
-
export function getDivideLogoAnimation(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.${ DOM_READY } .personalized-design-container img.${ PAYPAL_LOGO }.${ PAYPAL_LOGO_PP }{
|
|
81
|
+
export function getDivideLogoAnimation(
|
|
82
|
+
designProps: DivideLogoAnimationProps,
|
|
83
|
+
configuration: Object
|
|
84
|
+
): void {
|
|
85
|
+
const {
|
|
86
|
+
min,
|
|
87
|
+
max,
|
|
88
|
+
cssUtilClasses: { DOM_READY, PAYPAL_LOGO, PAYPAL_LOGO_PP },
|
|
89
|
+
} = configuration;
|
|
90
|
+
|
|
91
|
+
const {
|
|
92
|
+
paypalLabelContainerElement,
|
|
93
|
+
paypalLogoStartingLeftPosition,
|
|
94
|
+
designContainer,
|
|
95
|
+
} = designProps;
|
|
96
|
+
|
|
97
|
+
const designCss = `
|
|
98
|
+
.${DOM_READY} .personalized-design-container img.${PAYPAL_LOGO}.${PAYPAL_LOGO_PP}{
|
|
83
99
|
animation: 3s divide-logo-animation-left-side 2s infinite alternate;
|
|
84
100
|
}
|
|
85
101
|
|
|
@@ -90,11 +106,11 @@ export function getDivideLogoAnimation(designProps : DivideLogoAnimationProps, c
|
|
|
90
106
|
@keyframes divide-logo-animation-left-side {
|
|
91
107
|
0% {
|
|
92
108
|
position: fixed;
|
|
93
|
-
left: ${
|
|
109
|
+
left: ${paypalLogoStartingLeftPosition};
|
|
94
110
|
}
|
|
95
111
|
33% {
|
|
96
112
|
position: fixed;
|
|
97
|
-
left: ${
|
|
113
|
+
left: ${paypalLogoStartingLeftPosition};
|
|
98
114
|
}
|
|
99
115
|
66% {
|
|
100
116
|
position: fixed;
|
|
@@ -130,35 +146,45 @@ export function getDivideLogoAnimation(designProps : DivideLogoAnimationProps, c
|
|
|
130
146
|
}
|
|
131
147
|
`;
|
|
132
148
|
|
|
133
|
-
|
|
134
|
-
|
|
149
|
+
if (paypalLabelContainerElement) {
|
|
150
|
+
const style = document.createElement("style");
|
|
151
|
+
paypalLabelContainerElement.appendChild(style);
|
|
152
|
+
style.appendChild(document.createTextNode(designCss));
|
|
153
|
+
|
|
154
|
+
window.addEventListener("resize", () => {
|
|
155
|
+
// Remove animation if size limit broken
|
|
156
|
+
if (
|
|
157
|
+
(designContainer.offsetWidth > max ||
|
|
158
|
+
designContainer.offsetWidth < min) &&
|
|
159
|
+
paypalLabelContainerElement.contains(style)
|
|
160
|
+
) {
|
|
161
|
+
paypalLabelContainerElement.removeChild(style);
|
|
162
|
+
} else if (
|
|
163
|
+
(designContainer.offsetWidth <= max ||
|
|
164
|
+
designContainer.offsetWidth >= min) &&
|
|
165
|
+
!paypalLabelContainerElement.contains(style)
|
|
166
|
+
) {
|
|
135
167
|
paypalLabelContainerElement.appendChild(style);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
window.addEventListener('resize', () => {
|
|
140
|
-
// Remove animation if size limit broken
|
|
141
|
-
if (
|
|
142
|
-
(designContainer.offsetWidth > max || designContainer.offsetWidth < min)
|
|
143
|
-
&& paypalLabelContainerElement.contains(style)
|
|
144
|
-
) {
|
|
145
|
-
paypalLabelContainerElement.removeChild(style);
|
|
146
|
-
} else if (
|
|
147
|
-
(designContainer.offsetWidth <= max || designContainer.offsetWidth >= min)
|
|
148
|
-
&& !paypalLabelContainerElement.contains(style)
|
|
149
|
-
) {
|
|
150
|
-
paypalLabelContainerElement.appendChild(style);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
154
171
|
}
|
|
155
172
|
|
|
156
|
-
export function DivideLogoTextComponent({
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
173
|
+
export function DivideLogoTextComponent({
|
|
174
|
+
designLabelText,
|
|
175
|
+
}: ContentOptions): ChildType {
|
|
176
|
+
return (
|
|
177
|
+
<Fragment>
|
|
178
|
+
<div
|
|
179
|
+
class={"personalized-label-container"}
|
|
180
|
+
data-design-experiment="104519"
|
|
181
|
+
>
|
|
182
|
+
{" "}
|
|
183
|
+
<span>{designLabelText}</span>
|
|
184
|
+
</div>
|
|
185
|
+
<style
|
|
186
|
+
innerHTML={`
|
|
187
|
+
.${CLASS.DOM_READY} .personalized-design-container img.${LOGO_CLASS.LOGO}{
|
|
162
188
|
position: relative;
|
|
163
189
|
}
|
|
164
190
|
|
|
@@ -175,7 +201,9 @@ export function DivideLogoTextComponent({ designLabelText } : ContentOptions) :
|
|
|
175
201
|
flex-direction: column;
|
|
176
202
|
justify-content: space-around;
|
|
177
203
|
}
|
|
178
|
-
`
|
|
179
|
-
|
|
180
|
-
|
|
204
|
+
`}
|
|
205
|
+
/>
|
|
206
|
+
;
|
|
207
|
+
</Fragment>
|
|
208
|
+
);
|
|
181
209
|
}
|
|
@@ -1,92 +1,95 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import { type ChildType } from
|
|
2
|
+
import { type ChildType } from "@krakenjs/jsx-pragmatic/src";
|
|
3
3
|
|
|
4
|
-
import { type Personalization } from
|
|
4
|
+
import { type Personalization } from "../props";
|
|
5
5
|
|
|
6
|
-
import { getDesignScript } from
|
|
7
|
-
import { type ButtonDesignOutputParams } from
|
|
8
|
-
import { ControlDesignComponent } from
|
|
6
|
+
import { getDesignScript } from "./script";
|
|
7
|
+
import { type ButtonDesignOutputParams } from "./types";
|
|
8
|
+
import { ControlDesignComponent } from "./control";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from
|
|
10
|
+
getDivideLogoAnimation,
|
|
11
|
+
getDivideLogoProps,
|
|
12
|
+
DIVIDE_LOGO_CONFIG,
|
|
13
|
+
DivideLogoTextComponent,
|
|
14
|
+
} from "./divideLogoAnimation";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from
|
|
16
|
+
getInlineLabelTextDesign,
|
|
17
|
+
getValidInlineLogoTextProps,
|
|
18
|
+
INLINE_LOGO_TEXT_CONFIG,
|
|
19
|
+
InlineLogoTextComponent,
|
|
20
|
+
} from "./inlineLogoTextDesign";
|
|
21
21
|
|
|
22
|
-
const DESIGN_MAP
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
const DESIGN_MAP: Object = {
|
|
23
|
+
"run-divide-logo-animation": {
|
|
24
|
+
designFn: getDivideLogoAnimation,
|
|
25
|
+
getValidDesignProps: getDivideLogoProps,
|
|
26
|
+
designConfig: DIVIDE_LOGO_CONFIG,
|
|
27
|
+
ButtonDesignComponent: DivideLogoTextComponent,
|
|
28
|
+
},
|
|
29
|
+
"run-add-label-text-next-to-logo-design": {
|
|
30
|
+
designFn: getInlineLabelTextDesign,
|
|
31
|
+
getValidDesignProps: getValidInlineLogoTextProps,
|
|
32
|
+
designConfig: INLINE_LOGO_TEXT_CONFIG,
|
|
33
|
+
ButtonDesignComponent: InlineLogoTextComponent,
|
|
34
|
+
},
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const CONTROL_MAP
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const CONTROL_MAP: Object = {
|
|
38
|
+
"large-button-design-control": "104519",
|
|
39
|
+
"small-button-design-control": "104530",
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
export function getButtonDesign(
|
|
42
|
+
export function getButtonDesign(
|
|
43
|
+
personalization: ?Personalization
|
|
44
|
+
): ButtonDesignOutputParams | Object {
|
|
45
|
+
// check valid personalization
|
|
46
|
+
if (
|
|
47
|
+
__WEB__ ||
|
|
48
|
+
!personalization ||
|
|
49
|
+
typeof personalization !== "object" ||
|
|
50
|
+
!personalization.buttonDesign
|
|
51
|
+
) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
) {
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const {
|
|
55
|
-
buttonDesign: {
|
|
56
|
-
id: designId = '',
|
|
57
|
-
text: designLabelText = 'Safe and easy way to pay'
|
|
58
|
-
} = {}
|
|
59
|
-
} = personalization;
|
|
55
|
+
const {
|
|
56
|
+
buttonDesign: {
|
|
57
|
+
id: designId = "",
|
|
58
|
+
text: designLabelText = "Safe and easy way to pay",
|
|
59
|
+
} = {},
|
|
60
|
+
} = personalization;
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
// Return fragment with data-design-experiment tag for logging
|
|
63
|
+
if (CONTROL_MAP[designId]) {
|
|
64
|
+
const buttonDesignComponent: ChildType = ControlDesignComponent(
|
|
65
|
+
CONTROL_MAP[designId]
|
|
66
|
+
);
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!DESIGN_MAP[designId]) {
|
|
73
|
-
return {};
|
|
74
|
-
}
|
|
68
|
+
return {
|
|
69
|
+
buttonDesignContainerClass: "",
|
|
70
|
+
buttonDesignScript: "",
|
|
71
|
+
buttonDesignComponent,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
designConfig,
|
|
80
|
-
ButtonDesignComponent
|
|
81
|
-
} = DESIGN_MAP[designId];
|
|
75
|
+
if (!DESIGN_MAP[designId]) {
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
82
78
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const buttonDesignComponent : ChildType = ButtonDesignComponent(designContent);
|
|
79
|
+
const { designFn, getValidDesignProps, designConfig, ButtonDesignComponent } =
|
|
80
|
+
DESIGN_MAP[designId];
|
|
86
81
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
const designContent = { designLabelText };
|
|
83
|
+
const buttonDesignScript: string = getDesignScript(
|
|
84
|
+
designFn,
|
|
85
|
+
getValidDesignProps,
|
|
86
|
+
designConfig
|
|
87
|
+
);
|
|
88
|
+
const buttonDesignComponent: ChildType = ButtonDesignComponent(designContent);
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
buttonDesignContainerClass: "personalized-design-container",
|
|
92
|
+
buttonDesignScript,
|
|
93
|
+
buttonDesignComponent,
|
|
94
|
+
};
|
|
92
95
|
}
|
|
@@ -1,72 +1,79 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
/** @jsx node */
|
|
3
|
-
import { LOGO_CLASS } from
|
|
4
|
-
import { node, Fragment, type ChildType } from
|
|
3
|
+
import { LOGO_CLASS } from "@paypal/sdk-logos/src";
|
|
4
|
+
import { node, Fragment, type ChildType } from "@krakenjs/jsx-pragmatic/src";
|
|
5
5
|
|
|
6
|
-
import { BUTTON_SIZE_STYLE } from
|
|
7
|
-
import { CLASS } from
|
|
6
|
+
import { BUTTON_SIZE_STYLE } from "../config";
|
|
7
|
+
import { CLASS } from "../../../constants";
|
|
8
8
|
|
|
9
|
-
import { type ContentOptions } from
|
|
9
|
+
import { type ContentOptions } from "./types";
|
|
10
10
|
|
|
11
11
|
type InlineLogoTextProps = {|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
paypalLabelContainerElement: Object,
|
|
13
|
+
designContainer: Object,
|
|
14
14
|
|};
|
|
15
15
|
|
|
16
16
|
export const INLINE_LOGO_TEXT_CONFIG = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
cssUtilClasses: {
|
|
18
|
+
PAYPAL_LABEL_CONTAINER: CLASS.BUTTON_LABEL,
|
|
19
|
+
PAYPAL_LOGO: LOGO_CLASS.LOGO,
|
|
20
|
+
DOM_READY: CLASS.DOM_READY,
|
|
21
|
+
},
|
|
22
|
+
min: BUTTON_SIZE_STYLE.large.minWidth,
|
|
23
|
+
max: BUTTON_SIZE_STYLE.huge.maxWidth,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export const getValidInlineLogoTextProps = function (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
export const getValidInlineLogoTextProps = function (
|
|
27
|
+
document: Object,
|
|
28
|
+
configuration: Object
|
|
29
|
+
): InlineLogoTextProps | null {
|
|
30
|
+
const { PAYPAL_LABEL_CONTAINER } = configuration.cssUtilClasses;
|
|
31
|
+
|
|
32
|
+
const designContainer =
|
|
33
|
+
(document && document.querySelector(".personalized-design-container")) ||
|
|
34
|
+
null;
|
|
35
|
+
if (!designContainer) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Return null if design does not apply to button size
|
|
40
|
+
const designContainerWidth = designContainer.offsetWidth;
|
|
41
|
+
if (
|
|
42
|
+
designContainerWidth < configuration.min ||
|
|
43
|
+
designContainerWidth > configuration.max
|
|
44
|
+
) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Return null if label element is not valid
|
|
49
|
+
const paypalLabelContainerElement =
|
|
50
|
+
(designContainer &&
|
|
51
|
+
designContainer.querySelector(`.${PAYPAL_LABEL_CONTAINER}`)) ||
|
|
52
|
+
null;
|
|
53
|
+
if (!paypalLabelContainerElement) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
paypalLabelContainerElement,
|
|
59
|
+
designContainer,
|
|
60
|
+
};
|
|
51
61
|
};
|
|
52
62
|
|
|
53
|
-
export const getInlineLabelTextDesign = function (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
export const getInlineLabelTextDesign = function (
|
|
64
|
+
designProps: InlineLogoTextProps,
|
|
65
|
+
configuration: Object
|
|
66
|
+
): void {
|
|
67
|
+
const {
|
|
68
|
+
min,
|
|
69
|
+
max,
|
|
70
|
+
cssUtilClasses: { DOM_READY, PAYPAL_LOGO },
|
|
71
|
+
} = configuration;
|
|
62
72
|
|
|
63
|
-
|
|
64
|
-
paypalLabelContainerElement,
|
|
65
|
-
designContainer
|
|
66
|
-
} = designProps;
|
|
73
|
+
const { paypalLabelContainerElement, designContainer } = designProps;
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
.${
|
|
75
|
+
const designCss = `
|
|
76
|
+
.${DOM_READY} .personalized-design-container img.${PAYPAL_LOGO}{
|
|
70
77
|
position: fixed;
|
|
71
78
|
left: 0%;
|
|
72
79
|
}
|
|
@@ -78,34 +85,45 @@ export const getInlineLabelTextDesign = function (designProps : InlineLogoTextPr
|
|
|
78
85
|
}
|
|
79
86
|
`;
|
|
80
87
|
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
if (paypalLabelContainerElement) {
|
|
89
|
+
const style = document.createElement("style");
|
|
90
|
+
paypalLabelContainerElement.appendChild(style);
|
|
91
|
+
style.appendChild(document.createTextNode(designCss));
|
|
92
|
+
|
|
93
|
+
window.addEventListener("resize", () => {
|
|
94
|
+
// Remove animation if size limit broken
|
|
95
|
+
if (
|
|
96
|
+
(designContainer.offsetWidth > max ||
|
|
97
|
+
designContainer.offsetWidth < min) &&
|
|
98
|
+
paypalLabelContainerElement.contains(style)
|
|
99
|
+
) {
|
|
100
|
+
paypalLabelContainerElement.removeChild(style);
|
|
101
|
+
} else if (
|
|
102
|
+
(designContainer.offsetWidth <= max ||
|
|
103
|
+
designContainer.offsetWidth >= min) &&
|
|
104
|
+
!paypalLabelContainerElement.contains(style)
|
|
105
|
+
) {
|
|
83
106
|
paypalLabelContainerElement.appendChild(style);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// Remove animation if size limit broken
|
|
88
|
-
if (
|
|
89
|
-
(designContainer.offsetWidth > max || designContainer.offsetWidth < min)
|
|
90
|
-
&& paypalLabelContainerElement.contains(style)
|
|
91
|
-
) {
|
|
92
|
-
paypalLabelContainerElement.removeChild(style);
|
|
93
|
-
} else if (
|
|
94
|
-
(designContainer.offsetWidth <= max || designContainer.offsetWidth >= min)
|
|
95
|
-
&& !paypalLabelContainerElement.contains(style)
|
|
96
|
-
) {
|
|
97
|
-
paypalLabelContainerElement.appendChild(style);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
101
110
|
};
|
|
102
111
|
|
|
103
|
-
export function InlineLogoTextComponent({
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
export function InlineLogoTextComponent({
|
|
113
|
+
designLabelText,
|
|
114
|
+
}: ContentOptions): ChildType {
|
|
115
|
+
return (
|
|
116
|
+
<Fragment>
|
|
117
|
+
<div
|
|
118
|
+
class={"personalized-label-container"}
|
|
119
|
+
data-design-experiment="104519"
|
|
120
|
+
>
|
|
121
|
+
{" "}
|
|
122
|
+
<span>{designLabelText}</span>
|
|
123
|
+
</div>
|
|
124
|
+
<style
|
|
125
|
+
innerHTML={`
|
|
126
|
+
.${CLASS.DOM_READY} .personalized-design-container img.${LOGO_CLASS.LOGO}{
|
|
109
127
|
position: relative;
|
|
110
128
|
}
|
|
111
129
|
|
|
@@ -122,7 +140,9 @@ export function InlineLogoTextComponent({ designLabelText } : ContentOptions) :
|
|
|
122
140
|
flex-direction: column;
|
|
123
141
|
justify-content: space-around;
|
|
124
142
|
}
|
|
125
|
-
`
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
`}
|
|
144
|
+
/>
|
|
145
|
+
;
|
|
146
|
+
</Fragment>
|
|
147
|
+
);
|
|
128
148
|
}
|