UNPKG

@wordpress/block-editor

Version:
57 lines (55 loc) 1.72 kB
/** * External dependencies */ import clsx from 'clsx'; /** * WordPress dependencies */ import { __, isRTL } from '@wordpress/i18n'; import { textHorizontal, textVertical } from '@wordpress/icons'; import { __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon } from '@wordpress/components'; import { jsx as _jsx } from "react/jsx-runtime"; const WRITING_MODES = [{ label: __('Horizontal'), value: 'horizontal-tb', icon: textHorizontal }, { label: __('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 {Element} Writing Mode control. */ export default function WritingModeControl({ className, value, onChange }) { return /*#__PURE__*/_jsx(ToggleGroupControl, { isDeselectable: true, __nextHasNoMarginBottom: true, __next40pxDefaultSize: true, label: __('Orientation'), className: clsx('block-editor-writing-mode-control', className), value: value, onChange: newValue => { onChange(newValue === value ? undefined : newValue); }, children: WRITING_MODES.map(option => { return /*#__PURE__*/_jsx(ToggleGroupControlOptionIcon, { value: option.value, icon: option.icon, label: option.label }, option.value); }) }); } //# sourceMappingURL=index.js.map