-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Typography: text orientation (writing mode) (#50822)
* Add Typography: text orientation (writing mode) * fix spacing CS issues * try to fix white space issue * Rename text orientation to writing mode * Add new text orientation icons
- Loading branch information
Showing
23 changed files
with
229 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/block-editor/src/components/writing-mode-control/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { BaseControl, Button } from '@wordpress/components'; | ||
import { __, isRTL } from '@wordpress/i18n'; | ||
import { textHorizontal, textVertical } from '@wordpress/icons'; | ||
|
||
const WRITING_MODES = [ | ||
{ | ||
name: __( 'Horizontal' ), | ||
value: 'horizontal-tb', | ||
icon: textHorizontal, | ||
}, | ||
{ | ||
name: __( 'Vertical' ), | ||
value: isRTL() ? 'vertical-lr' : 'vertical-rl', | ||
icon: textVertical, | ||
}, | ||
]; | ||
|
||
/** | ||
* Control to facilitate writing mode selections. | ||
* | ||
* @param {Object} props Component props. | ||
* @param {string} props.className Class name to add to the control. | ||
* @param {string} props.value Currently selected writing mode. | ||
* @param {Function} props.onChange Handles change in the writing mode selection. | ||
* | ||
* @return {WPElement} Writing Mode control. | ||
*/ | ||
export default function WritingModeControl( { className, value, onChange } ) { | ||
return ( | ||
<fieldset | ||
className={ classnames( | ||
'block-editor-writing-mode-control', | ||
className | ||
) } | ||
> | ||
<BaseControl.VisualLabel as="legend"> | ||
{ __( 'Orientation' ) } | ||
</BaseControl.VisualLabel> | ||
<div className="block-editor-writing-mode-control__buttons"> | ||
{ WRITING_MODES.map( ( writingMode ) => { | ||
return ( | ||
<Button | ||
key={ writingMode.value } | ||
icon={ writingMode.icon } | ||
label={ writingMode.name } | ||
isPressed={ writingMode.value === value } | ||
onClick={ () => { | ||
onChange( | ||
writingMode.value === value | ||
? undefined | ||
: writingMode.value | ||
); | ||
} } | ||
/> | ||
); | ||
} ) } | ||
</div> | ||
</fieldset> | ||
); | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/block-editor/src/components/writing-mode-control/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.block-editor-writing-mode-control { | ||
border: 0; | ||
margin: 0; | ||
padding: 0; | ||
|
||
.block-editor-writing-mode-control__buttons { | ||
// 4px of padding makes the row 40px high, same as an input. | ||
padding: $grid-unit-05 0; | ||
display: flex; | ||
} | ||
|
||
.components-button.has-icon { | ||
height: $grid-unit-40; | ||
margin-right: $grid-unit-05; | ||
min-width: $grid-unit-40; | ||
padding: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
56ebbcb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 56ebbcb.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5399720523
📝 Reported issues:
/test/e2e/specs/editor/blocks/image.spec.js