1
1
/* @flow */
2
2
3
- import { max , perc , roundUp } from "@krakenjs/belter/src" ;
3
+ import { max , perc } from "@krakenjs/belter/src" ;
4
4
import {
5
5
FUNDING ,
6
6
type FundingEligibilityType ,
@@ -12,7 +12,6 @@ import {
12
12
BUTTON_NUMBER ,
13
13
CLASS ,
14
14
ATTRIBUTE ,
15
- BUTTON_SIZE ,
16
15
} from "../../../constants" ;
17
16
import {
18
17
BUTTON_SIZE_STYLE ,
@@ -29,25 +28,22 @@ import {
29
28
const FIRST_BUTTON_PERC = 50 ;
30
29
const WALLET_BUTTON_PERC = 60 ;
31
30
32
- export function buttonResponsiveStyle ( {
31
+ const generateButtonSizeStyles = ( {
33
32
height,
34
33
fundingEligibility,
35
34
disableMaxWidth,
36
35
disableMaxHeight,
37
36
borderRadius,
38
- experiment = { } ,
37
+ experiment,
39
38
} : { |
40
39
height ?: ?number ,
41
40
fundingEligibility : FundingEligibilityType ,
42
41
disableMaxWidth ?: ?boolean ,
43
42
disableMaxHeight ?: ?boolean ,
44
43
borderRadius ?: ?number ,
45
44
experiment : Experiment ,
46
- | } ) : string {
47
- let button_size_style_obj = "" ;
48
- let button_disable_max_style = "" ;
49
-
50
- Object . keys ( BUTTON_SIZE_STYLE )
45
+ | } ) : string => {
46
+ return Object . keys ( BUTTON_SIZE_STYLE )
51
47
. map ( ( size ) => {
52
48
const {
53
49
style,
@@ -64,7 +60,7 @@ export function buttonResponsiveStyle({
64
60
size,
65
61
} ) ;
66
62
67
- button_size_style_obj += `
63
+ return `
68
64
@media only screen and (min-width: ${ style . minWidth } px) {
69
65
.${ CLASS . CONTAINER } {
70
66
min-width: ${ style . minWidth } px;
@@ -356,9 +352,17 @@ export function buttonResponsiveStyle({
356
352
` ;
357
353
} )
358
354
. join ( "\n" ) ;
355
+ } ;
359
356
360
- if ( disableMaxHeight ) {
361
- Object . keys ( BUTTON_DISABLE_MAX_HEIGHT_STYLE ) . map ( ( disableMaxHeightSize ) => {
357
+ const generateDisableMaxHeightStyles = ( {
358
+ fundingEligibility,
359
+ experiment,
360
+ } : { |
361
+ fundingEligibility : FundingEligibilityType ,
362
+ experiment : Experiment ,
363
+ | } ) : string => {
364
+ return Object . keys ( BUTTON_DISABLE_MAX_HEIGHT_STYLE )
365
+ . map ( ( disableMaxHeightSize ) => {
362
366
const {
363
367
disableHeightStyle,
364
368
labelHeight,
@@ -373,7 +377,7 @@ export function buttonResponsiveStyle({
373
377
374
378
const { minHeight, maxHeight } = disableHeightStyle ;
375
379
376
- button_disable_max_style += `
380
+ return `
377
381
@media (min-height: ${ minHeight } px) and (max-height: ${ maxHeight } px) {
378
382
.${ CLASS . CONTAINER } .${ CLASS . BUTTON_ROW } .${ CLASS . TEXT } ,
379
383
.${ CLASS . CONTAINER } .${ CLASS . BUTTON_ROW } .${ CLASS . SPACE } {
@@ -396,8 +400,40 @@ export function buttonResponsiveStyle({
396
400
}
397
401
}
398
402
` ;
399
- } ) ;
400
- }
403
+ } )
404
+ . join ( "\n" ) ;
405
+ } ;
406
+
407
+ export function buttonResponsiveStyle ( {
408
+ height,
409
+ fundingEligibility,
410
+ disableMaxWidth,
411
+ disableMaxHeight,
412
+ borderRadius,
413
+ experiment = { } ,
414
+ } : { |
415
+ height ?: ?number ,
416
+ fundingEligibility : FundingEligibilityType ,
417
+ disableMaxWidth ?: ?boolean ,
418
+ disableMaxHeight ?: ?boolean ,
419
+ borderRadius ?: ?number ,
420
+ experiment : Experiment ,
421
+ | } ) : string {
422
+ const buttonSizeStyles = generateButtonSizeStyles ( {
423
+ height,
424
+ fundingEligibility,
425
+ disableMaxWidth,
426
+ disableMaxHeight,
427
+ borderRadius,
428
+ experiment,
429
+ } ) ;
430
+
431
+ const disableMaxHeightStyles = disableMaxHeight
432
+ ? generateDisableMaxHeightStyles ( {
433
+ fundingEligibility,
434
+ experiment,
435
+ } )
436
+ : "" ;
401
437
402
- return button_size_style_obj + button_disable_max_style ;
438
+ return buttonSizeStyles + disableMaxHeightStyles ;
403
439
}
0 commit comments