@paypal/checkout-components 5.0.204 → 5.0.205
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/CHANGELOG.md +10 -0
- package/dist/button.js +1 -1
- package/package.json +1 -1
- package/src/constants/class.js +3 -1
- package/src/funding/card/config.jsx +9 -1
- package/src/funding/common.jsx +3 -2
- package/src/types.js +7 -0
- package/src/ui/buttons/button.jsx +7 -4
- package/src/ui/buttons/buttons.jsx +2 -1
- package/src/ui/buttons/props.js +8 -5
- package/src/ui/buttons/style.jsx +2 -2
- package/src/ui/buttons/styles/base.js +5 -1
- package/src/ui/buttons/styles/button.js +2 -7
- package/src/ui/buttons/styles/custom.js +20 -0
- package/src/zoid/buttons/component.jsx +5 -1
package/package.json
CHANGED
package/src/constants/class.js
CHANGED
|
@@ -121,7 +121,15 @@ export function getCardConfig() : FundingSourceConfig {
|
|
|
121
121
|
);
|
|
122
122
|
},
|
|
123
123
|
|
|
124
|
-
Label: ({ logo, locale, content }) => {
|
|
124
|
+
Label: ({ logo, locale, content, custom }) => {
|
|
125
|
+
if (custom && custom.label) {
|
|
126
|
+
return (
|
|
127
|
+
<Fragment>
|
|
128
|
+
<Text>{ custom.label }</Text>
|
|
129
|
+
<Space />
|
|
130
|
+
</Fragment>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
125
133
|
const { lang } = locale;
|
|
126
134
|
const isRTL = isRTLLanguage(lang);
|
|
127
135
|
return (
|
package/src/funding/common.jsx
CHANGED
|
@@ -7,7 +7,7 @@ import type { FundingEligibilityType } from '@paypal/sdk-client/src';
|
|
|
7
7
|
import { PLATFORM, type LocaleType, COUNTRY, CARD, COMPONENTS, FUNDING, ENV } from '@paypal/sdk-constants/src';
|
|
8
8
|
import { LOGO_COLOR } from '@paypal/sdk-logos/src';
|
|
9
9
|
|
|
10
|
-
import type { ContentType, WalletInstrument, Experiment, Requires, Wallet } from '../types';
|
|
10
|
+
import type { ContentType, CustomStyle, WalletInstrument, Experiment, Requires, Wallet } from '../types';
|
|
11
11
|
import { BUTTON_COLOR, BUTTON_SHAPE, BUTTON_LAYOUT, DEFAULT, BUTTON_LABEL, BUTTON_FLOW, TEXT_COLOR } from '../constants';
|
|
12
12
|
import type { Personalization } from '../ui/buttons/props';
|
|
13
13
|
|
|
@@ -47,7 +47,8 @@ export type LabelOptions = {|
|
|
|
47
47
|
nonce : ?string,
|
|
48
48
|
tagline : ?boolean,
|
|
49
49
|
content : ?ContentType,
|
|
50
|
-
experiment? : Experiment
|
|
50
|
+
experiment? : Experiment,
|
|
51
|
+
custom? : ?CustomStyle
|
|
51
52
|
|};
|
|
52
53
|
|
|
53
54
|
export type DesignExperimentLabelOptions = {|
|
package/src/types.js
CHANGED
|
@@ -38,11 +38,12 @@ type IndividualButtonProps = {|
|
|
|
38
38
|
flow : $Values<typeof BUTTON_FLOW>,
|
|
39
39
|
vault : boolean,
|
|
40
40
|
merchantFundingSource : ?$Values<typeof FUNDING>,
|
|
41
|
-
instrument : ?WalletInstrument
|
|
41
|
+
instrument : ?WalletInstrument,
|
|
42
|
+
inline? : boolean
|
|
42
43
|
|};
|
|
43
44
|
|
|
44
45
|
export function Button({ fundingSource, style, multiple, locale, env, fundingEligibility, i, nonce, flow, vault,
|
|
45
|
-
userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument } : IndividualButtonProps) : ElementNode {
|
|
46
|
+
userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument, inline } : IndividualButtonProps) : ElementNode {
|
|
46
47
|
|
|
47
48
|
const fundingConfig = getFundingConfig()[fundingSource];
|
|
48
49
|
|
|
@@ -94,9 +95,9 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
97
|
|
|
97
|
-
const { layout, shape } = style;
|
|
98
|
+
const { custom, layout, shape } = style;
|
|
98
99
|
|
|
99
|
-
const labelText =
|
|
100
|
+
const labelText = typeof fundingConfig.labelText === 'function' ? fundingConfig.labelText({ content, fundingEligibility }) : (fundingConfig.labelText || fundingSource);
|
|
100
101
|
|
|
101
102
|
const logoNode = (
|
|
102
103
|
<Logo
|
|
@@ -129,6 +130,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
129
130
|
personalization={ personalization }
|
|
130
131
|
tagline={ tagline }
|
|
131
132
|
content={ content }
|
|
133
|
+
custom={ inline ? custom : null }
|
|
132
134
|
experiment={ experiment }
|
|
133
135
|
/>
|
|
134
136
|
);
|
|
@@ -221,6 +223,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
221
223
|
} }
|
|
222
224
|
class={ [
|
|
223
225
|
CLASS.BUTTON,
|
|
226
|
+
inline && fundingSource === FUNDING.CARD ? CLASS.CUSTOM : '',
|
|
224
227
|
`${ CLASS.NUMBER }-${ i }`,
|
|
225
228
|
`${ CLASS.LAYOUT }-${ layout }`,
|
|
226
229
|
`${ CLASS.SHAPE }-${ shape }`,
|
|
@@ -97,7 +97,7 @@ export function validateButtonProps(props : ButtonPropsInputs) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export function Buttons(props : ButtonsProps) : ElementNode {
|
|
100
|
-
const { onClick = noop } = props;
|
|
100
|
+
const { onClick = noop, inline } = props;
|
|
101
101
|
const { wallet, fundingSource, style, locale, remembered, env, fundingEligibility, platform, commit, vault,
|
|
102
102
|
nonce, components, onShippingChange, personalization, userIDToken, content, flow, experiment, applePaySupport, supportsPopups, supportedNativeBrowser } = normalizeButtonProps(props);
|
|
103
103
|
const { layout, shape, tagline } = style;
|
|
@@ -162,6 +162,7 @@ export function Buttons(props : ButtonsProps) : ElementNode {
|
|
|
162
162
|
flow={ flow }
|
|
163
163
|
vault={ vault }
|
|
164
164
|
instrument={ instruments[source] }
|
|
165
|
+
inline={ inline }
|
|
165
166
|
/>
|
|
166
167
|
))
|
|
167
168
|
}
|
package/src/ui/buttons/props.js
CHANGED
|
@@ -12,7 +12,7 @@ import { LOGO_COLOR } from '@paypal/sdk-logos/src';
|
|
|
12
12
|
import { SUPPORTED_FUNDING_SOURCES } from '@paypal/funding-components/src';
|
|
13
13
|
import type { ComponentFunctionType } from 'jsx-pragmatic/src';
|
|
14
14
|
|
|
15
|
-
import type { ContentType, Wallet, Experiment } from '../../types';
|
|
15
|
+
import type { ContentType, CustomStyle, Wallet, Experiment } from '../../types';
|
|
16
16
|
import { BUTTON_LABEL, BUTTON_COLOR, BUTTON_LAYOUT, BUTTON_SHAPE, BUTTON_SIZE, BUTTON_FLOW, MENU_PLACEMENT } from '../../constants';
|
|
17
17
|
import { getFundingConfig, isFundingEligible } from '../../funding';
|
|
18
18
|
|
|
@@ -130,7 +130,8 @@ export type ButtonStyle = {|
|
|
|
130
130
|
layout : $Values<typeof BUTTON_LAYOUT>,
|
|
131
131
|
menuPlacement : $Values<typeof MENU_PLACEMENT>,
|
|
132
132
|
period? : number,
|
|
133
|
-
height? : number
|
|
133
|
+
height? : number,
|
|
134
|
+
custom? : CustomStyle
|
|
134
135
|
|};
|
|
135
136
|
|
|
136
137
|
export type ButtonStyleInputs = {|
|
|
@@ -140,7 +141,8 @@ export type ButtonStyleInputs = {|
|
|
|
140
141
|
tagline? : boolean | void,
|
|
141
142
|
layout? : $Values<typeof BUTTON_LAYOUT> | void,
|
|
142
143
|
period? : number | void,
|
|
143
|
-
height? : number | void
|
|
144
|
+
height? : number | void,
|
|
145
|
+
custom? : CustomStyle
|
|
144
146
|
|};
|
|
145
147
|
|
|
146
148
|
type PersonalizationComponentProps = {|
|
|
@@ -397,7 +399,8 @@ export function normalizeButtonStyle(props : ?ButtonPropsInputs, style : ButtonS
|
|
|
397
399
|
tagline = (layout === BUTTON_LAYOUT.HORIZONTAL && !fundingSource),
|
|
398
400
|
height,
|
|
399
401
|
period,
|
|
400
|
-
menuPlacement = MENU_PLACEMENT.BELOW
|
|
402
|
+
menuPlacement = MENU_PLACEMENT.BELOW,
|
|
403
|
+
custom
|
|
401
404
|
} = style;
|
|
402
405
|
|
|
403
406
|
// $FlowFixMe
|
|
@@ -443,7 +446,7 @@ export function normalizeButtonStyle(props : ?ButtonPropsInputs, style : ButtonS
|
|
|
443
446
|
}
|
|
444
447
|
}
|
|
445
448
|
|
|
446
|
-
return { label, layout, color, shape, tagline, height, period, menuPlacement };
|
|
449
|
+
return { custom, label, layout, color, shape, tagline, height, period, menuPlacement };
|
|
447
450
|
}
|
|
448
451
|
|
|
449
452
|
const COUNTRIES = values(COUNTRY);
|
package/src/ui/buttons/style.jsx
CHANGED
|
@@ -15,8 +15,8 @@ type StyleProps = {|
|
|
|
15
15
|
|
|
16
16
|
export function Style({ style, nonce, fundingEligibility } : StyleProps) : ElementNode {
|
|
17
17
|
|
|
18
|
-
const { height } = style;
|
|
19
|
-
const css = componentStyle({ height, fundingEligibility });
|
|
18
|
+
const { custom, height } = style;
|
|
19
|
+
const css = componentStyle({ custom, height, fundingEligibility });
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<style nonce={ nonce } innerHTML={ css } />
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
import { type FundingEligibilityType } from '@paypal/sdk-constants/src';
|
|
4
4
|
|
|
5
|
+
import type { CustomStyle } from '../../../types';
|
|
6
|
+
|
|
5
7
|
import { pageStyle } from './page';
|
|
6
8
|
import { buttonStyle } from './button';
|
|
7
9
|
import { labelStyle } from './labels';
|
|
8
10
|
import { buttonResponsiveStyle } from './responsive';
|
|
9
11
|
import { buttonColorStyle } from './color';
|
|
12
|
+
import { customStyle } from './custom';
|
|
10
13
|
|
|
11
|
-
export function componentStyle({ height, fundingEligibility } : {| height? : ?number, fundingEligibility : FundingEligibilityType |}) : string {
|
|
14
|
+
export function componentStyle({ custom, height, fundingEligibility } : {| custom? : CustomStyle, height? : ?number, fundingEligibility : FundingEligibilityType |}) : string {
|
|
12
15
|
return `
|
|
13
16
|
${ pageStyle }
|
|
14
17
|
${ buttonStyle }
|
|
15
18
|
${ buttonColorStyle }
|
|
16
19
|
${ labelStyle }
|
|
17
20
|
${ buttonResponsiveStyle({ height, fundingEligibility }) }
|
|
21
|
+
${ customStyle({ custom }) }
|
|
18
22
|
`;
|
|
19
23
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
|
|
3
|
-
import { ENV
|
|
3
|
+
import { ENV } from '@paypal/sdk-constants/src';
|
|
4
4
|
import { LOGO_CLASS } from '@paypal/sdk-logos/src';
|
|
5
5
|
|
|
6
|
-
import { CLASS
|
|
6
|
+
import { CLASS } from '../../../constants';
|
|
7
7
|
|
|
8
8
|
const MIN_VAULT_BUTTON_WIDTH = 250;
|
|
9
9
|
|
|
@@ -126,11 +126,6 @@ export const buttonStyle = `
|
|
|
126
126
|
margin-top: 10px;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
.${ CLASS.BUTTON }[${ ATTRIBUTE.FUNDING_SOURCE }=${ FUNDING.VENMO }] .${ CLASS.BUTTON_LABEL } .${ CLASS.TEXT } {
|
|
130
|
-
font-size: 18px;
|
|
131
|
-
font-weight: 500;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
129
|
@media only screen and (max-width: ${ MIN_VAULT_BUTTON_WIDTH }px) {
|
|
135
130
|
.menu-button {
|
|
136
131
|
display: none;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
|
|
3
|
+
import type { CustomStyle } from '../../../types';
|
|
4
|
+
import { CLASS } from '../../../constants';
|
|
5
|
+
|
|
6
|
+
export const customStyle = ({ custom } : {| custom? : CustomStyle |}) : string => {
|
|
7
|
+
if (!custom) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { css } = custom || {};
|
|
12
|
+
|
|
13
|
+
let style = Object.keys(css).reduce((acc, key) => {
|
|
14
|
+
acc += `${ key }: ${ css[key] };`;
|
|
15
|
+
return acc;
|
|
16
|
+
}, '');
|
|
17
|
+
style = `.${ CLASS.BUTTON }.${ CLASS.CUSTOM } { ${ style } } `;
|
|
18
|
+
|
|
19
|
+
return style;
|
|
20
|
+
};
|
|
@@ -600,7 +600,11 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
|
|
|
600
600
|
inline: {
|
|
601
601
|
queryParam: true,
|
|
602
602
|
required: false,
|
|
603
|
-
type: 'boolean'
|
|
603
|
+
type: 'boolean',
|
|
604
|
+
value: ({ props }) => {
|
|
605
|
+
const { style: { custom }, fundingEligibility } = props;
|
|
606
|
+
return custom && fundingEligibility[FUNDING.CARD]?.eligible;
|
|
607
|
+
}
|
|
604
608
|
},
|
|
605
609
|
|
|
606
610
|
// allowBillingPayments prop is used by Honey Extension to render the one-click button
|