UNPKG

@wordpress/block-library

Version:
63 lines (62 loc) 2.33 kB
/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { ToolbarButton, ToggleControl, ToolbarGroup, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components'; import { BlockControls, InspectorControls } from '@wordpress/block-editor'; import { edit } from '@wordpress/icons'; /** * Internal dependencies */ import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; function getResponsiveHelp(checked) { return checked ? __('This embed will preserve its aspect ratio when the browser is resized.') : __('This embed may not preserve its aspect ratio when the browser is resized.'); } const EmbedControls = ({ blockSupportsResponsive, showEditButton, themeSupportsResponsive, allowResponsive, toggleResponsive, switchBackToURLInput }) => { const dropdownMenuProps = useToolsPanelDropdownMenuProps(); return /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(BlockControls, { children: /*#__PURE__*/_jsx(ToolbarGroup, { children: showEditButton && /*#__PURE__*/_jsx(ToolbarButton, { className: "components-toolbar__control", label: __('Edit URL'), icon: edit, onClick: switchBackToURLInput }) }) }), themeSupportsResponsive && blockSupportsResponsive && /*#__PURE__*/_jsx(InspectorControls, { children: /*#__PURE__*/_jsx(ToolsPanel, { label: __('Media settings'), resetAll: () => { toggleResponsive(true); }, dropdownMenuProps: dropdownMenuProps, children: /*#__PURE__*/_jsx(ToolsPanelItem, { label: __('Media settings'), isShownByDefault: true, hasValue: () => !allowResponsive, onDeselect: () => { toggleResponsive(!allowResponsive); }, children: /*#__PURE__*/_jsx(ToggleControl, { __nextHasNoMarginBottom: true, label: __('Resize for smaller devices'), checked: allowResponsive, help: getResponsiveHelp, onChange: toggleResponsive }) }) }) })] }); }; export default EmbedControls; //# sourceMappingURL=embed-controls.js.map