PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.4.1
Block Animations, Motion & Scroll Effects – Ghost Kit v3.4.1
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / form / fields / email / edit.js

edit.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.4.1, at gutenberg/blocks/form/fields/email/edit.js

160 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import classnames from 'classnames/dedupe';
2
3 import {
4 InspectorControls,
5 RichText,
6 useBlockProps,
7 } from '@wordpress/block-editor';
8 import { PanelBody, TextControl, ToggleControl } from '@wordpress/components';
9 import { applyFilters } from '@wordpress/hooks';
10 import { __ } from '@wordpress/i18n';
11
12 import {
13 FieldDefaultSettings,
14 getFieldAttributes,
15 } from '../../field-attributes';
16 import FieldDescription from '../../field-description';
17 import FieldLabel from '../../field-label';
18
19 /**
20 * Block Edit Class.
21 *
22 * @param props
23 */
24 export default function BlockEdit(props) {
25 const { attributes, setAttributes } = props;
26
27 const {
28 description,
29 emailConfirmation,
30 descriptionConfirmation,
31 placeholderConfirmation,
32 defaultConfirmation,
33 } = attributes;
34
35 let { className = '' } = props;
36
37 className = classnames(
38 'ghostkit-form-field ghostkit-form-field-email',
39 className
40 );
41 className = applyFilters('ghostkit.editor.className', className, props);
42
43 const blockProps = useBlockProps({ className });
44
45 return (
46 <>
47 <InspectorControls>
48 <PanelBody>
49 <FieldDefaultSettings {...props} />
50 </PanelBody>
51 <PanelBody title={__('Email Confirmation', 'ghostkit')}>
52 <ToggleControl
53 label={__('Yes', 'ghostkit')}
54 checked={emailConfirmation}
55 onChange={() => {
56 if (emailConfirmation) {
57 setAttributes({
58 emailConfirmation: !emailConfirmation,
59 });
60 } else {
61 setAttributes({
62 emailConfirmation: !emailConfirmation,
63 description:
64 description || __('Email', 'ghostkit'),
65 descriptionConfirmation:
66 descriptionConfirmation ||
67 __('Confirm Email', 'ghostkit'),
68 });
69 }
70 }}
71 __nextHasNoMarginBottom
72 />
73 {emailConfirmation ? (
74 <>
75 <TextControl
76 label={__('Placeholder', 'ghostkit')}
77 value={placeholderConfirmation}
78 onChange={(val) =>
79 setAttributes({
80 placeholderConfirmation: val,
81 })
82 }
83 __next40pxDefaultSize
84 __nextHasNoMarginBottom
85 />
86 <TextControl
87 label={__('Default', 'ghostkit')}
88 value={defaultConfirmation}
89 onChange={(val) =>
90 setAttributes({ defaultConfirmation: val })
91 }
92 __next40pxDefaultSize
93 __nextHasNoMarginBottom
94 />
95 </>
96 ) : null}
97 </PanelBody>
98 </InspectorControls>
99 <div {...blockProps}>
100 <FieldLabel {...props} />
101
102 {emailConfirmation ? (
103 <div className="ghostkit-form-field-row">
104 <div className="ghostkit-form-field-email-primary">
105 <TextControl
106 type="email"
107 __next40pxDefaultSize
108 __nextHasNoMarginBottom
109 {...getFieldAttributes(attributes)}
110 />
111 <FieldDescription {...props} />
112 </div>
113 <div className="ghostkit-form-field-email-confirm">
114 <TextControl
115 type="email"
116 __next40pxDefaultSize
117 __nextHasNoMarginBottom
118 {...getFieldAttributes({
119 slug: attributes.slug
120 ? `${attributes.slug}-confirmation`
121 : null,
122 placeholder:
123 attributes.placeholderConfirmation,
124 default: attributes.defaultConfirmation,
125 required: attributes.required,
126 })}
127 />
128 <RichText
129 inlineToolbar
130 tagName="small"
131 className="ghostkit-form-field-description"
132 value={descriptionConfirmation}
133 placeholder={__(
134 'Write description…',
135 'ghostkit'
136 )}
137 onChange={(val) =>
138 setAttributes({
139 descriptionConfirmation: val,
140 })
141 }
142 />
143 </div>
144 </div>
145 ) : (
146 <>
147 <TextControl
148 type="email"
149 __next40pxDefaultSize
150 __nextHasNoMarginBottom
151 {...getFieldAttributes(attributes)}
152 />
153 <FieldDescription {...props} />
154 </>
155 )}
156 </div>
157 </>
158 );
159 }
160