@paypal/checkout-components 5.0.378 → 5.0.379-alpha-84027e6.0
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 +1 -1
- package/src/constants/button.js +13 -0
- package/src/ui/buttons/config.js +116 -0
- package/src/ui/buttons/styles/base.js +2 -1
- package/src/ui/buttons/styles/button.js +54 -0
- package/src/ui/buttons/styles/color.js +4 -0
- package/src/ui/buttons/styles/responsive.js +290 -2
- package/src/ui/buttons/styles/styleUtils.js +52 -1
package/package.json
CHANGED
package/src/constants/button.js
CHANGED
|
@@ -44,6 +44,19 @@ export const BUTTON_SIZE = {
|
|
|
44
44
|
RESPONSIVE: ("responsive": "responsive"),
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
export const BUTTON_REDESIGN_SIZE = {
|
|
48
|
+
EXTRA_SMALL: ("extraSmall": "extraSmall"),
|
|
49
|
+
TINY: ("tiny": "tiny"),
|
|
50
|
+
SMALL: ("small": "small"),
|
|
51
|
+
MEDIUM_SMALL: ("mediumSmall": "mediumSmall"),
|
|
52
|
+
MEDIUM_BIG: ("mediumBig": "mediumBig"),
|
|
53
|
+
LARGE_SMALL: ("largeSmall": "largeSmall"),
|
|
54
|
+
LARGE_BIG: ("largeBig": "largeBig"),
|
|
55
|
+
XL_SMALL: ("xlSmall": "xlSmall"),
|
|
56
|
+
XL_BIG: ("xlBig": "xlBig"),
|
|
57
|
+
XXL: ("xxl": "xxl"),
|
|
58
|
+
};
|
|
59
|
+
|
|
47
60
|
export const BUTTON_DISABLE_MAX_HEIGHT_SIZE = {
|
|
48
61
|
TINY: ("tiny": "tiny"),
|
|
49
62
|
SMALL: ("small": "small"),
|
package/src/ui/buttons/config.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
BUTTON_SIZE,
|
|
6
6
|
BUTTON_DISABLE_MAX_HEIGHT_SIZE,
|
|
7
7
|
BUTTON_LAYOUT,
|
|
8
|
+
BUTTON_REDESIGN_SIZE,
|
|
8
9
|
} from "../../constants";
|
|
9
10
|
|
|
10
11
|
export const MINIMUM_SIZE: {|
|
|
@@ -45,6 +46,19 @@ type ButtonDisableMaxHeightStyleMap = {
|
|
|
45
46
|
|},
|
|
46
47
|
};
|
|
47
48
|
|
|
49
|
+
type ButtonRedesignStyleMap = {
|
|
50
|
+
[$Values<typeof BUTTON_REDESIGN_SIZE>]: {|
|
|
51
|
+
defaultHeight: number,
|
|
52
|
+
minHeight: number,
|
|
53
|
+
maxHeight: number,
|
|
54
|
+
minWidth: number,
|
|
55
|
+
maxWidth: number,
|
|
56
|
+
gap?: number,
|
|
57
|
+
fontSize?: number,
|
|
58
|
+
padding?: number,
|
|
59
|
+
|},
|
|
60
|
+
};
|
|
61
|
+
|
|
48
62
|
export const BUTTON_SIZE_STYLE: ButtonStyleMap = {
|
|
49
63
|
[BUTTON_SIZE.TINY]: {
|
|
50
64
|
defaultWidth: 75,
|
|
@@ -147,3 +161,105 @@ export const BUTTON_DISABLE_MAX_HEIGHT_STYLE: ButtonDisableMaxHeightStyleMap = {
|
|
|
147
161
|
maxHeight: 200,
|
|
148
162
|
},
|
|
149
163
|
};
|
|
164
|
+
|
|
165
|
+
export const BUTTON_REDESIGN_STYLE: ButtonRedesignStyleMap = {
|
|
166
|
+
[BUTTON_REDESIGN_SIZE.EXTRA_SMALL]: {
|
|
167
|
+
defaultHeight: 20,
|
|
168
|
+
minHeight: 20,
|
|
169
|
+
maxHeight: 30,
|
|
170
|
+
minWidth: 50,
|
|
171
|
+
maxWidth: 75,
|
|
172
|
+
gap: 3,
|
|
173
|
+
fontSize: 12,
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
[BUTTON_REDESIGN_SIZE.TINY]: {
|
|
177
|
+
defaultHeight: 25,
|
|
178
|
+
minHeight: 25,
|
|
179
|
+
maxHeight: 30,
|
|
180
|
+
minWidth: 75,
|
|
181
|
+
maxWidth: 200,
|
|
182
|
+
gap: 3,
|
|
183
|
+
fontSize: 12,
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
[BUTTON_REDESIGN_SIZE.SMALL]: {
|
|
187
|
+
defaultHeight: 30,
|
|
188
|
+
minHeight: 30,
|
|
189
|
+
maxHeight: 35,
|
|
190
|
+
minWidth: 200,
|
|
191
|
+
maxWidth: 250,
|
|
192
|
+
gap: 3,
|
|
193
|
+
fontSize: 14,
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
[BUTTON_REDESIGN_SIZE.MEDIUM_SMALL]: {
|
|
197
|
+
defaultHeight: 35,
|
|
198
|
+
minHeight: 35,
|
|
199
|
+
maxHeight: 40,
|
|
200
|
+
minWidth: 250,
|
|
201
|
+
maxWidth: 300,
|
|
202
|
+
gap: 4,
|
|
203
|
+
fontSize: 16,
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
[BUTTON_REDESIGN_SIZE.MEDIUM_BIG]: {
|
|
207
|
+
defaultHeight: 40,
|
|
208
|
+
minHeight: 40,
|
|
209
|
+
maxHeight: 44,
|
|
210
|
+
minWidth: 300,
|
|
211
|
+
maxWidth: 350,
|
|
212
|
+
gap: 4,
|
|
213
|
+
fontSize: 16,
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
[BUTTON_REDESIGN_SIZE.LARGE_SMALL]: {
|
|
217
|
+
defaultHeight: 45,
|
|
218
|
+
minHeight: 45,
|
|
219
|
+
maxHeight: 50,
|
|
220
|
+
minWidth: 350,
|
|
221
|
+
maxWidth: 425,
|
|
222
|
+
gap: 5,
|
|
223
|
+
fontSize: 18,
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
[BUTTON_REDESIGN_SIZE.LARGE_BIG]: {
|
|
227
|
+
defaultHeight: 50,
|
|
228
|
+
minHeight: 50,
|
|
229
|
+
maxHeight: 55,
|
|
230
|
+
minWidth: 425,
|
|
231
|
+
maxWidth: 500,
|
|
232
|
+
gap: 5,
|
|
233
|
+
fontSize: 20,
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
[BUTTON_REDESIGN_SIZE.XL_SMALL]: {
|
|
237
|
+
defaultHeight: 55,
|
|
238
|
+
minHeight: 55,
|
|
239
|
+
maxHeight: 60,
|
|
240
|
+
minWidth: 500,
|
|
241
|
+
maxWidth: 550,
|
|
242
|
+
gap: 6,
|
|
243
|
+
fontSize: 22,
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
[BUTTON_REDESIGN_SIZE.XL_BIG]: {
|
|
247
|
+
defaultHeight: 60,
|
|
248
|
+
minHeight: 60,
|
|
249
|
+
maxHeight: 65,
|
|
250
|
+
minWidth: 550,
|
|
251
|
+
maxWidth: 650,
|
|
252
|
+
gap: 7,
|
|
253
|
+
fontSize: 24,
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
[BUTTON_REDESIGN_SIZE.XXL]: {
|
|
257
|
+
defaultHeight: 65,
|
|
258
|
+
minHeight: 65,
|
|
259
|
+
maxHeight: 100,
|
|
260
|
+
minWidth: 650,
|
|
261
|
+
maxWidth: 750,
|
|
262
|
+
gap: 7,
|
|
263
|
+
fontSize: 26,
|
|
264
|
+
},
|
|
265
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { type FundingEligibilityType } from "@paypal/sdk-constants/src";
|
|
4
4
|
|
|
5
5
|
import { pageStyle } from "./page";
|
|
6
|
-
import { buttonStyle } from "./button";
|
|
6
|
+
import { buttonStyle, buttonRebrandStyle } from "./button";
|
|
7
7
|
import { labelStyle } from "./labels";
|
|
8
8
|
import { buttonResponsiveStyle } from "./responsive";
|
|
9
9
|
import { buttonColorStyle } from "./color";
|
|
@@ -26,6 +26,7 @@ export function componentStyle({
|
|
|
26
26
|
return `
|
|
27
27
|
${pageStyle}
|
|
28
28
|
${buttonStyle}
|
|
29
|
+
${shouldApplyRebrandedStyles ? buttonRebrandStyle : ""}
|
|
29
30
|
${buttonColorStyle}
|
|
30
31
|
${labelStyle}
|
|
31
32
|
${buttonResponsiveStyle({
|
|
@@ -151,3 +151,57 @@ export const buttonStyle = `
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
`;
|
|
154
|
+
|
|
155
|
+
export const buttonRebrandStyle = `
|
|
156
|
+
|
|
157
|
+
.${CLASS.BUTTON_REBRAND} {
|
|
158
|
+
border: 1px solid transparent;
|
|
159
|
+
border-radius: 0 3px 3px 0;
|
|
160
|
+
position: relative;
|
|
161
|
+
width: 100%;
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
border: none;
|
|
164
|
+
vertical-align: top;
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.${CLASS.BUTTON_REBRAND} > .${CLASS.BUTTON_LABEL} {
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
flex-wrap: nowrap;
|
|
174
|
+
height: 76%;
|
|
175
|
+
min-width: 0px;
|
|
176
|
+
position: relative;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.${LOGO_CLASS.LOGO} {
|
|
180
|
+
height: 100%;
|
|
181
|
+
padding: 0;
|
|
182
|
+
background: none;
|
|
183
|
+
border: none;
|
|
184
|
+
width: auto;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.${CLASS.TEXT} {
|
|
188
|
+
position: relative !important;
|
|
189
|
+
height: 100%;
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
192
|
+
line-height: 1.1;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.${CLASS.BUTTON_REBRAND} .${CLASS.BUTTON_LABEL} > .paypal-logo {
|
|
196
|
+
height: 100%;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.${CLASS.BUTTON_REBRAND} .${CLASS.TAGLINE} {
|
|
200
|
+
max-width: 100%;
|
|
201
|
+
font-size: initial;
|
|
202
|
+
font-weight: 400;
|
|
203
|
+
display: block;
|
|
204
|
+
text-align: center;
|
|
205
|
+
width: auto;
|
|
206
|
+
}
|
|
207
|
+
`;
|
|
@@ -17,12 +17,14 @@ import {
|
|
|
17
17
|
BUTTON_SIZE_STYLE,
|
|
18
18
|
BUTTON_RELATIVE_STYLE,
|
|
19
19
|
BUTTON_DISABLE_MAX_HEIGHT_STYLE,
|
|
20
|
+
BUTTON_REDESIGN_STYLE,
|
|
20
21
|
} from "../config";
|
|
21
22
|
import { isBorderRadiusNumber } from "../util";
|
|
22
23
|
|
|
23
24
|
import {
|
|
24
25
|
getResponsiveStyleVariables,
|
|
25
26
|
getDisableMaxHeightResponsiveStyleVariables,
|
|
27
|
+
getResponsiveRebrandedStyleVariables,
|
|
26
28
|
} from "./styleUtils";
|
|
27
29
|
|
|
28
30
|
const FIRST_BUTTON_PERC = 50;
|
|
@@ -77,10 +79,19 @@ const generateButtonSizeStyles = ({
|
|
|
77
79
|
CLASS.CONTAINER
|
|
78
80
|
} .${CLASS.BUTTON_ROW} .${CLASS.SPACE} {
|
|
79
81
|
font-size: ${max(perc(buttonHeight, 36), 10)}px;
|
|
80
|
-
margin-top: -${perc(max(perc(buttonHeight, 36), 10), 10)}px;
|
|
81
82
|
line-height: ${labelHeight}px;
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
[${ATTRIBUTE.FUNDING_SOURCE}=
|
|
86
|
+
${FUNDING.PAYPAL}] .${CLASS.TEXT},
|
|
87
|
+
[${ATTRIBUTE.FUNDING_SOURCE}=
|
|
88
|
+
${FUNDING.PAYLATER}] .${CLASS.TEXT},
|
|
89
|
+
[${ATTRIBUTE.FUNDING_SOURCE}=
|
|
90
|
+
${FUNDING.CREDIT}] .${CLASS.TEXT}
|
|
91
|
+
{
|
|
92
|
+
margin-top: -${perc(max(perc(buttonHeight, 36), 10), 10)}px;
|
|
93
|
+
}
|
|
94
|
+
|
|
84
95
|
.${CLASS.CONTAINER} .${CLASS.BUTTON_ROW} .${CLASS.TEXT} * {
|
|
85
96
|
margin-top: ${perc(max(perc(buttonHeight, 36), 10), 10)}px;
|
|
86
97
|
}
|
|
@@ -470,6 +481,225 @@ const generateDisableMaxHeightStyles = ({
|
|
|
470
481
|
.join("\n");
|
|
471
482
|
};
|
|
472
483
|
|
|
484
|
+
const generateRebrandedButtonSizeStyles = ({
|
|
485
|
+
height,
|
|
486
|
+
disableMaxHeight,
|
|
487
|
+
borderRadius,
|
|
488
|
+
}: {|
|
|
489
|
+
height?: ?number,
|
|
490
|
+
fundingEligibility?: FundingEligibilityType,
|
|
491
|
+
disableMaxWidth?: ?boolean,
|
|
492
|
+
disableMaxHeight?: ?boolean,
|
|
493
|
+
borderRadius?: ?number,
|
|
494
|
+
shouldApplyRebrandedStyles?: boolean,
|
|
495
|
+
|}): string => {
|
|
496
|
+
return Object.keys(BUTTON_REDESIGN_STYLE)
|
|
497
|
+
.map((redesign_size) => {
|
|
498
|
+
const {
|
|
499
|
+
buttonHeight,
|
|
500
|
+
pillBorderRadius,
|
|
501
|
+
gap,
|
|
502
|
+
fontSize,
|
|
503
|
+
minHeight,
|
|
504
|
+
maxHeight,
|
|
505
|
+
minWidth,
|
|
506
|
+
} = getResponsiveRebrandedStyleVariables({
|
|
507
|
+
height,
|
|
508
|
+
redesign_size,
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
const widthBasedStyles = `
|
|
512
|
+
@media only screen and (min-width: ${minWidth}px) {
|
|
513
|
+
.${CLASS.BUTTON_ROW} {
|
|
514
|
+
height: ${buttonHeight}px;
|
|
515
|
+
vertical-align: top;
|
|
516
|
+
min-height: ${height || minHeight}px;
|
|
517
|
+
max-height: ${height || maxHeight}px;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.${CLASS.BUTTON_REBRAND} > .${CLASS.BUTTON_LABEL} {
|
|
521
|
+
margin: 0px 4vw;
|
|
522
|
+
box-sizing: border-box;
|
|
523
|
+
height: ${buttonHeight * 0.76}px;
|
|
524
|
+
}
|
|
525
|
+
}`;
|
|
526
|
+
|
|
527
|
+
const disableMaxHeightStyles = `
|
|
528
|
+
@media only screen and (min-height: ${minHeight}px) and (max-height: ${maxHeight}px) {
|
|
529
|
+
.${CLASS.BUTTON_ROW} {
|
|
530
|
+
height: ${buttonHeight}px;
|
|
531
|
+
vertical-align: top;
|
|
532
|
+
min-height: ${height || minHeight}px;
|
|
533
|
+
max-height: ${height || maxHeight}px;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.${CLASS.BUTTON_REBRAND} > .${CLASS.BUTTON_LABEL} {
|
|
537
|
+
margin: 0px 4vw;
|
|
538
|
+
box-sizing: border-box;
|
|
539
|
+
height: ${buttonHeight * 0.76}px;
|
|
540
|
+
}
|
|
541
|
+
}`;
|
|
542
|
+
|
|
543
|
+
const heightBasedStyles = `
|
|
544
|
+
@media only screen and (min-height: ${minHeight}px) and (max-height: ${maxHeight}px) {
|
|
545
|
+
.${CLASS.BUTTON_REBRAND} > .${CLASS.BUTTON_LABEL} {
|
|
546
|
+
gap: ${gap}px;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
.${CLASS.CONTAINER} .${CLASS.BUTTON_ROW} .${CLASS.TEXT}, .${
|
|
550
|
+
CLASS.CONTAINER
|
|
551
|
+
} .${CLASS.BUTTON_ROW} .${CLASS.SPACE} {
|
|
552
|
+
font-size: ${fontSize}px;
|
|
553
|
+
position: relative;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.${CLASS.BUTTON_REBRAND} .${CLASS.TEXT} {
|
|
557
|
+
line-height: 1.2;
|
|
558
|
+
margin: 0;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.${CLASS.BUTTON_ROW}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.VERTICAL} {
|
|
562
|
+
margin-bottom: ${perc(
|
|
563
|
+
buttonHeight,
|
|
564
|
+
BUTTON_RELATIVE_STYLE.VERTICAL_MARGIN
|
|
565
|
+
)}px;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.${CLASS.BUTTON_ROW}.${CLASS.LAYOUT}-${
|
|
569
|
+
BUTTON_LAYOUT.VERTICAL
|
|
570
|
+
}:last-of-type {
|
|
571
|
+
margin-bottom: 0;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.${CLASS.BUTTON} {
|
|
575
|
+
display: inline-block;
|
|
576
|
+
text-align: center;
|
|
577
|
+
height: 100%;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.${CLASS.BUTTON} .${CLASS.SPINNER} {
|
|
581
|
+
height: ${perc(buttonHeight, 50)}px;
|
|
582
|
+
width: ${perc(buttonHeight, 50)}px;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.APPLEPAY}] .${
|
|
586
|
+
CLASS.BUTTON_LABEL
|
|
587
|
+
} {
|
|
588
|
+
height: ${perc(buttonHeight, 80) + 5}px;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.APPLEPAY}] .${
|
|
592
|
+
CLASS.BUTTON_LABEL
|
|
593
|
+
} .${CLASS.TEXT} {
|
|
594
|
+
line-height: ${perc(buttonHeight, 80) + 5}px;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.EPS}] .${
|
|
598
|
+
CLASS.BUTTON_LABEL
|
|
599
|
+
},
|
|
600
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.MYBANK}] .${
|
|
601
|
+
CLASS.BUTTON_LABEL
|
|
602
|
+
} {
|
|
603
|
+
height: ${perc(buttonHeight, 50) + 5}px;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.EPS}] .${
|
|
607
|
+
CLASS.BUTTON_LABEL
|
|
608
|
+
} .${CLASS.TEXT},
|
|
609
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.EPS}] .${
|
|
610
|
+
CLASS.BUTTON_LABEL
|
|
611
|
+
} .${CLASS.SPACE},
|
|
612
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.MYBANK}] .${
|
|
613
|
+
CLASS.BUTTON_LABEL
|
|
614
|
+
} .${CLASS.TEXT},
|
|
615
|
+
.${CLASS.BUTTON}[${ATTRIBUTE.FUNDING_SOURCE}=${FUNDING.MYBANK}] .${
|
|
616
|
+
CLASS.BUTTON_LABEL
|
|
617
|
+
} .${CLASS.SPACE} {
|
|
618
|
+
line-height: ${perc(buttonHeight, 50) + 5}px;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.${CLASS.BUTTON}.${CLASS.BORDER_RADIUS} {
|
|
622
|
+
${
|
|
623
|
+
borderRadius && isBorderRadiusNumber(borderRadius)
|
|
624
|
+
? `border-radius: ${borderRadius}px`
|
|
625
|
+
: ""
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.${CLASS.BUTTON}.${CLASS.SHAPE}-${BUTTON_SHAPE.SHARP} {
|
|
630
|
+
border-radius: 0px;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.${CLASS.BUTTON}.${CLASS.SHAPE}-${BUTTON_SHAPE.RECT} {
|
|
634
|
+
border-radius: 4px;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.${CLASS.BUTTON}.${CLASS.SHAPE}-${BUTTON_SHAPE.PILL} {
|
|
638
|
+
border-radius: ${pillBorderRadius}px;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.${CLASS.BUTTON_ROW}.${CLASS.BORDER_RADIUS} .menu-button {
|
|
642
|
+
${
|
|
643
|
+
borderRadius && isBorderRadiusNumber(borderRadius)
|
|
644
|
+
? `border-top-right-radius: ${borderRadius}px; border-bottom-right-radius: ${borderRadius}px`
|
|
645
|
+
: ""
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.${CLASS.BUTTON_ROW}.${CLASS.SHAPE}-${
|
|
650
|
+
BUTTON_SHAPE.SHARP
|
|
651
|
+
} .menu-button {
|
|
652
|
+
border-top-right-radius: 0px;
|
|
653
|
+
border-bottom-right-radius: 0px;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.${CLASS.BUTTON_ROW}.${CLASS.SHAPE}-${
|
|
657
|
+
BUTTON_SHAPE.RECT
|
|
658
|
+
} .menu-button {
|
|
659
|
+
border-top-right-radius: 4px;
|
|
660
|
+
border-bottom-right-radius: 4px;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
.${CLASS.BUTTON_ROW}.${CLASS.SHAPE}-${
|
|
664
|
+
BUTTON_SHAPE.PILL
|
|
665
|
+
} .menu-button {
|
|
666
|
+
border-top-right-radius: ${pillBorderRadius}px;
|
|
667
|
+
border-bottom-right-radius: ${pillBorderRadius}px;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
.${CLASS.TAGLINE} .${CLASS.TEXT} {
|
|
671
|
+
height: ${perc(buttonHeight, BUTTON_RELATIVE_STYLE.TAGLINE)}px;
|
|
672
|
+
line-height: ${perc(
|
|
673
|
+
buttonHeight,
|
|
674
|
+
BUTTON_RELATIVE_STYLE.TAGLINE
|
|
675
|
+
)}px;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.${CLASS.CARD} {
|
|
679
|
+
display: inline-block;
|
|
680
|
+
height: 100%;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
.${CLASS.BUTTON_ROW}.${CLASS.WALLET}.${CLASS.WALLET_MENU} .${
|
|
684
|
+
CLASS.BUTTON
|
|
685
|
+
} {
|
|
686
|
+
width: calc(100% - ${buttonHeight + 2}px);
|
|
687
|
+
border-top-right-radius: 0px;
|
|
688
|
+
border-bottom-right-radius: 0px;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
.menu-button {
|
|
692
|
+
height: ${buttonHeight}px;
|
|
693
|
+
width: ${buttonHeight}px;
|
|
694
|
+
}
|
|
695
|
+
}`;
|
|
696
|
+
return disableMaxHeight
|
|
697
|
+
? disableMaxHeightStyles + heightBasedStyles
|
|
698
|
+
: widthBasedStyles + heightBasedStyles;
|
|
699
|
+
})
|
|
700
|
+
.join("\n");
|
|
701
|
+
};
|
|
702
|
+
|
|
473
703
|
export function buttonResponsiveStyle({
|
|
474
704
|
height,
|
|
475
705
|
fundingEligibility,
|
|
@@ -494,6 +724,14 @@ export function buttonResponsiveStyle({
|
|
|
494
724
|
shouldApplyRebrandedStyles,
|
|
495
725
|
});
|
|
496
726
|
|
|
727
|
+
const buttonRedesignSizeStyles = generateRebrandedButtonSizeStyles({
|
|
728
|
+
height,
|
|
729
|
+
fundingEligibility,
|
|
730
|
+
disableMaxWidth,
|
|
731
|
+
disableMaxHeight,
|
|
732
|
+
borderRadius,
|
|
733
|
+
});
|
|
734
|
+
|
|
497
735
|
const disableMaxHeightStyles = disableMaxHeight
|
|
498
736
|
? generateDisableMaxHeightStyles({
|
|
499
737
|
fundingEligibility,
|
|
@@ -501,5 +739,55 @@ export function buttonResponsiveStyle({
|
|
|
501
739
|
})
|
|
502
740
|
: "";
|
|
503
741
|
|
|
504
|
-
|
|
742
|
+
const baseStyles = `
|
|
743
|
+
.${CLASS.BUTTON} {
|
|
744
|
+
display: inline-block;
|
|
745
|
+
text-align: center;
|
|
746
|
+
height: 100%;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// border radius
|
|
750
|
+
.${CLASS.BUTTON}.${CLASS.BORDER_RADIUS} {
|
|
751
|
+
${
|
|
752
|
+
borderRadius && isBorderRadiusNumber(borderRadius)
|
|
753
|
+
? `border-radius: ${borderRadius}px`
|
|
754
|
+
: ""
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
.${CLASS.BUTTON}.${CLASS.SHAPE}-${BUTTON_SHAPE.SHARP} {
|
|
758
|
+
border-radius: 0px;
|
|
759
|
+
}
|
|
760
|
+
.${CLASS.BUTTON}.${CLASS.SHAPE}-${BUTTON_SHAPE.RECT} {
|
|
761
|
+
border-radius: 4px;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// menu button - border radius
|
|
765
|
+
.${CLASS.BUTTON_ROW}.${CLASS.BORDER_RADIUS} .menu-button {
|
|
766
|
+
${
|
|
767
|
+
borderRadius && isBorderRadiusNumber(borderRadius)
|
|
768
|
+
? `border-top-right-radius: ${borderRadius}px; border-bottom-right-radius: ${borderRadius}px`
|
|
769
|
+
: ""
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
.${CLASS.BUTTON_ROW}.${CLASS.SHAPE}-${BUTTON_SHAPE.SHARP} .menu-button {
|
|
774
|
+
border-top-right-radius: 0px;
|
|
775
|
+
border-bottom-right-radius: 0px;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
.${CLASS.BUTTON_ROW}.${CLASS.SHAPE}-${BUTTON_SHAPE.RECT} .menu-button {
|
|
779
|
+
border-top-right-radius: 4px;
|
|
780
|
+
border-bottom-right-radius: 4px;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
.${CLASS.CARD} {
|
|
784
|
+
display: inline-block;
|
|
785
|
+
height: 100%;
|
|
786
|
+
}`;
|
|
787
|
+
|
|
788
|
+
const rebrandedStyles = shouldApplyRebrandedStyles
|
|
789
|
+
? buttonRedesignSizeStyles
|
|
790
|
+
: buttonSizeStyles + disableMaxHeightStyles;
|
|
791
|
+
|
|
792
|
+
return baseStyles + rebrandedStyles;
|
|
505
793
|
}
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
import { max, perc, roundUp } from "@krakenjs/belter/src";
|
|
4
4
|
import type { FundingEligibilityType } from "@paypal/sdk-constants/src";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
BUTTON_DISABLE_MAX_HEIGHT_STYLE,
|
|
8
|
+
BUTTON_SIZE_STYLE,
|
|
9
|
+
BUTTON_REDESIGN_STYLE,
|
|
10
|
+
} from "../config";
|
|
7
11
|
import {
|
|
8
12
|
BUTTON_SIZE,
|
|
9
13
|
BUTTON_DISABLE_MAX_HEIGHT_SIZE,
|
|
14
|
+
BUTTON_REDESIGN_SIZE,
|
|
10
15
|
} from "../../../constants";
|
|
11
16
|
|
|
12
17
|
const BUTTON_MIN_ASPECT_RATIO = 2.2;
|
|
@@ -156,6 +161,52 @@ export function getResponsiveStyleVariables({
|
|
|
156
161
|
return styleVariables;
|
|
157
162
|
}
|
|
158
163
|
|
|
164
|
+
export function getResponsiveRebrandedStyleVariables({
|
|
165
|
+
height,
|
|
166
|
+
redesign_size,
|
|
167
|
+
}: {|
|
|
168
|
+
height?: ?number,
|
|
169
|
+
redesign_size: $Values<typeof BUTTON_REDESIGN_SIZE>,
|
|
170
|
+
|}): Object {
|
|
171
|
+
const style = BUTTON_REDESIGN_STYLE[redesign_size];
|
|
172
|
+
const {
|
|
173
|
+
minHeight,
|
|
174
|
+
maxHeight,
|
|
175
|
+
defaultHeight,
|
|
176
|
+
minWidth,
|
|
177
|
+
maxWidth,
|
|
178
|
+
gap,
|
|
179
|
+
fontSize,
|
|
180
|
+
padding,
|
|
181
|
+
} = style;
|
|
182
|
+
|
|
183
|
+
const buttonHeight = height || defaultHeight;
|
|
184
|
+
const pillBorderRadius = Math.ceil(buttonHeight / 2);
|
|
185
|
+
|
|
186
|
+
const minDualWidth = Math.max(
|
|
187
|
+
Math.round(
|
|
188
|
+
buttonHeight * BUTTON_MIN_ASPECT_RATIO * (100 / WALLET_BUTTON_PERC)
|
|
189
|
+
),
|
|
190
|
+
MIN_SPLIT_BUTTON_WIDTH
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const styleVariables = {
|
|
194
|
+
style,
|
|
195
|
+
buttonHeight,
|
|
196
|
+
pillBorderRadius,
|
|
197
|
+
gap,
|
|
198
|
+
minHeight,
|
|
199
|
+
maxHeight,
|
|
200
|
+
minWidth,
|
|
201
|
+
minDualWidth,
|
|
202
|
+
maxWidth,
|
|
203
|
+
fontSize,
|
|
204
|
+
padding,
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
return styleVariables;
|
|
208
|
+
}
|
|
209
|
+
|
|
159
210
|
export function getDisableMaxHeightResponsiveStyleVariables({
|
|
160
211
|
fundingEligibility,
|
|
161
212
|
shouldApplyRebrandedStyles,
|