mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add a disabled visual state to the Payment Method component
This commit is contained in:
parent
df076e13bc
commit
f2cb29e8e5
4 changed files with 99 additions and 3 deletions
|
@ -11,6 +11,8 @@ const PaymentMethodItemBlock = ( {
|
|||
onTriggerModal,
|
||||
onSelect,
|
||||
isSelected,
|
||||
isDisabled,
|
||||
disabledMessage,
|
||||
} ) => {
|
||||
const { activeHighlight, setActiveHighlight } = useActiveHighlight();
|
||||
const isHighlighted = activeHighlight === paymentMethod.id;
|
||||
|
@ -31,9 +33,16 @@ const PaymentMethodItemBlock = ( {
|
|||
id={ paymentMethod.id }
|
||||
className={ `ppcp--method-item ${
|
||||
isHighlighted ? 'ppcp-highlight' : ''
|
||||
}` }
|
||||
} ${ isDisabled ? 'ppcp--method-item--disabled' : '' }` }
|
||||
separatorAndGap={ false }
|
||||
>
|
||||
{ isDisabled && (
|
||||
<div className="ppcp--method-disabled-overlay">
|
||||
<p className="ppcp--method-disabled-message">
|
||||
{ disabledMessage }
|
||||
</p>
|
||||
</div>
|
||||
) }
|
||||
<div className="ppcp--method-inner">
|
||||
<div className="ppcp--method-title-wrapper">
|
||||
{ paymentMethod?.icon && (
|
||||
|
|
|
@ -19,12 +19,14 @@ const PaymentMethodsBlock = ( { paymentMethods = [], onTriggerModal } ) => {
|
|||
<SettingsBlock className="ppcp--grid ppcp-r-settings-block__payment-methods">
|
||||
{ paymentMethods
|
||||
// Remove empty/invalid payment method entries.
|
||||
.filter( ( m ) => m.id )
|
||||
.filter( ( m ) => m && m.id )
|
||||
.map( ( paymentMethod ) => (
|
||||
<PaymentMethodItemBlock
|
||||
key={ paymentMethod.id }
|
||||
paymentMethod={ paymentMethod }
|
||||
isSelected={ paymentMethod.enabled }
|
||||
isDisabled={ paymentMethod.isDisabled }
|
||||
disabledMessage={ paymentMethod.disabledMessage }
|
||||
onSelect={ ( checked ) =>
|
||||
handleSelect( paymentMethod.id, checked )
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue