tailwindcss/src/util
Robin Malfait 1ec5438448
Improve arbitrary value support (#5568)
* simplify `inset` plugin

* run `prettier` on stub file

* simplify `align` utility

* improve arbitrary support for outline

This will allow us to use `outline-[OUTLINE,OPTIONAL_OFFSET]`

Input:
```html
outline-[2px_solid_black]
```

Output:
```css
.outline-\[2px_solid_black\] {
  outline: 2px solid black;
  outline-offset: 0;
}
```

---

Input:
```html
outline-[2px_solid_black,2px]
```

Output:
```css
.outline-\[2px_solid_black\2c 2px\] {
  outline: 2px solid black;
  outline-offset: 2px;
}
```

* remove default `type`

* simplify createUtilityPlugin, use types directly

* find first matching type when coercing the value

* introduce css data types

Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types

These data types will be used to "guess" the type of an arbitrary value
if there is some ambiguity going on. For example:

```
bg-[#0088cc]      -> This is a `color`  -> `background-color`
bg-[url('...')]   -> This is a `url`    -> `background-image`
```

If you are using css variables, then there is no way of knowing which
type it is referring to, in that case you can be explicit:

```
bg-[color:var(--value)]   -> This is a `color`  -> `background-color`
bg-[url:var(--value)]     -> This is a `url`    -> `background-image`
```

When you explicitly pass a data type, then we bypass the type system and
assume you are right. This is nice in a way because now we don't have to
run all of the guessing type code. On the other hand, you can introduce
runtime issues that we are not able to detect:

```
:root {
  --value: 12px;
}

/* Later... */
bg-[color:var(--value)] -> Assumes `color` -> *eventually* -> `background-color: 12px`
```

* add a bunch of new tests for advanced arbitrary values
2021-09-24 18:45:42 +02:00
..
bigSign.js [WIP] Unify JIT and AOT code paths (#4188) 2021-04-30 10:58:40 -04:00
buildMediaQuery.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
cloneDeep.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
cloneNodes.js JIT: Assign source to nodes inserted into @tailwind directives 2021-05-24 15:08:38 -04:00
color.js Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00
configurePlugins.js Make it possible to enable caretColor and content core plugins in AOT mode (#4548) 2021-06-03 15:27:22 +02:00
createPlugin.js ensure options for plugins are not stale between builds (#2695) 2020-10-28 13:46:12 -04:00
createUtilityPlugin.js Improve arbitrary value support (#5568) 2021-09-24 18:45:42 +02:00
dataTypes.js Improve arbitrary value support (#5568) 2021-09-24 18:45:42 +02:00
defaults.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
escapeClassName.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
escapeCommas.js [WIP] Unify JIT and AOT code paths (#4188) 2021-04-30 10:58:40 -04:00
flattenColorPalette.js Remove AOT (#5340) 2021-09-01 17:13:59 +02:00
getAllConfigs.js Refactor util functions (#2616) 2021-05-10 11:22:47 -04:00
hashConfig.js Ignore unknown types when hashing config 2021-05-06 13:16:32 -04:00
isKeyframeRule.js Fix malformed keyframes when using class variants (#5223) 2021-08-16 12:25:30 -04:00
isPlainObject.js [WIP] Unify JIT and AOT code paths (#4188) 2021-04-30 10:58:40 -04:00
log.js Improve new JIT-compatible CLI (#4558) 2021-06-04 10:28:09 -04:00
nameClass.js Pattern safelisting (#5511) 2021-09-16 14:47:41 +02:00
negateValue.js Simplify negate value (#5389) 2021-09-06 14:26:32 -04:00
parseAnimationValue.js [JIT] Support animation lists (#5252) 2021-08-20 22:39:06 -04:00
parseDependency.js Add glob property to dir-dependency messages (#4539) 2021-06-02 08:59:14 -04:00
parseObjectStyles.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
pluginUtils.js Improve arbitrary value support (#5568) 2021-09-24 18:45:42 +02:00
prefixSelector.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
resolveConfig.js Remove variants related code (#5465) 2021-09-10 09:34:27 -04:00
resolveConfigPath.js Remove log 2021-05-29 14:48:10 -04:00
responsive.js Replaces use of Lodash isArray with built-in Array.isArray 2019-07-13 16:52:07 +02:00
tap.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
toColorValue.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
toPath.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
transformThemeValue.js Replace underscore with space in arbitrary values (#5460) 2021-09-09 18:10:04 +02:00
withAlphaVariable.js Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00