UNPKG

@wordpress/components

Version:
32 lines (31 loc) • 1.29 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); // packages/components/src/font-size-picker/utils.ts /** * Some themes use css vars for their font sizes, so until we * have the way of calculating them don't display them. * * @param value The value that is checked. * @return Whether the value is a simple css value. */ function isSimpleCssValue(value) { return /^[\d\.]+(px|em|rem|vw|vh|%|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cqw|cqh|cqi|cqb|cqmin|cqmax)?$/i.test(String(value)); } /** * Generates hint text for a font size. * This function returns the hint provided by the consumer, if any. * If no hint is provided, it falls back to showing the size value for simple CSS values. * * @param fontSize The font size object to generate hint text for. * @return The hint text provided by the consumer, or the size value for simple CSS values, or undefined. */ function generateFontSizeHint(fontSize) { if (fontSize.hint) return fontSize.hint; if (isSimpleCssValue(fontSize.size)) return String(fontSize.size); } exports.generateFontSizeHint = generateFontSizeHint; exports.isSimpleCssValue = isSimpleCssValue; //# sourceMappingURL=utils.cjs.map