UNPKG

@wordpress/block-editor

Version:
65 lines (60 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LayoutProvider = void 0; exports.LayoutStyle = LayoutStyle; exports.defaultLayout = void 0; exports.useLayout = useLayout; var _element = require("@wordpress/element"); var _layouts = require("../../layouts"); var _useSettings = require("../use-settings"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * Internal dependencies */ const defaultLayout = exports.defaultLayout = { type: 'default' }; const Layout = (0, _element.createContext)(defaultLayout); /** * Allows to define the layout. */ const LayoutProvider = exports.LayoutProvider = Layout.Provider; /** * React hook used to retrieve the layout config. */ function useLayout() { return (0, _element.useContext)(Layout); } function LayoutStyle({ layout = {}, css, ...props }) { const layoutType = (0, _layouts.getLayoutType)(layout.type); const [blockGapSupport] = (0, _useSettings.useSettings)('spacing.blockGap'); const hasBlockGapSupport = blockGapSupport !== null; if (layoutType) { if (css) { return /*#__PURE__*/(0, _jsxRuntime.jsx)("style", { children: css }); } const layoutStyle = layoutType.getLayoutStyle?.({ hasBlockGapSupport, layout, ...props }); if (layoutStyle) { return /*#__PURE__*/(0, _jsxRuntime.jsx)("style", { children: layoutStyle }); } } return null; } //# sourceMappingURL=layout.js.map