PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.2
GenerateBlocks v1.8.2
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 / extend / inspector-control / controls / background-panel / index.js
generateblocks / src / extend / inspector-control / controls / background-panel Last commit date
components 2 years ago attributes.js 3 years ago index.js 2 years ago
index.js
107 lines
1 import { __ } from '@wordpress/i18n';
2 import getIcon from '../../../../utils/get-icon';
3 import PanelArea from '../../../../components/panel-area';
4 import ImageUrl from './components/image-url';
5 import { useContext } from '@wordpress/element';
6 import ControlsContext from '../../../../block-context';
7 import UseInlineStyle from './components/use-inline-style';
8 import BackgroundOptions from './components/background-options';
9 import Size from './components/size';
10 import Position from './components/position';
11 import Repeat from './components/repeat';
12 import Attachment from './components/attachment';
13 import GradientControl from '../../../../components/gradient';
14
15 export default function BackgroundPanel( { attributes, setAttributes } ) {
16 const { id, isInQueryLoop, supports: { backgroundPanel } } = useContext( ControlsContext );
17
18 const {
19 bgImage,
20 bgOptions,
21 bgImageInline,
22 useDynamicData,
23 dynamicContentType,
24 isQueryLoopItem,
25 } = attributes;
26
27 return (
28 <PanelArea
29 title={ __( 'Backgrounds', 'generateblocks' ) }
30 initialOpen={ false }
31 icon={ getIcon( 'gradients' ) }
32 className={ 'gblocks-panel-label' }
33 id={ `${ id }Background` }
34 attributes={ attributes }
35 setAttributes={ setAttributes }
36 >
37 { !! backgroundPanel.backgroundImage &&
38 <>
39 <ImageUrl
40 bgImage={ bgImage }
41 setAttributes={ setAttributes }
42 isUsingFeaturedImage={ useDynamicData && '' !== dynamicContentType }
43 />
44
45 { ( !! bgImage || ( useDynamicData && '' !== dynamicContentType ) ) &&
46 <>
47 <UseInlineStyle
48 checked={ !! bgImageInline }
49 disabled={ useDynamicData && '' !== dynamicContentType && ( isQueryLoopItem || isInQueryLoop ) }
50 onChange={ ( value ) => setAttributes( { bgImageInline: value } ) }
51 />
52
53 <BackgroundOptions
54 attributes={ attributes }
55 setAttributes={ setAttributes }
56 />
57
58 <Size
59 value={ bgOptions.size }
60 onChange={ ( nextSize ) => setAttributes( { bgOptions: { size: nextSize } } ) }
61 />
62
63 <Position
64 value={ bgOptions.position }
65 onChange={ ( nextPosition ) => setAttributes( {
66 bgOptions: { position: nextPosition },
67 } ) }
68 />
69
70 <Repeat
71 value={ bgOptions.repeat }
72 onChange={ ( nextRepeat ) => setAttributes( {
73 bgOptions: { repeat: nextRepeat },
74 } ) }
75 />
76
77 <Attachment
78 value={ bgOptions.attachment }
79 onChange={ ( nextAttachment ) => setAttributes( {
80 bgOptions: { attachment: nextAttachment },
81 } ) }
82 />
83 </>
84 }
85 </>
86 }
87
88 { !! backgroundPanel.backgroundGradient &&
89 <GradientControl
90 attributes={ attributes }
91 setAttributes={ setAttributes }
92 attrGradient={ 'gradient' }
93 attrGradientDirection={ 'gradientDirection' }
94 attrGradientColorOne={ 'gradientColorOne' }
95 attrGradientColorStopOne={ 'gradientColorStopOne' }
96 attrGradientColorTwo={ 'gradientColorTwo' }
97 attrGradientColorStopTwo={ 'gradientColorStopTwo' }
98 attrGradientColorOneOpacity={ 'gradientColorOneOpacity' }
99 attrGradientColorTwoOpacity={ 'gradientColorTwoOpacity' }
100 defaultColorOne={ generateBlocksDefaults[ id ].gradientColorOne }
101 defaultColorTwo={ generateBlocksDefaults[ id ].gradientColorTwo }
102 />
103 }
104 </PanelArea>
105 );
106 }
107