UNPKG

@gechiui/block-editor

Version:
58 lines (51 loc) 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = TextDecorationControl; var _element = require("@gechiui/element"); var _components = require("@gechiui/components"); var _icons = require("@gechiui/icons"); var _i18n = require("@gechiui/i18n"); /** * GeChiUI dependencies */ const TEXT_DECORATIONS = [{ name: (0, _i18n.__)('下划线'), value: 'underline', icon: _icons.formatUnderline }, { name: (0, _i18n.__)('删除线'), value: 'line-through', icon: _icons.formatStrikethrough }]; /** * Control to facilitate text decoration selections. * * @param {Object} props Component props. * @param {string} props.value Currently selected text decoration. * @param {Function} props.onChange Handles change in text decoration selection. * * @return {GCElement} Text decoration control. */ function TextDecorationControl(_ref) { let { value, onChange } = _ref; return (0, _element.createElement)("fieldset", { className: "block-editor-text-decoration-control" }, (0, _element.createElement)("legend", null, (0, _i18n.__)('装饰')), (0, _element.createElement)("div", { className: "block-editor-text-decoration-control__buttons" }, TEXT_DECORATIONS.map(textDecoration => { return (0, _element.createElement)(_components.Button, { key: textDecoration.value, icon: textDecoration.icon, isSmall: true, isPressed: textDecoration.value === value, onClick: () => onChange(textDecoration.value === value ? undefined : textDecoration.value), "aria-label": textDecoration.name }); }))); } //# sourceMappingURL=index.js.map