DonationReceipt.tsx
5 months ago
DonationSummaryItems.tsx
1 year ago
FieldDescription.tsx
2 years ago
FieldError.tsx
2 years ago
FieldLabel.tsx
2 years ago
Form.tsx
2 years ago
FormError.tsx
1 year ago
Goal.tsx
1 year ago
GoalAchieved.tsx
2 years ago
Header.tsx
2 years ago
HeaderDescription.tsx
1 year ago
HeaderImage.tsx
2 years ago
HeaderTitle.tsx
2 years ago
MultiStepForm.tsx
2 years ago
NodeWrapper.tsx
2 years ago
Section.tsx
1 year ago
Header.tsx
91 lines
| 1 | import type {HeaderProps} from '@givewp/forms/propTypes'; |
| 2 | import cx from 'classnames'; |
| 3 | |
| 4 | /** |
| 5 | * @since 3.5.0 add HeaderImage |
| 6 | * @since 3.0.0 |
| 7 | */ |
| 8 | export default function Header({ HeaderImage, Title, Description, Goal, isMultiStep }: HeaderProps) { |
| 9 | const { designSettingsImageStyle, designSettingsImageUrl } = window.givewp.form.hooks.useDonationFormSettings(); |
| 10 | |
| 11 | if (!designSettingsImageUrl) { |
| 12 | return ( |
| 13 | <div className={ |
| 14 | cx({ |
| 15 | 'givewp-layouts-header__templates': !isMultiStep, |
| 16 | 'givewp-layouts-header__templates-ms': isMultiStep |
| 17 | } |
| 18 | )}> |
| 19 | <Title /> |
| 20 | <Description /> |
| 21 | <Goal /> |
| 22 | </div> |
| 23 | ); |
| 24 | } |
| 25 | |
| 26 | return ( |
| 27 | <div |
| 28 | className={cx({ |
| 29 | 'givewp-layouts-header__templates': !isMultiStep, |
| 30 | [`givewp-layouts-header__templates--${designSettingsImageStyle}`]: !isMultiStep, |
| 31 | 'givewp-layouts-header__templates-ms': isMultiStep, |
| 32 | [`givewp-layouts-header__templates-ms--${designSettingsImageStyle}`]: isMultiStep |
| 33 | })} |
| 34 | > |
| 35 | <HeaderImageTemplates |
| 36 | imagePosition={designSettingsImageStyle} |
| 37 | HeaderImage={HeaderImage} |
| 38 | Title={Title} |
| 39 | Description={Description} |
| 40 | Goal={Goal} |
| 41 | /> |
| 42 | </div> |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | function HeaderImageTemplates({ imagePosition, HeaderImage, Title, Description, Goal }) { |
| 47 | switch (imagePosition) { |
| 48 | case 'background': |
| 49 | return ( |
| 50 | <> |
| 51 | <div className={'givewp-layouts-header__content'}> |
| 52 | <HeaderImage /> |
| 53 | <Title /> |
| 54 | <Description /> |
| 55 | </div> |
| 56 | <div className={'givewp-layouts-header__goal'}> |
| 57 | <Goal /> |
| 58 | </div> |
| 59 | </> |
| 60 | ); |
| 61 | case 'above': |
| 62 | return ( |
| 63 | <> |
| 64 | <HeaderImage /> |
| 65 | <div className={'givewp-layouts-header__content'}> |
| 66 | <Title /> |
| 67 | <Description /> |
| 68 | <Goal /> |
| 69 | </div> |
| 70 | </> |
| 71 | ); |
| 72 | case 'center': |
| 73 | return ( |
| 74 | <> |
| 75 | <Title /> |
| 76 | <Description /> |
| 77 | <HeaderImage /> |
| 78 | <Goal /> |
| 79 | </> |
| 80 | ); |
| 81 | default: |
| 82 | return ( |
| 83 | <> |
| 84 | <Title /> |
| 85 | <Description /> |
| 86 | <Goal /> |
| 87 | </> |
| 88 | ); |
| 89 | } |
| 90 | } |
| 91 |