Skip to content

Commit 5d1e48d

Browse files
authored
Include percent sign in font-stretch utilities (#13158)
Include a percent sign in `font-stretch` utilities (e.g. `font-stretch-50%` rather than `font-stretch-50`) to make the meaning of the value clearer.
1 parent c550a62 commit 5d1e48d

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -714,16 +714,16 @@ exports[`getClassList 1`] = `
714714
"font-medium",
715715
"font-normal",
716716
"font-semibold",
717-
"font-stretch-100",
718-
"font-stretch-105",
719-
"font-stretch-110",
720-
"font-stretch-125",
721-
"font-stretch-150",
722-
"font-stretch-200",
723-
"font-stretch-50",
724-
"font-stretch-75",
725-
"font-stretch-90",
726-
"font-stretch-95",
717+
"font-stretch-100%",
718+
"font-stretch-105%",
719+
"font-stretch-110%",
720+
"font-stretch-125%",
721+
"font-stretch-150%",
722+
"font-stretch-200%",
723+
"font-stretch-50%",
724+
"font-stretch-75%",
725+
"font-stretch-90%",
726+
"font-stretch-95%",
727727
"font-stretch-condensed",
728728
"font-stretch-expanded",
729729
"font-stretch-extra-condensed",

packages/tailwindcss/src/utilities.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8789,13 +8789,13 @@ test('font-style', () => {
87898789
})
87908790

87918791
test('font-stretch', () => {
8792-
expect(run(['font-stretch-ultra-expanded', 'font-stretch-50', 'font-stretch-200']))
8792+
expect(run(['font-stretch-ultra-expanded', 'font-stretch-50%', 'font-stretch-200%']))
87938793
.toMatchInlineSnapshot(`
8794-
".font-stretch-200 {
8794+
".font-stretch-200\\% {
87958795
font-stretch: 200%;
87968796
}
87978797
8798-
.font-stretch-50 {
8798+
.font-stretch-50\\% {
87998799
font-stretch: 50%;
88008800
}
88018801
@@ -8804,7 +8804,13 @@ test('font-stretch', () => {
88048804
}"
88058805
`)
88068806
expect(
8807-
run(['font-stretch', 'font-stretch-20', 'font-stretch-400', 'font-stretch-potato']),
8807+
run([
8808+
'font-stretch',
8809+
'font-stretch-20%',
8810+
'font-stretch-50',
8811+
'font-stretch-400%',
8812+
'font-stretch-potato',
8813+
]),
88088814
).toEqual('')
88098815
})
88108816

packages/tailwindcss/src/utilities.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,17 +2877,18 @@ export function createUtilities(theme: Theme) {
28772877
functionalUtility('font-stretch', {
28782878
themeKeys: [],
28792879
handleBareValue: ({ value }) => {
2880-
let num = Number(value)
2880+
if (!value.endsWith('%')) return null
2881+
let num = Number(value.slice(0, -1))
28812882
// Only 50-200% (inclusive) are valid:
28822883
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch#percentage
28832884
if (Number.isNaN(num) || num < 50 || num > 200) return null
2884-
return `${value}%`
2885+
return value
28852886
},
28862887
handle: (value) => [decl('font-stretch', value)],
28872888
})
28882889
suggest('font-stretch', () => [
28892890
{
2890-
values: ['50', '75', '90', '95', '100', '105', '110', '125', '150', '200'],
2891+
values: ['50%', '75%', '90%', '95%', '100%', '105%', '110%', '125%', '150%', '200%'],
28912892
},
28922893
])
28932894

0 commit comments

Comments
 (0)