source: frontend/node_modules/tailwindcss/src/util/validateFormalSyntax.js@ ae6cd79

Last change on this file since ae6cd79 was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1020 bytes
Line 
1import { length, percentage } from './dataTypes'
2import { splitAtTopLevelOnly } from './splitAtTopLevelOnly'
3
4/**
5 *
6 * https://developer.mozilla.org/en-US/docs/Web/CSS/background-size#formal_syntax
7 *
8 * background-size =
9 * <bg-size>#
10 *
11 * <bg-size> =
12 * [ <length-percentage [0,∞]> | auto ]{1,2} |
13 * cover |
14 * contain
15 *
16 * <length-percentage> =
17 * <length> |
18 * <percentage>
19 *
20 * @param {string} value
21 */
22export function backgroundSize(value) {
23 let keywordValues = ['cover', 'contain']
24 // the <length-percentage> type will probably be a css function
25 // so we have to use `splitAtTopLevelOnly`
26 return splitAtTopLevelOnly(value, ',').every((part) => {
27 let sizes = splitAtTopLevelOnly(part, '_').filter(Boolean)
28 if (sizes.length === 1 && keywordValues.includes(sizes[0])) return true
29
30 if (sizes.length !== 1 && sizes.length !== 2) return false
31
32 return sizes.every((size) => length(size) || percentage(size) || size === 'auto')
33 })
34}
Note: See TracBrowser for help on using the repository browser.