2020-04-29 10:57:58 +00:00
|
|
|
/**
|
|
|
|
* Get a class name for an icon.
|
|
|
|
*
|
|
|
|
* @param {string} id Icon ID.
|
|
|
|
*/
|
|
|
|
const getIconClassName = ( id ) => {
|
2020-06-17 09:53:42 +00:00
|
|
|
return `wc-block-components-payment-method-icon wc-block-components-payment-method-icon--${ id }`;
|
2020-04-29 10:57:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an element for an icon.
|
2020-09-20 23:54:08 +00:00
|
|
|
*
|
|
|
|
* @param {Object} props Incoming props for component.
|
|
|
|
* @param {string} props.id Id for component.
|
|
|
|
* @param {string|null} props.src Optional src value for icon.
|
|
|
|
* @param {string} props.alt Optional alt value for icon.
|
2020-04-29 10:57:58 +00:00
|
|
|
*/
|
|
|
|
const PaymentMethodIcon = ( { id, src = null, alt = '' } ) => {
|
|
|
|
if ( ! src ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return <img className={ getIconClassName( id ) } src={ src } alt={ alt } />;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PaymentMethodIcon;
|