PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.4
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.1.4
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / wizard / assets / src / wizard-steps / PageBuilderStep.js

PageBuilderStep.js in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.4, at wizard/assets/src/wizard-steps/PageBuilderStep.js

232 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useState, useEffect } from 'react';
2 import { useHistory } from 'react-router-dom';
3 import { RadioGroup } from '@headlessui/react';
4 import { __ } from '@wordpress/i18n';
5 import { useStateValue } from '../utils/StateProvider';
6 import Elementor from '@WizardImages/elementor.svg';
7 import BeaverBuilder from '@WizardImages/beaver-builder.svg';
8 import BlockEditor from '@WizardImages/block-editor.png';
9 import otherPageBuilders from '@WizardImages/other.svg';
10 import Bricks from '@WizardImages/bricks.png';
11 import { ArrowRightIcon } from '@heroicons/react/24/outline';
12
13 const mailingLists = [
14 {
15 id: 1,
16 slug: 'gutenberg',
17 title: 'Block Builder',
18 image: BlockEditor,
19 },
20 {
21 id: 2,
22 slug: 'elementor',
23 title: 'Elementor',
24 image: Elementor,
25 },
26 {
27 id: 3,
28 slug: 'bricks-builder',
29 title: 'Bricks',
30 image: Bricks,
31 },
32 {
33 id: 4,
34 slug: 'beaver-builder',
35 title: 'Beaver Builder',
36 image: BeaverBuilder,
37 },
38 {
39 id: 5,
40 slug: 'other',
41 title: 'Other',
42 image: otherPageBuilders,
43 },
44 ];
45
46 function classNames( ...classes ) {
47 return classes.filter( Boolean ).join( ' ' );
48 }
49
50 function PageBuilderStep() {
51 const [ selectedMailingLists, setSelectedMailingLists ] = useState(
52 cartflows_wizard?.active_page_builder || mailingLists[ 0 ].slug
53 );
54 const [ { action_button }, dispatch ] = useStateValue();
55 const history = useHistory();
56 const handleChange = ( value ) => {
57 setSelectedMailingLists( value );
58
59 dispatch( {
60 status: 'SET_WIZARD_PAGE_BUILDER',
61 selected_page_builder: value,
62 } );
63 };
64
65 useEffect( () => {
66 dispatch( {
67 status: 'SET_NEXT_STEP',
68 action_button: {
69 button_text: __( 'Save & Continue', 'cartflows' ),
70 button_class: 'install-page-builder-plugins',
71 },
72 } );
73
74 const installPbPluginsProcess = document.addEventListener(
75 'wcf-page-builder-plugins-install-processing',
76 function () {
77 dispatch( {
78 status: 'SET_NEXT_STEP',
79 action_button: {
80 button_text: __( 'Saving', 'cartflows' ),
81 button_class: 'install-page-builder-plugins is-loading',
82 },
83 } );
84
85 dispatch( {
86 status: 'PROCESSING',
87 } );
88 },
89 false
90 );
91
92 const installPbPluginsSuccess = document.addEventListener(
93 'wcf-page-builder-plugins-install-success',
94 function () {
95 // Stop the processing.
96 dispatch( {
97 status: 'RESET',
98 } );
99
100 history.push( {
101 pathname: 'index.php',
102 search: `?page=cartflow-setup&step=plugin-install`,
103 } );
104 },
105 false
106 );
107
108 return () => {
109 document.removeEventListener(
110 'wcf-page-builder-plugins-install-processing',
111 installPbPluginsProcess
112 );
113
114 document.removeEventListener(
115 'wcf-page-builder-plugins-install-success',
116 installPbPluginsSuccess
117 );
118 };
119 }, [] );
120
121 return (
122 <div className="wcf-container">
123 <div className="wcf-row text-center mt-12">
124 <div className="bg-white rounded mx-auto px-11">
125 <span className="text-sm font-medium text-primary-600 mb-10 text-center block tracking-[.24em] uppercase">
126 { __( 'Step 2 of 6', 'cartflows' ) }
127 </span>
128 <h1 className="wcf-step-heading mb-4">
129 { __(
130 'Hi there! Tell us which page builder you use.',
131 'cartflows'
132 ) }
133 </h1>
134
135 <div className="flex justify-center mb-10">
136 <RadioGroup
137 value={ selectedMailingLists }
138 onChange={ handleChange }
139 >
140 <RadioGroup.Label className="text-center overflow-hidden max-w-2xl mb-10 mx-auto text-lg font-normal text-slate-500 block">
141 { __(
142 "CartFlows works with all page builders, so don't worry if your page builder is not in the list. ",
143 'cartflows'
144 ) }
145 </RadioGroup.Label>
146
147 <div className="wcf-pb-list-wrapper flex justify-center items-center gap-8">
148 { mailingLists.map( ( mailingList ) => (
149 <RadioGroup.Option
150 key={ mailingList.id }
151 value={ mailingList.slug }
152 data-key={ mailingList.slug }
153 className={ ( { checked, active } ) =>
154 classNames(
155 'wcf-pb-list--option relative border rounded shadow-sm flex justify-center cursor-pointer h-[9rem] w-[130px] transition-all duration-300 focus:outline-none hover:drop-shadow-lg hover:translate-y-[-1px] hover:shadow-[0px 4px 8px -2px rgb(9 30 66 / 25%), 0px 0px 1px rgb(9 30 66 / 31%)]',
156 checked
157 ? 'border-transparent'
158 : 'border-gray-300',
159 active ? '' : ''
160 )
161 }
162 >
163 { ( { checked, active } ) => (
164 <>
165 <div className="flex-auto flex justify-center">
166 <div className="text-center">
167 <RadioGroup.Description
168 as="img"
169 className="block text-sm font-normal text-[#4B5563] h-[45%] rounded-full m-5"
170 src={
171 mailingList.image
172 }
173 ></RadioGroup.Description>
174 <RadioGroup.Label
175 as="div"
176 className="block text-sm font-normal text-[#4B5563] mt-4"
177 >
178 {
179 mailingList.title
180 }
181 </RadioGroup.Label>
182 </div>
183 </div>
184
185 <div
186 className={ classNames(
187 active
188 ? 'border-2'
189 : 'border-2',
190 checked
191 ? 'border-orange-500'
192 : 'border-transparent',
193 'absolute -inset-px rounded pointer-events-none'
194 ) }
195 aria-hidden="true"
196 />
197 </>
198 ) }
199 </RadioGroup.Option>
200 ) ) }
201 </div>
202 </RadioGroup>
203
204 <span
205 id="wcf-selected-page-builder"
206 data-selected-pb={ selectedMailingLists }
207 ></span>
208 </div>
209
210 <div className="flex justify-center">
211 <div
212 className={ `wcf-wizard--button ${
213 action_button.button_class
214 ? action_button.button_class
215 : ''
216 }` }
217 >
218 { action_button.button_text }
219 <ArrowRightIcon
220 className="w-5 mt-0.5 ml-1.5 stroke-2"
221 aria-hidden="true"
222 />
223 </div>
224 </div>
225 </div>
226 </div>
227 </div>
228 );
229 }
230
231 export default PageBuilderStep;
232