woocommerce-paypal-payments/modules/ppcp-settings/resources/js/Components/ReusableComponents/BadgeBox.js

42 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-11-05 13:49:38 +04:00
import data from '../../utils/data';
2024-11-06 18:37:56 +04:00
import TitleBadge, { TITLE_BADGE_INFO } from "./TitleBadge";
import { __ } from "@wordpress/i18n";
2024-11-05 13:49:38 +04:00
const BadgeBox = ( props ) => {
2024-11-05 17:54:47 +04:00
const titleSize = props.titleType && props.titleType === BADGE_BOX_TITLE_BIG ? BADGE_BOX_TITLE_BIG : BADGE_BOX_TITLE_SMALL
2024-11-06 18:37:56 +04:00
const titleTextClassName = 'ppcp-r-badge-box__title-text ' + `ppcp-r-badge-box__title-text--${ titleSize }`;
2024-11-05 17:54:47 +04:00
const titleBaseClassName = 'ppcp-r-badge-box__title';
2024-11-06 18:37:56 +04:00
const titleClassName = props.imageBadge ? `${ titleBaseClassName } ppcp-r-badge-box__title--has-image-badge` : titleBaseClassName;
2024-11-05 13:49:38 +04:00
return (
2024-11-05 17:54:47 +04:00
<div className="ppcp-r-badge-box">
2024-11-06 18:37:56 +04:00
<span className={ titleClassName }>
<span className={ titleTextClassName }>{props.title}</span>
2024-11-05 13:49:38 +04:00
2024-11-06 18:37:56 +04:00
{ props.imageBadge && (
2024-11-05 17:54:47 +04:00
<span className="ppcp-r-badge-box__title-image-badge">
2024-11-06 18:37:56 +04:00
{ props.imageBadge.map( ( badge ) => data().getImage( badge ) ) }
2024-11-05 17:54:47 +04:00
</span>
2024-11-06 18:37:56 +04:00
) }
2024-11-05 13:49:38 +04:00
2024-11-06 18:37:56 +04:00
{ props.textBadge && (
<TitleBadge type={ TITLE_BADGE_INFO } text={ props.textBadge }/>
) }
2024-11-05 13:49:38 +04:00
</span>
2024-11-05 17:54:47 +04:00
<div className="ppcp-r-badge-box__description">
2024-11-06 18:37:56 +04:00
{ props?.description && (
2024-11-05 13:49:38 +04:00
<p
2024-11-05 17:54:47 +04:00
className="ppcp-r-badge-box__description"
2024-11-06 18:37:56 +04:00
dangerouslySetInnerHTML={ { __html: props.description, } }
2024-11-05 13:49:38 +04:00
></p>
2024-11-06 18:37:56 +04:00
) }
2024-11-05 13:49:38 +04:00
</div>
</div>
);
};
2024-11-05 17:54:47 +04:00
export const BADGE_BOX_TITLE_BIG = 'big';
export const BADGE_BOX_TITLE_SMALL = 'small';
2024-11-05 13:49:38 +04:00
export default BadgeBox;