PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
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 / button-single / deprecated.js

deprecated.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/blocks/button-single/deprecated.js

174 lines 3.0 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 { RichText, useBlockProps } from '@wordpress/block-editor';
4 import { applyFilters } from '@wordpress/hooks';
5
6 import IconPicker from '../../components/icon-picker';
7 import metadata from './block.json';
8
9 const { name } = metadata;
10
11 export default [
12 // v2.23.2
13 {
14 ...metadata,
15
16 attributes: {
17 tagName: {
18 type: 'string',
19 },
20 url: {
21 type: 'string',
22 source: 'attribute',
23 selector: 'a.ghostkit-button',
24 attribute: 'href',
25 },
26 target: {
27 type: 'string',
28 source: 'attribute',
29 selector: 'a.ghostkit-button',
30 attribute: 'target',
31 },
32 rel: {
33 type: 'string',
34 source: 'attribute',
35 selector: 'a.ghostkit-button',
36 attribute: 'rel',
37 },
38 text: {
39 type: 'string',
40 source: 'html',
41 selector: '.ghostkit-button .ghostkit-button-text',
42 default: 'Button',
43 },
44 hideText: {
45 type: 'boolean',
46 default: false,
47 },
48 icon: {
49 type: 'string',
50 default: '',
51 },
52 iconPosition: {
53 type: 'string',
54 default: 'left',
55 },
56 size: {
57 type: 'string',
58 default: 'md',
59 },
60 color: {
61 type: 'string',
62 },
63 textColor: {
64 type: 'string',
65 },
66
67 borderRadius: {
68 type: 'number',
69 },
70 borderWeight: {
71 type: 'number',
72 },
73 borderColor: {
74 type: 'string',
75 },
76
77 focusOutlineWeight: {
78 type: 'number',
79 },
80
81 hoverColor: {
82 type: 'string',
83 },
84 hoverTextColor: {
85 type: 'string',
86 },
87 hoverBorderColor: {
88 type: 'string',
89 },
90
91 focusOutlineColor: {
92 type: 'string',
93 default: 'rgba(3, 102, 214, 0.5)',
94 },
95 },
96 save: function BlockSave(props) {
97 const {
98 tagName,
99 text,
100 icon,
101 iconPosition,
102 hideText,
103 url,
104 target,
105 rel,
106 size,
107 focusOutlineWeight,
108 focusOutlineColor,
109 } = props.attributes;
110
111 let className = classnames(
112 'ghostkit-button',
113 size && `ghostkit-button-${size}`,
114 hideText && 'ghostkit-button-icon-only'
115 );
116
117 // focus outline
118 if (focusOutlineWeight && focusOutlineColor) {
119 className = classnames(
120 className,
121 'ghostkit-button-with-outline'
122 );
123 }
124
125 className = applyFilters('ghostkit.blocks.className', className, {
126 name,
127 ...props,
128 });
129
130 const result = [];
131
132 if (!hideText) {
133 result.push(
134 <RichText.Content
135 tagName="span"
136 className="ghostkit-button-text"
137 value={text}
138 key="button-text"
139 />
140 );
141 }
142
143 // add icon.
144 if (icon) {
145 result.unshift(
146 <IconPicker.Render
147 name={icon}
148 tag="span"
149 className={`ghostkit-button-icon ghostkit-button-icon-${
150 iconPosition === 'right' ? 'right' : 'left'
151 }`}
152 key="button-icon"
153 />
154 );
155 }
156
157 const Tag = tagName || (url ? 'a' : 'span');
158
159 const blockProps = useBlockProps.save({
160 className,
161 ...(Tag === 'a'
162 ? {
163 href: url,
164 target: target || false,
165 rel: rel || false,
166 }
167 : {}),
168 });
169
170 return <Tag {...blockProps}>{result}</Tag>;
171 },
172 },
173 ];
174