PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.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
108 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 currentAtRule,
30 } = useBlockStyles();
31
32 const panelProps = {
33 name,
34 attributes,
35 setAttributes,
36 };
37
38 return (
39 <ApplyFilters
40 name="generateblocks.editor.blockControls"
41 blockName={ name }
42 getStyleValue={ getStyleValue }
43 onStyleChange={ onStyleChange }
44 currentAtRule={ currentAtRule }
45 attributes={ attributes }
46 setAttributes={ setAttributes }
47 >
48 <OpenPanel
49 { ...panelProps }
50 shouldRender={ 'a' === tagName && '' === currentAtRule }
51 panelId="link-destination"
52 >
53 <URLControls
54 label={ __( 'Link Destination', 'generateblocks' ) }
55 setAttributes={ setAttributes }
56 htmlAttributes={ htmlAttributes }
57 context={ context }
58 tagName={ tagName }
59 />
60 </OpenPanel>
61
62 <OpenPanel
63 { ...panelProps }
64 shouldRender={ '' === currentAtRule }
65 panelId="inline-background-image"
66 >
67 <InlineBackgroundImage
68 label={ __( 'Inline Background Image', 'generateblocks' ) }
69 htmlAttributes={ htmlAttributes }
70 setAttributes={ setAttributes }
71 styles={ styles }
72 onStyleChange={ onStyleChange }
73 context={ context }
74 />
75 </OpenPanel>
76
77 <OpenPanel
78 { ...panelProps }
79 shouldRender={ '' === currentAtRule }
80 panelId="settings"
81 >
82 <TagNameControl
83 blockName="generateblocks/loop-item"
84 value={ tagName }
85 onChange={ ( value ) => {
86 setAttributes( { tagName: value } );
87
88 if ( 'a' === value && ! styles?.display ) {
89 onStyleChange( 'display', 'block' );
90 }
91 } }
92 />
93
94 { 'a' === tagName && (
95 <BaseControl>
96 <Notice
97 status="warning"
98 isDismissible={ false }
99 >
100 { __( 'This container is now a link element. Be sure not to add any interactive elements inside of it, like buttons or other links.', 'generateblocks' ) }
101 </Notice>
102 </BaseControl>
103 ) }
104 </OpenPanel>
105 </ApplyFilters>
106 );
107 }
108