Skip to content

Commit

Permalink
Update list of length units (#10100)
Browse files Browse the repository at this point in the history
* Update length units

* Update changelog
  • Loading branch information
thecrypticace committed Dec 16, 2022
1 parent c834da4 commit 51b6224
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Prevent invalid arbitrary variant selectors from failing the build ([#10059](https://github.com/tailwindlabs/tailwindcss/pull/10059))
- Properly handle subtraction followed by a variable ([#10074](https://github.com/tailwindlabs/tailwindcss/pull/10074))
- Fix missing `string[]` in the `theme.dropShadow` types ([#10072](https://github.com/tailwindlabs/tailwindcss/pull/10072))
- Update list of length units ([#10100](https://github.com/tailwindlabs/tailwindcss/pull/10100))

### Changed

Expand Down
18 changes: 18 additions & 0 deletions src/util/dataTypes.js
Expand Up @@ -77,6 +77,9 @@ export function percentage(value) {
return (value.endsWith('%') && number(value.slice(0, -1))) || isCSSFunction(value)
}

// Please refer to MDN when updating this list:
// https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units
let lengthUnits = [
'cm',
'mm',
Expand All @@ -90,10 +93,25 @@ let lengthUnits = [
'ch',
'rem',
'lh',
'rlh',
'vw',
'vh',
'vmin',
'vmax',
'vb',
'vi',
'svw',
'svh',
'lvw',
'lvh',
'dvw',
'dvh',
'cqw',
'cqh',
'cqi',
'cqb',
'cqmin',
'cqmax',
]
let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`
export function length(value) {
Expand Down
3 changes: 3 additions & 0 deletions tests/arbitrary-values.test.css
Expand Up @@ -843,6 +843,9 @@
.text-\[2\.23rem\] {
font-size: 2.23rem;
}
.text-\[4cqw\] {
font-size: 4cqw;
}
.text-\[length\:var\(--font-size\)\] {
font-size: var(--font-size);
}
Expand Down
1 change: 1 addition & 0 deletions tests/arbitrary-values.test.html
Expand Up @@ -284,6 +284,7 @@

<div class="text-[0]"></div>
<div class="text-[2.23rem]"></div>
<div class="text-[4cqw]"></div>
<div class="text-[length:var(--font-size)]"></div>
<div class="text-[angle:var(--angle)]"></div>
<div class="text-[min(10vh,100px)]"></div>
Expand Down

0 comments on commit 51b6224

Please sign in to comment.