@@ -16,17 +16,24 @@ import {
1616 InspectorStyleControls ,
1717 PanelAdvancedSettings ,
1818 ShadowControl ,
19+ ColorPaletteControl ,
20+ AdvancedToolbarControl ,
21+ BlendModeControl ,
22+ ControlSeparator ,
1923} from '~stackable/components'
2024import {
21- useBlockAttributes ,
25+ useBlockAttributes , useBlockHoverState ,
2226} from '~stackable/hooks'
27+ import { getAttributeName } from '~stackable/util'
2328
2429/**
2530 * WordPress dependencies
2631 */
2732import { useBlockEditContext } from '@wordpress/block-editor'
2833import { useDispatch , useSelect } from '@wordpress/data'
29- import { __ } from '@wordpress/i18n'
34+ import {
35+ sprintf , _x , __ ,
36+ } from '@wordpress/i18n'
3037import { applyFilters } from '@wordpress/hooks'
3138import { useMemo } from '@wordpress/element'
3239
@@ -49,6 +56,7 @@ const Controls = props => {
4956
5057 const { updateBlockAttributes } = useDispatch ( 'core/block-editor' )
5158 const attributes = useBlockAttributes ( clientId )
59+ const [ state ] = useBlockHoverState ( )
5260
5361 // Get the image size urls.
5462 const { imageData } = useSelect ( select => {
@@ -204,6 +212,127 @@ const Controls = props => {
204212 />
205213 }
206214
215+ < ControlSeparator />
216+
217+ < AdvancedToolbarControl
218+ controls = { [
219+ {
220+ value : '' ,
221+ title : __ ( 'Single' , i18n ) ,
222+ } ,
223+ {
224+ value : 'gradient' ,
225+ title : __ ( 'Gradient' , i18n ) ,
226+ } ,
227+ ] }
228+ attribute = "imageOverlayColorType"
229+ fullwidth = { false }
230+ isSmall = { true }
231+ />
232+
233+ < ColorPaletteControl
234+ label = {
235+ attributes . imageOverlayColorType === 'gradient'
236+ ? sprintf ( _x ( '%s #%d' , 'option title' , i18n ) , __ ( 'Overlay Color' , i18n ) , 1 )
237+ : __ ( 'Overlay Color' , i18n )
238+ }
239+ attribute = "imageOverlayColor"
240+ hover = "all"
241+ hasTransparent = { attributes . imageOverlayColorType === 'gradient' }
242+ />
243+ { attributes . imageOverlayColorType === 'gradient' && (
244+ < ColorPaletteControl
245+ label = { sprintf ( _x ( '%s #%d' , 'option title' , i18n ) , __ ( 'Overlay Color' , i18n ) , 2 ) }
246+ attribute = "imageOverlayColor2"
247+ hover = "all"
248+ hasTransparent = { true }
249+ />
250+ ) }
251+
252+ < AdvancedRangeControl
253+ label = { __ ( 'Overlay Opacity' , i18n ) }
254+ attribute = "imageOverlayOpacity"
255+ hover = "all"
256+ min = { 0 }
257+ max = { 1 }
258+ step = { 0.1 }
259+ placeholder = "0.3"
260+ />
261+
262+ < BlendModeControl
263+ label = { __ ( 'Overlay Blend Mode' , i18n ) }
264+ attribute = "imageOverlayBlendMode"
265+ className = "ugb--help-tip-background-blend-mode"
266+ />
267+
268+ { attributes . imageOverlayColorType === 'gradient' && (
269+ < ButtonIconPopoverControl
270+ label = { __ ( 'Gradient Overlay Settings' , i18n ) }
271+ onReset = { ( ) => {
272+ updateBlockAttributes ( clientId , {
273+ [ getAttributeName ( 'imageOverlayGradientDirection' , 'desktop' , state ) ] : '' ,
274+ [ getAttributeName ( 'imageOverlayGradientLocation1' , 'desktop' , state ) ] : '' ,
275+ [ getAttributeName ( 'imageOverlayGradientLocation2' , 'desktop' , state ) ] : '' ,
276+ [ getAttributeName ( 'imageOverlayGradientDirection' , 'tablet' , state ) ] : '' ,
277+ [ getAttributeName ( 'imageOverlayGradientLocation1' , 'tablet' , state ) ] : '' ,
278+ [ getAttributeName ( 'imageOverlayGradientLocation2' , 'tablet' , state ) ] : '' ,
279+ [ getAttributeName ( 'imageOverlayGradientDirection' , 'mobile' , state ) ] : '' ,
280+ [ getAttributeName ( 'imageOverlayGradientLocation1' , 'mobile' , state ) ] : '' ,
281+ [ getAttributeName ( 'imageOverlayGradientLocation2' , 'mobile' , state ) ] : '' ,
282+ } )
283+ } }
284+ allowReset = {
285+ attributes [ getAttributeName ( 'imageOverlayGradientDirection' , 'desktop' , state ) ] ||
286+ attributes [ getAttributeName ( 'imageOverlayGradientLocation1' , 'desktop' , state ) ] ||
287+ attributes [ getAttributeName ( 'imageOverlayGradientLocation2' , 'desktop' , state ) ] ||
288+ attributes [ getAttributeName ( 'imageOverlayGradientDirection' , 'tablet' , state ) ] ||
289+ attributes [ getAttributeName ( 'imageOverlayGradientLocation1' , 'tablet' , state ) ] ||
290+ attributes [ getAttributeName ( 'imageOverlayGradientLocation2' , 'tablet' , state ) ] ||
291+ attributes [ getAttributeName ( 'imageOverlayGradientDirection' , 'mobile' , state ) ] ||
292+ attributes [ getAttributeName ( 'imageOverlayGradientLocation1' , 'mobile' , state ) ] ||
293+ attributes [ getAttributeName ( 'imageOverlayGradientLocation2' , 'mobile' , state ) ]
294+ }
295+ >
296+ < AdvancedRangeControl
297+ label = { __ ( 'Gradient Direction (degrees)' , i18n ) }
298+ attribute = "imageOverlayGradientDirection"
299+ hover = "all"
300+ min = { 0 }
301+ max = { 360 }
302+ step = { 10 }
303+ allowReset = { true }
304+ placeholder = "90"
305+ className = "ugb--help-tip-gradient-direction"
306+ />
307+
308+ < AdvancedRangeControl
309+ label = { sprintf ( __ ( 'Color %d Location' , i18n ) , 1 ) }
310+ attribute = "imageOverlayGradientLocation1"
311+ hover = "all"
312+ sliderMin = { 0 }
313+ max = { 100 }
314+ step = { 1 }
315+ allowReset = { true }
316+ placeholder = "0"
317+ className = "ugb--help-tip-gradient-location"
318+ />
319+
320+ < AdvancedRangeControl
321+ label = { sprintf ( __ ( 'Color %d Location' , i18n ) , 2 ) }
322+ attribute = "imageOverlayGradientLocation2"
323+ hover = "all"
324+ sliderMin = { 0 }
325+ max = { 100 }
326+ step = { 1 }
327+ allowReset = { true }
328+ placeholder = "100"
329+ className = "ugb--help-tip-gradient-location"
330+ />
331+ </ ButtonIconPopoverControl >
332+ ) }
333+
334+ < ControlSeparator />
335+
207336 < AdvancedFocalPointControl
208337 attribute = "imageFocalPoint"
209338 label = { __ ( 'Focal point' , i18n ) }
0 commit comments