Skip to content

Commit bcfa80f

Browse files
committed
fix: conditionally render monei-text span in blocks checkout labels
Hide monei-text span when payment method title is empty/hidden to prevent layout issues. Applies to all payment method labels in blocks checkout. - CC component: conditionally render monei-text based on moneiData.title - Bizum: conditionally render monei-text based on bizumData.title - PayPal: conditionally render monei-text based on paypalData.title - Multibanco: conditionally render monei-text based on multibancoData.title - MBWay: conditionally render monei-text based on mbwayData.title - Apple/Google already had conditional rendering This matches the pattern already used in Apple/Google Pay component.
1 parent 0f25185 commit bcfa80f

File tree

6 files changed

+29
-20
lines changed

6 files changed

+29
-20
lines changed

assets/css/monei-blocks-checkout.css

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@
6767

6868
/* Label Container */
6969
.monei-label-container {
70-
display: block;
70+
flex: 1;
71+
display: flex;
72+
flex-wrap: wrap;
73+
align-items: center;
74+
justify-content: space-between;
75+
gap: 0.5em;
7176
}
7277

7378
.monei-text {
@@ -79,7 +84,6 @@
7984
display: inline-flex;
8085
align-items: center;
8186
gap: 0.3125em;
82-
flex-wrap: wrap;
8387
}
8488

8589
.monei-card-brands img,
@@ -150,9 +154,4 @@
150154
min-height: 3.75em;
151155
}
152156

153-
.monei-label-container {
154-
flex-direction: column;
155-
align-items: flex-start;
156-
gap: 0.3em;
157-
}
158157
}

assets/js/components/monei-cc-component.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ export const CreditCardLabel = ( moneiData ) => {
359359

360360
return (
361361
<div className="monei-label-container">
362-
<span className="monei-text">{ moneiData.title }</span>
362+
{ moneiData.title && (
363+
<span className="monei-text">{ moneiData.title }</span>
364+
) }
363365
{ cardBrands.length > 0 ? (
364366
<span className="monei-card-brands">
365367
{ cardBrands.map( ( brand, index ) => (

assets/js/monei-block-checkout-bizum.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,11 @@
361361
const bizumLabel = () => {
362362
return (
363363
<div className="monei-label-container">
364-
<span className="monei-text">
365-
{ __( bizumData.title, 'monei' ) }
366-
</span>
364+
{ bizumData.title && (
365+
<span className="monei-text">
366+
{ __( bizumData.title, 'monei' ) }
367+
</span>
368+
) }
367369
{ bizumData?.logo && (
368370
<div className="monei-logo">
369371
<img src={ bizumData.logo } alt="" />

assets/js/monei-block-checkout-mbway.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
const mbwayLabel = () => {
77
return (
88
<div className="monei-label-container">
9-
<span className="monei-text">
10-
{ __( mbwayData.title, 'monei' ) }
11-
</span>
9+
{ mbwayData.title && (
10+
<span className="monei-text">
11+
{ __( mbwayData.title, 'monei' ) }
12+
</span>
13+
) }
1214
{ mbwayData?.logo && (
1315
<div className="monei-logo">
1416
<img src={ mbwayData.logo } alt="" />

assets/js/monei-block-checkout-multibanco.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
const multibancoLabel = () => {
77
return (
88
<div className="monei-label-container">
9-
<span className="monei-text">
10-
{ __( multibancoData.title, 'monei' ) }
11-
</span>
9+
{ multibancoData.title && (
10+
<span className="monei-text">
11+
{ __( multibancoData.title, 'monei' ) }
12+
</span>
13+
) }
1214
{ multibancoData?.logo && (
1315
<div className="monei-logo">
1416
<img src={ multibancoData.logo } alt="" />

assets/js/monei-block-checkout-paypal.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@
235235
const paypalLabel = () => {
236236
return (
237237
<div className="monei-label-container">
238-
<span className="monei-text">
239-
{ __( paypalData.title, 'monei' ) }
240-
</span>
238+
{ paypalData.title && (
239+
<span className="monei-text">
240+
{ __( paypalData.title, 'monei' ) }
241+
</span>
242+
) }
241243
{ paypalData?.logo && (
242244
<div className="monei-logo">
243245
<img src={ paypalData.logo } alt="" />

0 commit comments

Comments
 (0)