PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.2.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.2.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
better-payment / src / campaign-builder / components / TemplateModal.js

TemplateModal.js in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.2.1, at src/campaign-builder/components/TemplateModal.js

88 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n';
2
3 /**
4 * Template selection modal — shown when a new campaign has no saved layout.
5 * Templates are provided from PHP via window.betterPaymentCampaignData.templates.
6 */
7
8 const TEMPLATE_ICONS = {
9 'blank-1col': (
10 <svg width="64" height="48" viewBox="0 0 64 48" fill="none" xmlns="http://www.w3.org/2000/svg">
11 <rect x="4" y="4" width="56" height="40" rx="3" fill="#f0f0f1" stroke="#ddd" strokeWidth="1.5"/>
12 <rect x="10" y="10" width="44" height="6" rx="2" fill="#6b63f6" opacity="0.6"/>
13 <rect x="10" y="20" width="44" height="4" rx="2" fill="#ddd"/>
14 <rect x="10" y="28" width="34" height="4" rx="2" fill="#ddd"/>
15 <rect x="10" y="36" width="20" height="4" rx="2" fill="#ddd"/>
16 </svg>
17 ),
18 'blank-2col': (
19 <svg width="64" height="48" viewBox="0 0 64 48" fill="none" xmlns="http://www.w3.org/2000/svg">
20 <rect x="4" y="4" width="56" height="40" rx="3" fill="#f0f0f1" stroke="#ddd" strokeWidth="1.5"/>
21 <rect x="8" y="10" width="30" height="6" rx="2" fill="#6b63f6" opacity="0.6"/>
22 <rect x="8" y="20" width="30" height="4" rx="2" fill="#ddd"/>
23 <rect x="8" y="28" width="24" height="4" rx="2" fill="#ddd"/>
24 <rect x="8" y="36" width="16" height="4" rx="2" fill="#ddd"/>
25 <rect x="42" y="10" width="14" height="28" rx="2" fill="#6b63f6" opacity="0.15" stroke="#6b63f6" strokeWidth="1"/>
26 </svg>
27 ),
28 'blank-3col': (
29 <svg width="64" height="48" viewBox="0 0 64 48" fill="none" xmlns="http://www.w3.org/2000/svg">
30 <rect x="4" y="4" width="56" height="40" rx="3" fill="#f0f0f1" stroke="#ddd" strokeWidth="1.5"/>
31 <rect x="7" y="10" width="15" height="28" rx="2" fill="#6b63f6" opacity="0.15" stroke="#6b63f6" strokeWidth="1"/>
32 <rect x="25" y="10" width="15" height="28" rx="2" fill="#6b63f6" opacity="0.15" stroke="#6b63f6" strokeWidth="1"/>
33 <rect x="43" y="10" width="15" height="28" rx="2" fill="#6b63f6" opacity="0.15" stroke="#6b63f6" strokeWidth="1"/>
34 </svg>
35 ),
36 'charity-basic': (
37 <svg width="64" height="48" viewBox="0 0 64 48" fill="none" xmlns="http://www.w3.org/2000/svg">
38 <rect x="4" y="4" width="56" height="40" rx="3" fill="#f0f0f1" stroke="#ddd" strokeWidth="1.5"/>
39 <rect x="8" y="8" width="30" height="16" rx="2" fill="#6b63f6" opacity="0.3"/>
40 <rect x="8" y="28" width="30" height="4" rx="2" fill="#6b63f6" opacity="0.6"/>
41 <rect x="8" y="36" width="22" height="4" rx="2" fill="#ddd"/>
42 <rect x="42" y="8" width="14" height="8" rx="2" fill="#ddd"/>
43 <rect x="42" y="20" width="14" height="4" rx="2" fill="#ddd"/>
44 <rect x="42" y="28" width="14" height="4" rx="2" fill="#ddd"/>
45 <rect x="42" y="36" width="14" height="4" rx="2" fill="#6b63f6" opacity="0.7"/>
46 </svg>
47 ),
48 };
49
50 export default function TemplateModal( { dispatch } ) {
51 const templates = window?.betterPaymentCampaignData?.templates || [];
52
53 const handleSelect = ( template ) => {
54 dispatch( { type: 'APPLY_TEMPLATE', template } );
55 };
56
57 return (
58 <div className="bp-template-modal-overlay">
59 <div className="bp-template-modal">
60 <div className="bp-template-modal__header">
61 <h2>{ __( 'Choose a Starting Layout', 'better-payment' ) }</h2>
62 <p>{ __( 'Select a template to begin building your fundraising campaign.', 'better-payment' ) }</p>
63 </div>
64
65 <div className="bp-template-modal__grid">
66 { templates.map( ( tpl ) => (
67 <button
68 key={ tpl.key }
69 className="bp-template-card"
70 onClick={ () => handleSelect( tpl ) }
71 >
72 <div className="bp-template-card__thumb">
73 { TEMPLATE_ICONS[ tpl.key ] || (
74 <span className="dashicons dashicons-layout" />
75 ) }
76 </div>
77 <div className="bp-template-card__info">
78 <strong>{ tpl.label }</strong>
79 <span>{ tpl.description }</span>
80 </div>
81 </button>
82 ) ) }
83 </div>
84 </div>
85 </div>
86 );
87 }
88