From b1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c Mon Sep 17 00:00:00 2001 From: Philipp Tanlak Date: Mon, 24 Nov 2025 20:54:57 +0100 Subject: Docs --- .../tailwindcss/src/util/validateFormalSyntax.js | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 node_modules/tailwindcss/src/util/validateFormalSyntax.js (limited to 'node_modules/tailwindcss/src/util/validateFormalSyntax.js') diff --git a/node_modules/tailwindcss/src/util/validateFormalSyntax.js b/node_modules/tailwindcss/src/util/validateFormalSyntax.js new file mode 100644 index 0000000..d3dafea --- /dev/null +++ b/node_modules/tailwindcss/src/util/validateFormalSyntax.js @@ -0,0 +1,34 @@ +import { length, percentage } from './dataTypes' +import { splitAtTopLevelOnly } from './splitAtTopLevelOnly' + +/** + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/background-size#formal_syntax + * + * background-size = + * # + * + * = + * [ | auto ]{1,2} | + * cover | + * contain + * + * = + * | + * + * + * @param {string} value + */ +export function backgroundSize(value) { + let keywordValues = ['cover', 'contain'] + // the type will probably be a css function + // so we have to use `splitAtTopLevelOnly` + return splitAtTopLevelOnly(value, ',').every((part) => { + let sizes = splitAtTopLevelOnly(part, '_').filter(Boolean) + if (sizes.length === 1 && keywordValues.includes(sizes[0])) return true + + if (sizes.length !== 1 && sizes.length !== 2) return false + + return sizes.every((size) => length(size) || percentage(size) || size === 'auto') + }) +} -- cgit v1.2.3