UNPKG

@wordpress/block-library

Version:
40 lines (36 loc) 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = GapStyles; var _blockEditor = require("@wordpress/block-editor"); /** * WordPress dependencies */ function GapStyles({ blockGap, clientId }) { // --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default // gap on the gallery. const fallbackValue = `var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )`; let gapValue = fallbackValue; let column = fallbackValue; let row; // Check for the possibility of split block gap values. See: https://github.com/WordPress/gutenberg/pull/37736 if (!!blockGap) { row = typeof blockGap === 'string' ? (0, _blockEditor.__experimentalGetGapCSSValue)(blockGap) : (0, _blockEditor.__experimentalGetGapCSSValue)(blockGap?.top) || fallbackValue; column = typeof blockGap === 'string' ? (0, _blockEditor.__experimentalGetGapCSSValue)(blockGap) : (0, _blockEditor.__experimentalGetGapCSSValue)(blockGap?.left) || fallbackValue; gapValue = row === column ? row : `${row} ${column}`; } // The unstable gallery gap calculation requires a real value (such as `0px`) and not `0`. const gap = `#block-${clientId} { --wp--style--unstable-gallery-gap: ${column === '0' ? '0px' : column}; gap: ${gapValue} }`; (0, _blockEditor.useStyleOverride)({ css: gap }); return null; } //# sourceMappingURL=gap-styles.js.map