@@ -55,8 +55,12 @@ const ALIGN_OPTIONS_NO_JUSTIFY = ALIGN_OPTIONS.filter( option => option.align !=
5555export const Edit = memo ( props => {
5656 const {
5757 contentAlign,
58+ contentAlignTablet,
59+ contentAlignMobile,
5860 columnJustify,
5961 innerBlockOrientation,
62+ innerBlockOrientationTablet,
63+ innerBlockOrientationMobile,
6064 innerBlockWrap,
6165 containerWidth,
6266 containerWidthTablet,
@@ -67,8 +71,12 @@ export const Edit = memo( props => {
6771 } = useBlockAttributesContext ( attributes => {
6872 return {
6973 contentAlign : attributes . contentAlign ,
74+ contentAlignTablet : attributes . contentAlignTablet ,
75+ contentAlignMobile : attributes . contentAlignMobile ,
7076 columnJustify : attributes . columnJustify ,
7177 innerBlockOrientation : attributes . innerBlockOrientation ,
78+ innerBlockOrientationTablet : attributes . innerBlockOrientationTablet ,
79+ innerBlockOrientationMobile : attributes . innerBlockOrientationMobile ,
7280 innerBlockWrap : attributes . innerBlockWrap ,
7381 containerWidth : attributes . containerWidth ,
7482 containerWidthTablet : attributes . containerWidthTablet ,
@@ -81,6 +89,14 @@ export const Edit = memo( props => {
8189 const setAttributes = useBlockSetAttributesContext ( )
8290 const deviceType = useDeviceType ( )
8391
92+ const _contentAlignTablet = contentAlignTablet || contentAlign
93+ const _contentAlignMobile = contentAlignMobile || _contentAlignTablet
94+
95+ const _innerBlockOrientationTablet = innerBlockOrientationTablet || innerBlockOrientation
96+ const _innerBlockOrientationMobile = innerBlockOrientationMobile || _innerBlockOrientationTablet
97+
98+ const _innerBlockOrientation = deviceType === 'Desktop' ? innerBlockOrientation : ( deviceType === 'Tablet' ? _innerBlockOrientationTablet : _innerBlockOrientationMobile )
99+
84100 const {
85101 labelContentAlign = sprintf ( __ ( '%s Alignment' , i18n ) , __ ( 'Content' , i18n ) ) ,
86102 enableContentAlign = true ,
@@ -140,8 +156,16 @@ export const Edit = memo( props => {
140156 < >
141157 < BlockControls >
142158 < AlignmentToolbar
143- value = { contentAlign }
144- onChange = { contentAlign => setAttributes ( { contentAlign } ) }
159+ value = { deviceType === 'Desktop' ? contentAlign : ( deviceType === 'Tablet' ? _contentAlignTablet : _contentAlignMobile ) }
160+ onChange = { contentAlign => {
161+ if ( deviceType === 'Desktop' ) {
162+ setAttributes ( { contentAlign } )
163+ } else if ( deviceType === 'Tablet' ) {
164+ setAttributes ( { contentAlignTablet : contentAlign } )
165+ } else {
166+ setAttributes ( { contentAlignMobile : contentAlign } )
167+ }
168+ } }
145169 alignmentControls = { props . hasContentJustify ? ALIGN_OPTIONS : ALIGN_OPTIONS_NO_JUSTIFY }
146170 />
147171
@@ -220,19 +244,53 @@ export const Edit = memo( props => {
220244 title : __ ( 'Horizontal' , i18n ) ,
221245 } ,
222246 {
223- value : '' ,
247+ value : 'vertical ' ,
224248 title : __ ( 'Vertical' , i18n ) ,
225249 } ,
226250 ] }
227251 attribute = "innerBlockOrientation"
252+ responsive = "all"
253+ value = { _innerBlockOrientation }
254+ default = "vertical"
228255 onChange = { value => {
229- const newAttributes = {
230- innerBlockOrientation : value ,
256+ const newAttributes = { }
257+
258+ if ( deviceType === 'Desktop' ) {
259+ newAttributes . innerBlockOrientation = value
260+ } else if ( deviceType === 'Tablet' && innerBlockOrientation === value ) {
261+ newAttributes . innerBlockOrientationTablet = ''
262+ } else if ( deviceType === 'Tablet' ) {
263+ newAttributes . innerBlockOrientationTablet = value
264+ } else if ( deviceType === 'Mobile' && _innerBlockOrientationTablet === value ) {
265+ newAttributes . innerBlockOrientationMobile = ''
266+ } else if ( deviceType === 'Mobile' ) {
267+ newAttributes . innerBlockOrientationMobile = value
231268 }
232- if ( value === '' ) { // Vertical.
233- newAttributes . innerBlockJustify = ''
269+
270+ if ( value === 'vertical' ) { // Vertical.
271+ if ( deviceType === 'Desktop' ) {
272+ newAttributes . innerBlockJustify = ''
273+ }
274+
275+ if ( deviceType === 'Tablet' || ( deviceType === 'Desktop' && ! innerBlockOrientationTablet ) ) {
276+ newAttributes . innerBlockJustifyTablet = ''
277+ }
278+
279+ if ( deviceType === 'Mobile' || ( deviceType === 'Desktop' && ! innerBlockOrientationTablet && ! innerBlockOrientationMobile ) || ( deviceType === 'Tablet' && ! innerBlockOrientationMobile ) ) {
280+ newAttributes . innerBlockJustifyMobile = ''
281+ }
234282 } else { // Horizontal
235- newAttributes . innerBlockAlign = ''
283+ if ( deviceType === 'Desktop' ) {
284+ newAttributes . innerBlockAlign = ''
285+ }
286+
287+ if ( deviceType === 'Tablet' || ( deviceType === 'Desktop' && ! innerBlockOrientationTablet ) ) {
288+ newAttributes . innerBlockAlignTablet = ''
289+ }
290+
291+ if ( deviceType === 'Mobile' || ( deviceType === 'Desktop' && ! innerBlockOrientationTablet && ! innerBlockOrientationMobile ) || ( deviceType === 'Tablet' && ! innerBlockOrientationMobile ) ) {
292+ newAttributes . innerBlockAlignMobile = ''
293+ }
236294 }
237295 setAttributes ( newAttributes )
238296 } }
@@ -243,7 +301,7 @@ export const Edit = memo( props => {
243301 label = { sprintf ( __ ( '%s Justify' , i18n ) , __ ( 'Inner Block' , i18n ) ) }
244302 attribute = "innerBlockJustify"
245303 responsive = "all"
246- controls = { innerBlockOrientation ? 'flex-horizontal' : 'horizontal' }
304+ controls = { _innerBlockOrientation === 'horizontal' ? 'flex-horizontal' : 'horizontal' }
247305 visualGuide = { {
248306 selector : '.stk-%s-container, .stk-%s-container > * > .block-editor-block-list__layout > [data-type]' ,
249307 highlight : 'outline-first-offset' ,
@@ -259,7 +317,7 @@ export const Edit = memo( props => {
259317 label = { sprintf ( __ ( '%s Alignment' , i18n ) , __ ( 'Inner Block' , i18n ) ) }
260318 attribute = "innerBlockAlign"
261319 responsive = "all"
262- controls = { innerBlockOrientation ? 'vertical' : 'flex-justify-vertical' }
320+ controls = { _innerBlockOrientation === 'horizontal' ? 'vertical' : 'flex-justify-vertical' }
263321 disabled = { alignLastBlockToBottom ? 'all' : undefined }
264322 visualGuide = { {
265323 selector : '.stk-%s-container, .stk-%s-container > * > .block-editor-block-list__layout > [data-type]' ,
@@ -272,7 +330,7 @@ export const Edit = memo( props => {
272330 help = { __ ( 'Set Content Min. Height for alignment to display properly' , i18n ) }
273331 />
274332 }
275- { innerBlockOrientation &&
333+ { _innerBlockOrientation &&
276334 < AdvancedToolbarControl
277335 label = { __ ( 'Inner Block Wrapping' , i18n ) }
278336 controls = { [
@@ -288,7 +346,7 @@ export const Edit = memo( props => {
288346 attribute = "innerBlockWrap"
289347 />
290348 }
291- { innerBlockOrientation && // This is "column gap" when the blocks are horizontal.
349+ { _innerBlockOrientation && // This is "column gap" when the blocks are horizontal.
292350 < AdvancedRangeControl
293351 label = { innerBlockWrap === 'wrap'
294352 ? sprintf ( __ ( '%s %s' , i18n ) , __ ( 'Inner Block' , i18n ) , __ ( 'Column Gap' , i18n ) )
@@ -314,7 +372,7 @@ export const Edit = memo( props => {
314372 }
315373 />
316374 }
317- { ( props . hasColumnAlignment || props . hasBlockAlignment ) && ! innerBlockOrientation && // This is "row gap" when the blocks are vertical.
375+ { ( props . hasColumnAlignment || props . hasBlockAlignment ) && _innerBlockOrientation !== 'horizontal' && // This is "row gap" when the blocks are vertical.
318376 < AdvancedRangeControl
319377 label = { sprintf ( __ ( '%s %s' , i18n ) , __ ( 'Inner Block' , i18n ) , __ ( 'Gap' , i18n ) ) }
320378 responsive = "all"
@@ -333,7 +391,7 @@ export const Edit = memo( props => {
333391 } }
334392 />
335393 }
336- { ( innerBlockOrientation && innerBlockWrap === 'wrap' ) &&
394+ { ( _innerBlockOrientation === 'horizontal' && innerBlockWrap === 'wrap' ) &&
337395 < AdvancedRangeControl
338396 label = { sprintf ( __ ( '%s %s' , i18n ) , __ ( 'Inner Block' , i18n ) , __ ( 'Row Gap' , i18n ) ) }
339397 responsive = "all"
0 commit comments