Skip to content

Commit 5c5037d

Browse files
adamwathanwongjn
andauthored
Ensure scale utilities support percentages (tailwindlabs#13182)
* Ensure scale utilities support percentages * Update changelog * Fix changelog entry --------- Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com> Co-authored-by: wongjn <11310624+wongjn@users.noreply.github.com>
1 parent 388d1b0 commit 5c5037d

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Ensure `scale-*` utilities support percentage values ([#13182](https://github.com/tailwindlabs/tailwindcss/pull/13182))
1113

1214
## [4.0.0-alpha.7] - 2024-03-08
1315

packages/tailwindcss/src/utilities.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -2607,13 +2607,13 @@ test('scale', () => {
26072607
}
26082608
26092609
@property --tw-scale-x {
2610-
syntax: "<number>";
2610+
syntax: "<number> | <percentage>";
26112611
inherits: false;
26122612
initial-value: 1;
26132613
}
26142614
26152615
@property --tw-scale-y {
2616-
syntax: "<number>";
2616+
syntax: "<number> | <percentage>";
26172617
inherits: false;
26182618
initial-value: 1;
26192619
}"
@@ -2639,13 +2639,13 @@ test('scale-x', () => {
26392639
}
26402640
26412641
@property --tw-scale-x {
2642-
syntax: "<number>";
2642+
syntax: "<number> | <percentage>";
26432643
inherits: false;
26442644
initial-value: 1;
26452645
}
26462646
26472647
@property --tw-scale-y {
2648-
syntax: "<number>";
2648+
syntax: "<number> | <percentage>";
26492649
inherits: false;
26502650
initial-value: 1;
26512651
}"
@@ -2671,13 +2671,13 @@ test('scale-y', () => {
26712671
}
26722672
26732673
@property --tw-scale-x {
2674-
syntax: "<number>";
2674+
syntax: "<number> | <percentage>";
26752675
inherits: false;
26762676
initial-value: 1;
26772677
}
26782678
26792679
@property --tw-scale-y {
2680-
syntax: "<number>";
2680+
syntax: "<number> | <percentage>";
26812681
inherits: false;
26822682
initial-value: 1;
26832683
}"

packages/tailwindcss/src/utilities.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,10 @@ export function createUtilities(theme: Theme) {
13121312
])
13131313

13141314
let scaleProperties = () =>
1315-
atRoot([property('--tw-scale-x', '1', '<number>'), property('--tw-scale-y', '1', '<number>')])
1315+
atRoot([
1316+
property('--tw-scale-x', '1', '<number> | <percentage>'),
1317+
property('--tw-scale-y', '1', '<number> | <percentage>'),
1318+
])
13161319

13171320
/**
13181321
* @css `scale`

packages/tailwindcss/tests/ui.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,18 @@ test('dividers can be added without setting border-style', async ({ page }) => {
221221
expect(await getPropertyValue('#b', 'border-top')).toEqual('4px dashed rgb(0, 0, 0)')
222222
})
223223

224+
test('scale can be a number or percentage', async ({ page }) => {
225+
let { getPropertyValue } = await render(
226+
page,
227+
html`<div id="x" class="scale-[50%] hover:scale-[1.5]">Hello world</div>`,
228+
)
229+
expect(await getPropertyValue('#x', 'scale')).toEqual('0.5')
230+
231+
await page.locator('#x').hover()
232+
233+
expect(await getPropertyValue('#x', 'scale')).toEqual('1.5')
234+
})
235+
224236
// ---
225237

226238
const preflight = fs.readFileSync(path.resolve(__dirname, '..', 'preflight.css'), 'utf-8')

0 commit comments

Comments
 (0)