PluginProbe
Ultimate Store Kit / 3.1.3
Ultimate Store Kit v3.1.3
3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 92 releases
ultimate-store-kit / src / admin / components / ProPromo.js

ProPromo.js in Ultimate Store Kit 3.1.3, at src/admin/components/ProPromo.js

225 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n';
2 import { btnPrimary, btnSm, fieldControl, fieldLabel, fieldRow, proBadge } from '../tw';
3
4 const PRO_URL = 'https://bdthemes.com/ultimate-store-kit/';
5
6 const promoSettings = [
7 {
8 group: __('Sales Notifications', 'ultimate-store-kit'),
9 description: __(
10 'Configure flash sale banners, countdown timers, and promotional badges for your store.',
11 'ultimate-store-kit'
12 ),
13 fields: [
14 {
15 name: 'enable_flash_sale',
16 type: 'checkbox',
17 label: __('Enable Flash Sale Banner', 'ultimate-store-kit'),
18 description: __(
19 'Display a site-wide flash sale banner on product pages.',
20 'ultimate-store-kit'
21 ),
22 },
23 {
24 name: 'flash_sale_text',
25 type: 'text',
26 label: __('Flash Sale Text', 'ultimate-store-kit'),
27 placeholder: __('🔥 Flash Sale — Up to 50% OFF!', 'ultimate-store-kit'),
28 },
29 {
30 name: 'sale_badge_style',
31 type: 'select',
32 label: __('Sale Badge Style', 'ultimate-store-kit'),
33 options: {
34 default: __('Default', 'ultimate-store-kit'),
35 ribbon: __('Ribbon', 'ultimate-store-kit'),
36 circle: __('Circle', 'ultimate-store-kit'),
37 starburst: __('Starburst', 'ultimate-store-kit'),
38 },
39 },
40 {
41 name: 'sale_badge_color',
42 type: 'color',
43 label: __('Sale Badge Color', 'ultimate-store-kit'),
44 value: '#ef4444',
45 },
46 {
47 name: 'enable_countdown_timer',
48 type: 'checkbox',
49 label: __('Enable Sale Countdown Timer', 'ultimate-store-kit'),
50 description: __(
51 'Show a countdown timer on products that have a sale end date.',
52 'ultimate-store-kit'
53 ),
54 },
55 {
56 name: 'countdown_position',
57 type: 'select',
58 label: __('Countdown Position', 'ultimate-store-kit'),
59 options: {
60 above_price: __('Above Price', 'ultimate-store-kit'),
61 below_price: __('Below Price', 'ultimate-store-kit'),
62 above_button: __('Above Add to Cart', 'ultimate-store-kit'),
63 },
64 },
65 {
66 name: 'minimum_discount_percent',
67 type: 'number',
68 label: __(
69 'Minimum Discount % to Show Badge',
70 'ultimate-store-kit'
71 ),
72 value: '5',
73 description: __(
74 'Only show the sale badge when the discount is at least this percentage.',
75 'ultimate-store-kit'
76 ),
77 },
78 ],
79 },
80 ];
81
82 const ProPromo = () => {
83 return (
84 <div className="pointer-events-none relative select-none opacity-70">
85 <div className="pointer-events-auto mb-4 flex items-center justify-between rounded-usk border border-uks-brand bg-[linear-gradient(313deg,#E62A3F_0%,#00216A_100%)] px-5 py-3.5">
86 <div className="flex items-center gap-2.5">
87 <span className="rounded-[10px] bg-[linear-gradient(313deg,#E62A3F_0%,#00216A_100%)] px-2.5 py-1 text-[10px] font-bold uppercase tracking-wide text-white">
88 {__('Pro', 'ultimate-store-kit')}
89 </span>
90 <span className="text-sm font-semibold text-white/90">
91 {__(
92 'Unlock these premium settings with Ultimate Store Kit Pro',
93 'ultimate-store-kit'
94 )}
95 </span>
96 </div>
97 <a href={PRO_URL} target="_blank" rel="noopener noreferrer" className={`${btnSm} ${btnPrimary}`}>
98 {__('Get Pro', 'ultimate-store-kit')}
99 </a>
100 </div>
101
102 {promoSettings.map((group, gi) => (
103 <div
104 key={gi}
105 className="relative mb-4 overflow-hidden rounded-usk border border-slate-200 bg-white"
106 >
107 <div className="border-l-[3px] border-uks-brand">
108 <h3 className="m-0 flex flex-wrap items-center gap-2 border-b border-slate-200 bg-slate-100 px-5 py-3.5 text-sm font-bold text-slate-800">
109 {group.group}
110 <span className={proBadge}>
111 {__('Pro', 'ultimate-store-kit')}
112 </span>
113 </h3>
114 {group.description && (
115 <p className="m-0 px-5 pt-1 text-[13px] leading-relaxed text-slate-400">
116 {group.description}
117 </p>
118 )}
119 <div className="px-5 py-2 opacity-60">
120 {group.fields.map((field) => {
121 if (field.type === 'checkbox') {
122 return (
123 <div
124 key={field.name}
125 className={`${fieldRow} flex-wrap`}
126 >
127 <div className={fieldLabel}>
128 <span>{field.label}</span>
129 </div>
130 <div className="h-[22px] w-10 rounded-full bg-slate-200" />
131 {field.description && (
132 <p className="mt-1 w-full text-xs leading-snug text-slate-400">
133 {field.description}
134 </p>
135 )}
136 </div>
137 );
138 }
139
140 if (field.type === 'select') {
141 const defaultValue = Object.keys(field.options)[0];
142 return (
143 <div key={field.name} className={fieldRow}>
144 <label className={fieldLabel}>
145 {field.label}
146 </label>
147 <select
148 className={`${fieldControl} cursor-not-allowed opacity-60`}
149 disabled
150 defaultValue={defaultValue}
151 >
152 {Object.entries(
153 field.options
154 ).map(([val, lbl]) => (
155 <option
156 key={val}
157 value={val}
158 >
159 {lbl}
160 </option>
161 ))}
162 </select>
163 </div>
164 );
165 }
166
167 if (field.type === 'color') {
168 return (
169 <div key={field.name} className={fieldRow}>
170 <label className={fieldLabel}>
171 {field.label}
172 </label>
173 <input
174 type="color"
175 disabled
176 value={field.value || '#000000'}
177 readOnly
178 className="h-8 w-12 cursor-not-allowed rounded-md border border-slate-200 p-0.5 opacity-60"
179 />
180 </div>
181 );
182 }
183
184 if (
185 field.type === 'number' ||
186 field.type === 'text'
187 ) {
188 return (
189 <div key={field.name} className={fieldRow}>
190 <label className={fieldLabel}>
191 {field.label}
192 </label>
193 <input
194 type={field.type}
195 className={`${fieldControl} cursor-not-allowed opacity-60`}
196 disabled
197 placeholder={
198 field.placeholder || ''
199 }
200 defaultValue={
201 field.value || ''
202 }
203 readOnly
204 />
205 {field.description && (
206 <p className="mt-1 w-full text-xs leading-snug text-slate-400">
207 {field.description}
208 </p>
209 )}
210 </div>
211 );
212 }
213
214 return null;
215 })}
216 </div>
217 </div>
218 </div>
219 ))}
220 </div>
221 );
222 };
223
224 export default ProPromo;
225