Header.tsx
94 lines
| 1 | import {__} from '@wordpress/i18n'; |
| 2 | import {HeaderProps} from '@givewp/forms/propTypes'; |
| 3 | |
| 4 | /** |
| 5 | * @since 3.0.0 |
| 6 | */ |
| 7 | const SecureBadge = () => { |
| 8 | return ( |
| 9 | <aside className="givewp-form-secure-badge"> |
| 10 | <i className="fa-solid fa-lock givewp-secondary-color"></i> |
| 11 | <span>{__('100% Secure Donation', 'give')}</span> |
| 12 | </aside> |
| 13 | ); |
| 14 | }; |
| 15 | |
| 16 | /** |
| 17 | * @since 3.5.0 add HeaderImage |
| 18 | * @since 3.0.0 |
| 19 | */ |
| 20 | export default function Header({HeaderImage, Title, Description, Goal}: HeaderProps) { |
| 21 | const {designSettingsImageStyle, designSettingsImageUrl} = window.givewp.form.hooks.useDonationFormSettings(); |
| 22 | |
| 23 | if (!designSettingsImageUrl) { |
| 24 | return ( |
| 25 | <div className={`givewp-layouts-header__templates`}> |
| 26 | <Title /> |
| 27 | <Description /> |
| 28 | <SecureBadge /> |
| 29 | <Goal /> |
| 30 | </div> |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | return ( |
| 35 | <div |
| 36 | className={`givewp-layouts-header__templates givewp-layouts-header__templates--${designSettingsImageStyle}`} |
| 37 | > |
| 38 | <HeaderImageTemplates |
| 39 | imagePosition={designSettingsImageStyle} |
| 40 | HeaderImage={HeaderImage} |
| 41 | Title={Title} |
| 42 | Description={Description} |
| 43 | Goal={Goal} |
| 44 | /> |
| 45 | </div> |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | function HeaderImageTemplates({imagePosition, HeaderImage, Title, Description, Goal}) { |
| 50 | switch (imagePosition) { |
| 51 | case 'background': |
| 52 | return ( |
| 53 | <> |
| 54 | <HeaderImage /> |
| 55 | <Title /> |
| 56 | <Description /> |
| 57 | <SecureBadge /> |
| 58 | <Goal /> |
| 59 | </> |
| 60 | ); |
| 61 | case 'above': |
| 62 | return ( |
| 63 | <> |
| 64 | <HeaderImage /> |
| 65 | <div className={'givewp-layouts-header__content'}> |
| 66 | <Title /> |
| 67 | <Description /> |
| 68 | <SecureBadge /> |
| 69 | <Goal /> |
| 70 | </div> |
| 71 | </> |
| 72 | ); |
| 73 | case 'center': |
| 74 | return ( |
| 75 | <> |
| 76 | <Title /> |
| 77 | <Description /> |
| 78 | <SecureBadge /> |
| 79 | <HeaderImage /> |
| 80 | <Goal /> |
| 81 | </> |
| 82 | ); |
| 83 | default: |
| 84 | return ( |
| 85 | <> |
| 86 | <Title /> |
| 87 | <Description /> |
| 88 | <SecureBadge /> |
| 89 | <Goal /> |
| 90 | </> |
| 91 | ); |
| 92 | } |
| 93 | } |
| 94 |