From 9805cdf0a718e9c01a5f7b2d9225e9514fc60488 Mon Sep 17 00:00:00 2001 From: ramonjd Date: Thu, 13 Jan 2022 13:42:25 +1100 Subject: [PATCH] Initial commit: experimenting with adding writing mode to layout --- packages/block-editor/src/hooks/layout.js | 43 ++++++++++++++++++++- packages/block-editor/src/hooks/layout.scss | 7 +++- packages/block-editor/src/layouts/flex.js | 6 ++- packages/block-editor/src/layouts/flow.js | 25 ++++++++++-- packages/block-library/src/group/block.json | 4 +- 5 files changed, 77 insertions(+), 8 deletions(-) diff --git a/packages/block-editor/src/hooks/layout.js b/packages/block-editor/src/hooks/layout.js index b2cfde0b5e06cc..20673e763e3e36 100644 --- a/packages/block-editor/src/hooks/layout.js +++ b/packages/block-editor/src/hooks/layout.js @@ -19,6 +19,7 @@ import { } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { useContext, createPortal } from '@wordpress/element'; +import { arrowRight, arrowDown } from '@wordpress/icons'; /** * Internal dependencies @@ -49,6 +50,7 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) { allowSwitching, allowEditing = true, allowInheriting = true, + allowWritingMode, default: defaultBlockLayout, } = layoutBlockSupport; @@ -103,6 +105,25 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) { layoutBlockSupport={ layoutBlockSupport } /> ) } + + { ! inherit && allowWritingMode && ( + { + const newOrientation = + newWritingMode === 'vertical' + ? 'vertical' + : layout.orientation; + setAttributes( { + layout: { + ...layout, + orientation: newOrientation, + writingMode: newWritingMode, + }, + } ); + } } + /> + ) } { ! inherit && layoutType && ( @@ -118,7 +139,7 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) { function LayoutTypeSwitcher( { type, onChange } ) { return ( - + { getLayoutTypes().map( ( { name, label } ) => { return (