Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Don't reset horizontal padding on date/time pseudo-elements ([#14959](https://github.com/tailwindlabs/tailwindcss/pull/14959))
- Don't emit `calc()` with invalid values for bare values that aren't integers in spacing utilities ([#14962](https://github.com/tailwindlabs/tailwindcss/pull/14962))

## [4.0.0-alpha.32] - 2024-11-11

Expand Down
152 changes: 152 additions & 0 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3861,6 +3861,82 @@ test('translate-x', async () => {
'-translate-x-[var(--value)]/foo',
]),
).toEqual('')

expect(
await compileCss(
css`
@theme {
--spacing: 0.25rem;
}
@tailwind utilities;
`,
['translate-x-full', '-translate-x-full', 'translate-x-px', '-translate-x-[var(--value)]'],
),
).toMatchInlineSnapshot(`
":root {
--spacing: .25rem;
}

.-translate-x-\\[var\\(--value\\)\\] {
--tw-translate-x: calc(var(--value) * -1);
translate: var(--tw-translate-x) var(--tw-translate-y);
}

.-translate-x-full {
--tw-translate-x: -100%;
translate: var(--tw-translate-x) var(--tw-translate-y);
}

.translate-x-full {
--tw-translate-x: 100%;
translate: var(--tw-translate-x) var(--tw-translate-y);
}

.translate-x-px {
--tw-translate-x: 1px;
translate: var(--tw-translate-x) var(--tw-translate-y);
}

@supports (-moz-orient: inline) {
@layer base {
*, :before, :after, ::backdrop {
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-translate-z: 0;
}
}
}

@property --tw-translate-x {
syntax: "<length> | <percentage>";
inherits: false;
initial-value: 0;
}

@property --tw-translate-y {
syntax: "<length> | <percentage>";
inherits: false;
initial-value: 0;
}

@property --tw-translate-z {
syntax: "<length>";
inherits: false;
initial-value: 0;
}"
`)
expect(
await run([
'perspective',
'-perspective',
'perspective-potato',
'perspective-123',
'perspective-normal/foo',
'perspective-dramatic/foo',
'perspective-none/foo',
'perspective-[456px]/foo',
]),
).toEqual('')
})

test('translate-y', async () => {
Expand Down Expand Up @@ -3933,6 +4009,82 @@ test('translate-y', async () => {
'-translate-y-[var(--value)]/foo',
]),
).toEqual('')

expect(
await compileCss(
css`
@theme {
--spacing: 0.25rem;
}
@tailwind utilities;
`,
['translate-y-full', '-translate-y-full', 'translate-y-px', '-translate-y-[var(--value)]'],
),
).toMatchInlineSnapshot(`
":root {
--spacing: .25rem;
}

.-translate-y-\\[var\\(--value\\)\\] {
--tw-translate-y: calc(var(--value) * -1);
translate: var(--tw-translate-x) var(--tw-translate-y);
}

.-translate-y-full {
--tw-translate-y: -100%;
translate: var(--tw-translate-x) var(--tw-translate-y);
}

.translate-y-full {
--tw-translate-y: 100%;
translate: var(--tw-translate-x) var(--tw-translate-y);
}

.translate-y-px {
--tw-translate-y: 1px;
translate: var(--tw-translate-x) var(--tw-translate-y);
}

@supports (-moz-orient: inline) {
@layer base {
*, :before, :after, ::backdrop {
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-translate-z: 0;
}
}
}

@property --tw-translate-x {
syntax: "<length> | <percentage>";
inherits: false;
initial-value: 0;
}

@property --tw-translate-y {
syntax: "<length> | <percentage>";
inherits: false;
initial-value: 0;
}

@property --tw-translate-z {
syntax: "<length>";
inherits: false;
initial-value: 0;
}"
`)
expect(
await run([
'perspective',
'-perspective',
'perspective-potato',
'perspective-123',
'perspective-normal/foo',
'perspective-dramatic/foo',
'perspective-none/foo',
'perspective-[456px]/foo',
]),
).toEqual('')
})

test('translate-z', async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ export function createUtilities(theme: Theme) {
handleNegativeBareValue: ({ value }) => {
let multiplier = theme.resolve(null, ['--spacing'])
if (!multiplier) return null
if (!isValidSpacingMultiplier(value)) return null

return `calc(${multiplier} * -${value})`
},
handle,
Expand Down
1 change: 1 addition & 0 deletions playgrounds/vite/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export function App() {
return (
<div className="m-3 p-3 border">
<h1 className="text-blue-500">Hello World</h1>
<div className="-inset-x-full -inset-y-full -space-x-full -space-y-full -inset-full"></div>
</div>
)
}