@paypal/checkout-components 5.0.189 → 5.0.190

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.189",
3
+ "version": "5.0.190",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -64,8 +64,8 @@
64
64
  "bundlemon": "^1.1.0",
65
65
  "conventional-changelog-cli": "^2.0.34",
66
66
  "flow-bin": "0.155.0",
67
- "fs-extra": "^9.0.1",
68
- "grumbler-scripts": "^3.0.70",
67
+ "fs-extra": "^10.0.0",
68
+ "grumbler-scripts": "^5.0.1",
69
69
  "imagemagick": "^0.1.3",
70
70
  "imgur": "^0.3.1",
71
71
  "karma": "^5.2.3",
@@ -49,7 +49,7 @@ export type LabelOptions = {|
49
49
  content : ?ContentType
50
50
  |};
51
51
 
52
- export type AnimatedExperimentLabelOptions = {|
52
+ export type DesignExperimentLabelOptions = {|
53
53
  i : number,
54
54
  logo : ChildType,
55
55
  label : ?$Values<typeof BUTTON_LABEL>,
@@ -66,7 +66,7 @@ export type AnimatedExperimentLabelOptions = {|
66
66
  nonce : ?string,
67
67
  tagline : ?boolean,
68
68
  content : ?ContentType,
69
- buttonAnimationComponent : ?ChildType
69
+ buttonDesignComponent : ?ChildType
70
70
  |};
71
71
 
72
72
  export type WalletLabelOptions = {|
@@ -29,6 +29,7 @@ import { getOxxoConfig } from './oxxo';
29
29
  import { getBoletoConfig } from './boleto';
30
30
  import { getMaximaConfig } from './maxima';
31
31
  import { getMercadopagoConfig } from './mercadopago';
32
+ import { getMultiblancoConfig } from './multiblanco';
32
33
 
33
34
  export function getFundingConfig() : { [$Values<typeof FUNDING>] : ?FundingSourceConfig } {
34
35
  return inlineMemoize(getFundingConfig, () => {
@@ -57,7 +58,8 @@ export function getFundingConfig() : { [$Values<typeof FUNDING>] : ?FundingSourc
57
58
  [ FUNDING.OXXO ]: (!__TREE_SHAKE__ || (typeof __FUNDING_ELIGIBILITY__.oxxo !== 'undefined' && __FUNDING_ELIGIBILITY__.oxxo.eligible)) ? getOxxoConfig() : null,
58
59
  [ FUNDING.BOLETO ]: (!__TREE_SHAKE__ || (typeof __FUNDING_ELIGIBILITY__.boleto !== 'undefined' && __FUNDING_ELIGIBILITY__.boleto.eligible)) ? getBoletoConfig() : null,
59
60
  [ FUNDING.MAXIMA ]: (!__TREE_SHAKE__ || (typeof __FUNDING_ELIGIBILITY__.maxima !== 'undefined' && __FUNDING_ELIGIBILITY__.maxima.eligible)) ? getMaximaConfig() : null,
60
- [ FUNDING.MERCADOPAGO ]: (!__TREE_SHAKE__ || (typeof __FUNDING_ELIGIBILITY__.mercadopago !== 'undefined' && __FUNDING_ELIGIBILITY__.mercadopago.eligible)) ? getMercadopagoConfig() : null
61
+ [ FUNDING.MERCADOPAGO ]: (!__TREE_SHAKE__ || (typeof __FUNDING_ELIGIBILITY__.mercadopago !== 'undefined' && __FUNDING_ELIGIBILITY__.mercadopago.eligible)) ? getMercadopagoConfig() : null,
62
+ [ FUNDING.MULTIBLANCO ]: (!__TREE_SHAKE__ || (typeof __FUNDING_ELIGIBILITY__.multiblanco !== 'undefined' && __FUNDING_ELIGIBILITY__.multiblanco.eligible)) ? getMultiblancoConfig() : null
61
63
  };
62
64
  });
63
65
  }
@@ -0,0 +1,21 @@
1
+ /* @flow */
2
+ /** @jsx node */
3
+
4
+ import { MultiblancoLogo } from '@paypal/sdk-logos/src';
5
+
6
+ import { BUTTON_LAYOUT } from '../../constants';
7
+ import { DEFAULT_FUNDING_CONFIG, type FundingSourceConfig } from '../common';
8
+
9
+ export function getMultiblancoConfig() : FundingSourceConfig {
10
+ return {
11
+ ...DEFAULT_FUNDING_CONFIG,
12
+
13
+ shippingChange: false,
14
+
15
+ layouts: [
16
+ BUTTON_LAYOUT.VERTICAL
17
+ ],
18
+
19
+ Logo: ({ logoColor, optional }) => MultiblancoLogo({ logoColor, optional })
20
+ };
21
+ }
@@ -0,0 +1,4 @@
1
+ /* @flow */
2
+
3
+ export * from './config';
4
+
@@ -8,7 +8,7 @@ import { FUNDING, WALLET_INSTRUMENT } from '@paypal/sdk-constants/src';
8
8
  import {
9
9
  type LogoOptions,
10
10
  type LabelOptions,
11
- type AnimatedExperimentLabelOptions,
11
+ type DesignExperimentLabelOptions,
12
12
  type WalletLabelOptions,
13
13
  type TagOptions,
14
14
  BasicLabel
@@ -59,7 +59,7 @@ function getButtonPersonalizationStyle(opts : LabelOptions) : ?ChildType {
59
59
  if (__TEST__) {
60
60
  return null;
61
61
  }
62
-
62
+
63
63
  const { tagline } = opts;
64
64
 
65
65
  const personalizationText = !tagline && getPersonalizationText(opts);
@@ -126,7 +126,7 @@ function ButtonPersonalization(opts : LabelOptions) : ?ChildType {
126
126
  }
127
127
 
128
128
  const { nonce, tagline, label } = opts;
129
-
129
+
130
130
  if (tagline || !label) {
131
131
  return;
132
132
  }
@@ -149,7 +149,7 @@ function ButtonPersonalization(opts : LabelOptions) : ?ChildType {
149
149
  getButtonPersonalizationStyle(opts)
150
150
  }
151
151
  </Fragment>
152
-
152
+
153
153
  );
154
154
  }
155
155
 
@@ -163,17 +163,14 @@ export function Label(opts : LabelOptions) : ChildType {
163
163
  );
164
164
  }
165
165
 
166
- export function AnimatedExperimentLabel(opts : AnimatedExperimentLabelOptions) : ChildType {
167
- const { buttonAnimationComponent } = opts;
168
- delete opts.buttonAnimationComponent;
169
- // $FlowFixMe
170
- const basicLabel = (<BasicLabel { ...opts } />);
171
- // $FlowFixMe
172
- const buttonPersonalization = (<ButtonPersonalization { ...opts } />);
166
+ export function DesignExperimentLabel(opts : DesignExperimentLabelOptions) : ChildType {
167
+ const { buttonDesignComponent, ...updatedOpts } = opts;
168
+ const basicLabel = (<BasicLabel { ...updatedOpts } />);
169
+ const buttonPersonalization = (<ButtonPersonalization { ...updatedOpts } />);
173
170
  return (
174
171
  <Fragment>
175
172
  { basicLabel }
176
- { buttonAnimationComponent }
173
+ { buttonDesignComponent }
177
174
  { buttonPersonalization }
178
175
  </Fragment>
179
176
  );
@@ -277,12 +274,12 @@ export function WalletLabel(opts : WalletLabelOptions) : ?ChildType {
277
274
  logo = <CreditMark />;
278
275
 
279
276
  label = content && content.credit;
280
-
277
+
281
278
  } else if (instrument.type === WALLET_INSTRUMENT.BALANCE) {
282
279
  logo = <PayPalMark />;
283
280
 
284
281
  label = content && content.balance;
285
-
282
+
286
283
  } else if (instrument.label) {
287
284
  label = instrument.label;
288
285
  }
@@ -342,7 +339,7 @@ export function Tag({ multiple, locale: { lang } } : TagOptions) : ?ChildType {
342
339
  if (__WEB__) {
343
340
  return null;
344
341
  }
345
-
342
+
346
343
  const { DualTag, SaferTag } = componentContent[lang];
347
344
 
348
345
  return (multiple && DualTag)
package/src/lib/errors.js CHANGED
@@ -3,11 +3,11 @@
3
3
  import { ERROR_CODE } from '@paypal/sdk-constants/src';
4
4
 
5
5
  export class ValidationError extends Error {
6
- code : string;
6
+ code : string;
7
7
 
8
- constructor(message : string) {
9
- super(message);
10
- this.name = 'ValidationError';
11
- this.code = ERROR_CODE.VALIDATION_ERROR;
12
- }
8
+ constructor(message : string) {
9
+ super(message);
10
+ this.name = 'ValidationError';
11
+ this.code = ERROR_CODE.VALIDATION_ERROR;
12
+ }
13
13
  }
@@ -32,16 +32,16 @@ function Mark({ fundingSource, fundingEligibility, experiment, env } : MarkOptio
32
32
  <div class='paypal-mark'>
33
33
  { marksDefined && MarkLogo
34
34
  ? <MarkLogo
35
- fundingEligibility={ fundingEligibility }
36
- locale={ getLocale() }
37
- experiment={ experiment }
38
- env={ env }
35
+ fundingEligibility={ fundingEligibility }
36
+ locale={ getLocale() }
37
+ experiment={ experiment }
38
+ env={ env }
39
39
  />
40
40
  : <Logo
41
- fundingEligibility={ fundingEligibility }
42
- locale={ getLocale() }
43
- experiment={ experiment }
44
- env={ env }
41
+ fundingEligibility={ fundingEligibility }
42
+ locale={ getLocale() }
43
+ experiment={ experiment }
44
+ env={ env }
45
45
  /> }
46
46
 
47
47
  </div>
@@ -10,9 +10,9 @@ import { noop, preventClickFocus, isBrowser, isElement } from 'belter/src';
10
10
  import type { ContentType, Wallet, Experiment, WalletInstrument } from '../../types';
11
11
  import { ATTRIBUTE, CLASS, BUTTON_COLOR, BUTTON_NUMBER, TEXT_COLOR, BUTTON_FLOW } from '../../constants';
12
12
  import { getFundingConfig } from '../../funding';
13
- import { AnimatedExperimentLabel } from '../../funding/paypal/template';
13
+ import { DesignExperimentLabel } from '../../funding/paypal/template';
14
14
 
15
- import { getButtonAnimation } from './button-animations';
15
+ import { getButtonDesign } from './buttonDesigns';
16
16
  import type { ButtonStyle, Personalization, OnShippingChange } from './props';
17
17
  import { Spinner } from './spinner';
18
18
  import { MenuButton } from './menu-button';
@@ -133,18 +133,18 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
133
133
  );
134
134
 
135
135
  // Only apply animation to the paypal button
136
- const buttonAnimation = fundingSource === FUNDING.PAYPAL
137
- ? getButtonAnimation(personalization)
136
+ const buttonDesign = fundingSource === FUNDING.PAYPAL
137
+ ? getButtonDesign(personalization)
138
138
  : {};
139
139
 
140
140
  const {
141
- buttonAnimationContainerClass = '',
142
- buttonAnimationComponent = null
143
- } = buttonAnimation;
141
+ buttonDesignContainerClass = '',
142
+ buttonDesignComponent = null
143
+ } = buttonDesign;
144
144
 
145
- if (buttonAnimationComponent) {
145
+ if (buttonDesignComponent) {
146
146
  labelNode = (
147
- <AnimatedExperimentLabel
147
+ <DesignExperimentLabel
148
148
  i={ i }
149
149
  logo={ logoNode }
150
150
  label={ label }
@@ -160,7 +160,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
160
160
  personalization={ personalization }
161
161
  tagline={ tagline }
162
162
  content={ content }
163
- buttonAnimationComponent={ buttonAnimationComponent }
163
+ buttonDesignComponent={ buttonDesignComponent }
164
164
  />
165
165
  );
166
166
  }
@@ -206,7 +206,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
206
206
  `${ LOGO_CLASS.LOGO_COLOR }-${ logoColor }`,
207
207
  `${ isWallet ? CLASS.WALLET : '' }`,
208
208
  `${ shouldShowWalletMenu ? CLASS.WALLET_MENU : '' }`,
209
- `${ buttonAnimationContainerClass }`
209
+ `${ buttonDesignContainerClass }`
210
210
  ].join(' ') }
211
211
  >
212
212
  <div
@@ -0,0 +1,9 @@
1
+ /* @flow */
2
+ /** @jsx node */
3
+ import { node, type ChildType } from 'jsx-pragmatic/src';
4
+
5
+ export function ControlDesignComponent(experimentId : string) : ChildType {
6
+ return (
7
+ <div data-design-experiment={ experimentId } />
8
+ );
9
+ }
@@ -0,0 +1,174 @@
1
+ /* @flow */
2
+ /** @jsx node */
3
+ import { LOGO_CLASS } from '@paypal/sdk-logos/src';
4
+ import { node, Fragment, type ChildType } from 'jsx-pragmatic/src';
5
+
6
+ import { CLASS } from '../../../constants';
7
+ import { BUTTON_SIZE_STYLE } from '../config';
8
+
9
+ import { type ContentOptions } from './types';
10
+
11
+ type DivideLogoAnimationProps = {|
12
+ paypalLabelContainerElement : Object,
13
+ paypalLogoStartingLeftPosition : string,
14
+ designContainer : Object
15
+ |};
16
+
17
+
18
+ export const DIVIDE_LOGO_CONFIG = {
19
+ min: BUTTON_SIZE_STYLE.large.minWidth,
20
+ max: BUTTON_SIZE_STYLE.huge.maxWidth,
21
+ cssUtilClasses: {
22
+ DOM_READY: CLASS.DOM_READY,
23
+ PAYPAL_LOGO: LOGO_CLASS.LOGO,
24
+ PAYPAL_BUTTON_LABEL: CLASS.BUTTON_LABEL
25
+ }
26
+ };
27
+
28
+ // Returns props necessary to render the animation as long as they are valid
29
+ export const getDivideLogoProps = function (document : Object, configuration : Object) : DivideLogoAnimationProps | null {
30
+ const { PAYPAL_BUTTON_LABEL, PAYPAL_LOGO } = configuration.cssUtilClasses;
31
+
32
+ const designContainer = (document && document.querySelector('.personalized-design-container')) || null;
33
+ if (!designContainer) {
34
+ return null;
35
+ }
36
+
37
+ // return null if animation should not be played for the button size
38
+ const designContainerWidth = designContainer.offsetWidth;
39
+ if (designContainerWidth < configuration.min || designContainerWidth > configuration.max) {
40
+ return null;
41
+ }
42
+
43
+ // get the label container that animation will be applied to
44
+ const paypalLabelContainerElement = designContainer.querySelector(`.${ PAYPAL_BUTTON_LABEL }`) || null;
45
+ if (!paypalLabelContainerElement) {
46
+ return null;
47
+ }
48
+
49
+ // get starting position for element so it doesn't flicker when animation begins
50
+ const paypalLogoElement = (paypalLabelContainerElement && paypalLabelContainerElement.querySelector(`.${ PAYPAL_LOGO }`)) || null;
51
+ if (!paypalLogoElement) {
52
+ return null;
53
+ }
54
+ const paypalLogoStartingLeftPosition = `${ (paypalLogoElement.offsetLeft / paypalLabelContainerElement.offsetWidth) * 100 }%`;
55
+
56
+ return {
57
+ paypalLabelContainerElement,
58
+ paypalLogoStartingLeftPosition,
59
+ designContainer
60
+ };
61
+ };
62
+
63
+ export function getDivideLogoAnimation(designProps : DivideLogoAnimationProps, configuration : Object) : void {
64
+ const {
65
+ min,
66
+ max,
67
+ cssUtilClasses: {
68
+ DOM_READY,
69
+ PAYPAL_LOGO
70
+ }
71
+ } = configuration;
72
+
73
+ const {
74
+ paypalLabelContainerElement,
75
+ paypalLogoStartingLeftPosition,
76
+ designContainer
77
+ } = designProps;
78
+
79
+ const designCss = `
80
+ .${ DOM_READY } .personalized-design-container img.${ PAYPAL_LOGO }{
81
+ animation: 3s divide-logo-animation-left-side 2s infinite alternate;
82
+ }
83
+
84
+ .personalized-design-container .personalized-label-container {
85
+ animation: 3s divide-logo-animation-right-side 2s infinite alternate;
86
+ }
87
+
88
+ @keyframes divide-logo-animation-left-side {
89
+ 0% {
90
+ position: fixed;
91
+ left: ${ paypalLogoStartingLeftPosition };
92
+ }
93
+ 33% {
94
+ position: fixed;
95
+ left: ${ paypalLogoStartingLeftPosition };
96
+ }
97
+ 66% {
98
+ position: fixed;
99
+ left: 0%;
100
+ }
101
+ 100% {
102
+ position: fixed;
103
+ left: 0%;
104
+ }
105
+ }
106
+
107
+ @keyframes divide-logo-animation-right-side {
108
+ 0%{
109
+ opacity: 0;
110
+ position: fixed;
111
+ right: 45%;
112
+ }
113
+ 33%{
114
+ opacity: 0;
115
+ position: fixed;
116
+ right: 45%;
117
+ }
118
+ 66% {
119
+ opacity: 1;
120
+ position: fixed;
121
+ right: 0%;
122
+ }
123
+ 100% {
124
+ opacity: 1;
125
+ position: fixed;
126
+ right: 0%;
127
+ }
128
+ }
129
+ `;
130
+
131
+ if (paypalLabelContainerElement) {
132
+ const style = document.createElement('style');
133
+ paypalLabelContainerElement.appendChild(style);
134
+ style.appendChild(document.createTextNode(designCss));
135
+
136
+
137
+ window.addEventListener('resize', () => {
138
+ // Remove animation if size limit broken
139
+ if (
140
+ (designContainer.offsetWidth > max || designContainer.offsetWidth < min)
141
+ && paypalLabelContainerElement.contains(style)
142
+ ) {
143
+ paypalLabelContainerElement.removeChild(style);
144
+ }
145
+ });
146
+ }
147
+ }
148
+
149
+ export function DivideLogoTextComponent({ designLabelText } : ContentOptions) : ChildType {
150
+ return (
151
+ <Fragment>
152
+ <div class={ 'personalized-label-container' } data-design-experiment='104519'> <span>{designLabelText}</span></div>
153
+ <style innerHTML={ `
154
+ .${ CLASS.DOM_READY } .personalized-design-container img.${ LOGO_CLASS.LOGO }{
155
+ position: relative;
156
+ }
157
+
158
+ .personalized-design-container .personalized-label-container {
159
+ position: absolute;
160
+ opacity: 0;
161
+ color: #142C8E;
162
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
163
+ font-size: 14px;
164
+ }
165
+
166
+ .personalized-design-container .personalized-label-container span {
167
+ display: flex;
168
+ flex-direction: column;
169
+ justify-content: space-around;
170
+ }
171
+ ` } />;
172
+ </Fragment>
173
+ );
174
+ }
@@ -0,0 +1,92 @@
1
+ /* @flow */
2
+ import { type ChildType } from 'jsx-pragmatic/src';
3
+
4
+ import { type Personalization } from '../props';
5
+
6
+ import { getDesignScript } from './script';
7
+ import { type ButtonDesignOutputParams } from './types';
8
+ import { ControlDesignComponent } from './control';
9
+ import {
10
+ getDivideLogoAnimation,
11
+ getDivideLogoProps,
12
+ DIVIDE_LOGO_CONFIG,
13
+ DivideLogoTextComponent
14
+ } from './divideLogoAnimation';
15
+ import {
16
+ getInlineLabelTextDesign,
17
+ getValidInlineLogoTextProps,
18
+ INLINE_LOGO_TEXT_CONFIG,
19
+ InlineLogoTextComponent
20
+ } from './inlineLogoTextDesign';
21
+
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
+ };
36
+
37
+ const CONTROL_MAP : Object = {
38
+ 'large-button-design-control': '104519',
39
+ 'small-button-design-control': '104530'
40
+ };
41
+
42
+ export function getButtonDesign(personalization : ?Personalization) : ButtonDesignOutputParams | Object {
43
+
44
+ // check valid personalization
45
+ if (
46
+ __WEB__
47
+ || !personalization
48
+ || typeof personalization !== 'object'
49
+ || !personalization.buttonDesign
50
+ ) {
51
+ return {};
52
+ }
53
+
54
+ const {
55
+ buttonDesign: {
56
+ id: designId = '',
57
+ text: designLabelText = 'Safe and easy way to pay'
58
+ } = {}
59
+ } = personalization;
60
+
61
+ // Return fragment with data-design-experiment tag for logging
62
+ if (CONTROL_MAP[designId]) {
63
+ const buttonDesignComponent : ChildType = ControlDesignComponent(CONTROL_MAP[designId]);
64
+
65
+ return {
66
+ buttonDesignContainerClass: '',
67
+ buttonDesignScript: '',
68
+ buttonDesignComponent
69
+ };
70
+ }
71
+
72
+ if (!DESIGN_MAP[designId]) {
73
+ return {};
74
+ }
75
+
76
+ const {
77
+ designFn,
78
+ getValidDesignProps,
79
+ designConfig,
80
+ ButtonDesignComponent
81
+ } = DESIGN_MAP[designId];
82
+
83
+ const designContent = { designLabelText };
84
+ const buttonDesignScript : string = getDesignScript(designFn, getValidDesignProps, designConfig);
85
+ const buttonDesignComponent : ChildType = ButtonDesignComponent(designContent);
86
+
87
+ return {
88
+ buttonDesignContainerClass: 'personalized-design-container',
89
+ buttonDesignScript,
90
+ buttonDesignComponent
91
+ };
92
+ }
@@ -0,0 +1,123 @@
1
+ /* @flow */
2
+ /** @jsx node */
3
+ import { LOGO_CLASS } from '@paypal/sdk-logos/src';
4
+ import { node, Fragment, type ChildType } from 'jsx-pragmatic/src';
5
+
6
+ import { BUTTON_SIZE_STYLE } from '../config';
7
+ import { CLASS } from '../../../constants';
8
+
9
+ import { type ContentOptions } from './types';
10
+
11
+ type InlineLogoTextProps = {|
12
+ paypalLabelContainerElement : Object,
13
+ designContainer : Object
14
+ |};
15
+
16
+ export const INLINE_LOGO_TEXT_CONFIG = {
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
+ };
25
+
26
+ export const getValidInlineLogoTextProps = function (document : Object, configuration : Object) : InlineLogoTextProps | null {
27
+ const { PAYPAL_LABEL_CONTAINER } = configuration.cssUtilClasses;
28
+
29
+
30
+ const designContainer = (document && document.querySelector('.personalized-design-container')) || null;
31
+ if (!designContainer) {
32
+ return null;
33
+ }
34
+
35
+ // Return null if design does not apply to button size
36
+ const designContainerWidth = designContainer.offsetWidth;
37
+ if (designContainerWidth < configuration.min || designContainerWidth > configuration.max) {
38
+ return null;
39
+ }
40
+
41
+ // Return null if label element is not valid
42
+ const paypalLabelContainerElement = (designContainer && designContainer.querySelector(`.${ PAYPAL_LABEL_CONTAINER }`)) || null;
43
+ if (!paypalLabelContainerElement) {
44
+ return null;
45
+ }
46
+
47
+ return {
48
+ paypalLabelContainerElement,
49
+ designContainer
50
+ };
51
+ };
52
+
53
+ export const getInlineLabelTextDesign = function (designProps : InlineLogoTextProps, configuration : Object) : void {
54
+ const {
55
+ min,
56
+ max,
57
+ cssUtilClasses: {
58
+ DOM_READY,
59
+ PAYPAL_LOGO
60
+ }
61
+ } = configuration;
62
+
63
+ const {
64
+ paypalLabelContainerElement,
65
+ designContainer
66
+ } = designProps;
67
+
68
+ const designCss = `
69
+ .${ DOM_READY } .personalized-design-container img.${ PAYPAL_LOGO }{
70
+ position: fixed;
71
+ left: 0%;
72
+ }
73
+
74
+ .personalized-design-container .personalized-label-container {
75
+ position: fixed;
76
+ opacity: 1;
77
+ right:0%;
78
+ }
79
+ `;
80
+
81
+ if (paypalLabelContainerElement) {
82
+ const style = document.createElement('style');
83
+ paypalLabelContainerElement.appendChild(style);
84
+ style.appendChild(document.createTextNode(designCss));
85
+
86
+ window.addEventListener('resize', () => {
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
+ }
94
+ });
95
+ }
96
+ };
97
+
98
+ export function InlineLogoTextComponent({ designLabelText } : ContentOptions) : ChildType {
99
+ return (
100
+ <Fragment>
101
+ <div class={ 'personalized-label-container' } data-design-experiment="104519"> <span>{designLabelText}</span></div>
102
+ <style innerHTML={ `
103
+ .${ CLASS.DOM_READY } .personalized-design-container img.${ LOGO_CLASS.LOGO }{
104
+ position: relative;
105
+ }
106
+
107
+ .personalized-design-container .personalized-label-container {
108
+ position: absolute;
109
+ opacity: 0;
110
+ color: #142C8E;
111
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
112
+ font-size: 14px;
113
+ }
114
+
115
+ .personalized-design-container .personalized-label-container span {
116
+ display: flex;
117
+ flex-direction: column;
118
+ justify-content: space-around;
119
+ }
120
+ ` } />;
121
+ </Fragment>
122
+ );
123
+ }