Skip to content

Commit

Permalink
Remove bare value handling for perspective utilities (#13288)
Browse files Browse the repository at this point in the history
* Remove bare value handling for perspective utilities

* move `perspective-123` example

This is now moved to the spot where we ensure that nothing is generated
at all. This prevents us from accidentally updating a snapshot and
missing a potential bug.

* update changelog

---------

Co-authored-by: Adam Wathan <[email protected]>
Co-authored-by: Robin Malfait <[email protected]>
  • Loading branch information
3 people authored Mar 20, 2024
1 parent d25fe81 commit 89a0b86
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add `inherit` as a universal color ([#13258](https://github.com/tailwindlabs/tailwindcss/pull/13258))
- Add 3D transform utilities ([#13248](https://github.com/tailwindlabs/tailwindcss/pull/13248))
- Add 3D transform utilities ([#13248](https://github.com/tailwindlabs/tailwindcss/pull/13248), [#13288](https://github.com/tailwindlabs/tailwindcss/pull/13288))

### Fixed

Expand Down
14 changes: 2 additions & 12 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3128,24 +3128,14 @@ test('perspective', () => {
}
@tailwind utilities;
`,
[
'perspective-normal',
'perspective-dramatic',
'perspective-none',
'perspective-123',
'perspective-[456px]',
],
['perspective-normal', 'perspective-dramatic', 'perspective-none', 'perspective-[456px]'],
),
).toMatchInlineSnapshot(`
":root {
--perspective-dramatic: 100px;
--perspective-normal: 500px;
}
.perspective-123 {
perspective: 123px;
}
.perspective-\\[456px\\] {
perspective: 456px;
}
Expand All @@ -3162,7 +3152,7 @@ test('perspective', () => {
perspective: 500px;
}"
`)
expect(run(['perspective', '-perspective', 'perspective-potato'])).toEqual('')
expect(run(['perspective', '-perspective', 'perspective-potato', 'perspective-123'])).toEqual('')
})

test('cursor', () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1501,10 +1501,6 @@ export function createUtilities(theme: Theme) {
staticUtility('perspective-none', [['perspective', 'none']])
functionalUtility('perspective', {
themeKeys: ['--perspective'],
handleBareValue: ({ value }) => {
if (!Number.isInteger(Number(value))) return null
return `${value}px`
},
handle: (value) => [decl('perspective', value)],
})

Expand Down

0 comments on commit 89a0b86

Please sign in to comment.