Skip to content

Commit b47b6d2

Browse files
authored
Remove double translate-z-px values (#16718)
This PR fixes an issue where if you used `translate-z-px` or `-translate-z-px` that the utility was generated twice: ```css .translate-z-px { --tw-translate-z: 1px; translate: var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z); } .translate-z-px { --tw-translate-z: 1px; translate: var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z); } @Property --tw-translate-x { syntax: "*"; inherits: false; initial-value: 0; } @Property --tw-translate-y { syntax: "*"; inherits: false; initial-value: 0; } @Property --tw-translate-z { syntax: "*"; inherits: false; initial-value: 0; } ``` With this PR, it will only generate once: ```css .translate-z-px { --tw-translate-z: 1px; translate: var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z); } @Property --tw-translate-x { syntax: "*"; inherits: false; initial-value: 0; } @Property --tw-translate-y { syntax: "*"; inherits: false; initial-value: 0; } @Property --tw-translate-z { syntax: "*"; inherits: false; initial-value: 0; } ```
1 parent 113142a commit b47b6d2

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Vite: Ensure utility classes are read without escaping special characters ([#16631](https://github.com/tailwindlabs/tailwindcss/pull/16631))
2525
- Allow `theme(…)` options when using `@import` ([#16514](https://github.com/tailwindlabs/tailwindcss/pull/16514))
2626
- Use amount of properties when sorting ([#16715](https://github.com/tailwindlabs/tailwindcss/pull/16715))
27+
- Remove double generated `translate-z-px` utilities ([#16718](https://github.com/tailwindlabs/tailwindcss/pull/16718))
2728

2829
## [4.0.7] - 2025-02-18
2930

packages/tailwindcss/src/utilities.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4213,16 +4213,22 @@ test('translate-y', async () => {
42134213
})
42144214

42154215
test('translate-z', async () => {
4216-
expect(await run(['translate-z-px', '-translate-z-[var(--value)]'])).toMatchInlineSnapshot(`
4216+
expect(
4217+
await run(['-translate-z-px', 'translate-z-px', '-translate-z-[var(--value)]']),
4218+
).toMatchInlineSnapshot(`
42174219
".-translate-z-\\[var\\(--value\\)\\] {
42184220
--tw-translate-z: calc(var(--value) * -1);
42194221
translate: var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z);
42204222
}
42214223
4224+
.-translate-z-px {
4225+
--tw-translate-z: -1px;
4226+
translate: var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z);
4227+
}
4228+
42224229
.translate-z-px {
42234230
--tw-translate-z: 1px;
42244231
translate: var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z);
4225-
translate: var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z);
42264232
}
42274233
42284234
@property --tw-translate-x {

packages/tailwindcss/src/utilities.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,16 +1230,6 @@ export function createUtilities(theme: Theme) {
12301230
supportsNegative: true,
12311231
},
12321232
)
1233-
staticUtility(`-translate-z-px`, [
1234-
translateProperties,
1235-
[`--tw-translate-z`, '-1px'],
1236-
['translate', 'var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z)'],
1237-
])
1238-
staticUtility(`translate-z-px`, [
1239-
translateProperties,
1240-
[`--tw-translate-z`, '1px'],
1241-
['translate', 'var(--tw-translate-x) var(--tw-translate-y) var(--tw-translate-z)'],
1242-
])
12431233

12441234
staticUtility('translate-3d', [
12451235
translateProperties,

0 commit comments

Comments
 (0)