PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.2.0
GenerateBlocks v2.2.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / loop-item / components / BlockSettings.jsx
generateblocks / src / blocks / loop-item / components Last commit date
BlockSettings.jsx 1 year ago
BlockSettings.jsx
113 lines
1 import { __ } from '@wordpress/i18n';
2 import { BaseControl, Notice } from '@wordpress/components';
3
4 import { OpenPanel } from '@edge22/components';
5
6 import {
7 ApplyFilters,
8 URLControls,
9 TagNameControl,
10 } from '@components/index.js';
11 import { useBlockStyles } from '@hooks/useBlockStyles';
12 import { InlineBackgroundImage } from '../../element/components/InlineBackgroundImage';
13
14 export function BlockSettings( {
15 getStyleValue,
16 onStyleChange,
17 name,
18 attributes,
19 setAttributes,
20 htmlAttributes,
21 styles,
22 context,
23 } ) {
24 const {
25 tagName,
26 } = attributes;
27
28 const {
29 atRule,
30 } = useBlockStyles();
31
32 const panelProps = {
33 name,
34 attributes,
35 setAttributes,
36 getStyleValue,
37 onStyleChange,
38 };
39
40 return (
41 <ApplyFilters
42 name="generateblocks.editor.blockControls"
43 blockName={ name }
44 getStyleValue={ getStyleValue }
45 onStyleChange={ onStyleChange }
46 currentAtRule={ atRule }
47 attributes={ attributes }
48 setAttributes={ setAttributes }
49 >
50 <OpenPanel
51 { ...panelProps }
52 shouldRender={ 'a' === tagName && '' === atRule }
53 panelId="link-destination"
54 >
55 <URLControls
56 label={ __( 'Link Destination', 'generateblocks' ) }
57 setAttributes={ setAttributes }
58 htmlAttributes={ htmlAttributes }
59 context={ context }
60 tagName={ tagName }
61 />
62 </OpenPanel>
63
64 <OpenPanel
65 { ...panelProps }
66 shouldRender={ '' === atRule }
67 panelId="inline-background-image"
68 >
69 <InlineBackgroundImage
70 label={ __( 'Inline Background Image', 'generateblocks' ) }
71 htmlAttributes={ htmlAttributes }
72 setAttributes={ setAttributes }
73 styles={ styles }
74 onStyleChange={ onStyleChange }
75 context={ context }
76 />
77 </OpenPanel>
78
79 <OpenPanel
80 { ...panelProps }
81 panelId="settings"
82 >
83 { '' === atRule && (
84 <>
85 <TagNameControl
86 blockName="generateblocks/loop-item"
87 value={ tagName }
88 onChange={ ( value ) => {
89 setAttributes( { tagName: value } );
90
91 if ( 'a' === value && ! styles?.display ) {
92 onStyleChange( 'display', 'block' );
93 }
94 } }
95 />
96
97 { 'a' === tagName && (
98 <BaseControl>
99 <Notice
100 status="warning"
101 isDismissible={ false }
102 >
103 { __( 'This container is now a link element. Be sure not to add any interactive elements inside of it, like buttons or other links.', 'generateblocks' ) }
104 </Notice>
105 </BaseControl>
106 ) }
107 </>
108 ) }
109 </OpenPanel>
110 </ApplyFilters>
111 );
112 }
113