Skip to content

Commit 926acd8

Browse files
committed
Use static utilities + a big loop
1 parent bc948a5 commit 926acd8

File tree

3 files changed

+80
-138
lines changed

3 files changed

+80
-138
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,36 @@ exports[`getClassList 1`] = `
12441244
"rotate-45",
12451245
"rotate-6",
12461246
"rotate-90",
1247+
"rounded-b-full",
1248+
"rounded-b-none",
1249+
"rounded-bl-full",
1250+
"rounded-bl-none",
1251+
"rounded-br-full",
1252+
"rounded-br-none",
1253+
"rounded-e-full",
1254+
"rounded-e-none",
1255+
"rounded-ee-full",
1256+
"rounded-ee-none",
1257+
"rounded-es-full",
1258+
"rounded-es-none",
1259+
"rounded-full",
1260+
"rounded-l-full",
1261+
"rounded-l-none",
1262+
"rounded-none",
1263+
"rounded-r-full",
1264+
"rounded-r-none",
1265+
"rounded-s-full",
1266+
"rounded-s-none",
1267+
"rounded-se-full",
1268+
"rounded-se-none",
1269+
"rounded-ss-full",
1270+
"rounded-ss-none",
1271+
"rounded-t-full",
1272+
"rounded-t-none",
1273+
"rounded-tl-full",
1274+
"rounded-tl-none",
1275+
"rounded-tr-full",
1276+
"rounded-tr-none",
12471277
"row-auto",
12481278
"row-end-1",
12491279
"row-end-10",

packages/tailwindcss/src/utilities.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5858,8 +5858,8 @@ test('rounded-s', () => {
58585858
}
58595859
58605860
.rounded-s-full {
5861-
border-start-start-radius: 9999px;
5862-
border-end-start-radius: 9999px;
5861+
border-start-start-radius: 3.40282e38px;
5862+
border-end-start-radius: 3.40282e38px;
58635863
}
58645864
58655865
.rounded-s-none {
@@ -5910,8 +5910,8 @@ test('rounded-e', () => {
59105910
}
59115911
59125912
.rounded-e-full {
5913-
border-start-end-radius: 9999px;
5914-
border-end-end-radius: 9999px;
5913+
border-start-end-radius: 3.40282e38px;
5914+
border-end-end-radius: 3.40282e38px;
59155915
}
59165916
59175917
.rounded-e-none {
@@ -5962,8 +5962,8 @@ test('rounded-t', () => {
59625962
}
59635963
59645964
.rounded-t-full {
5965-
border-top-left-radius: 9999px;
5966-
border-top-right-radius: 9999px;
5965+
border-top-left-radius: 3.40282e38px;
5966+
border-top-right-radius: 3.40282e38px;
59675967
}
59685968
59695969
.rounded-t-none {
@@ -6014,8 +6014,8 @@ test('rounded-r', () => {
60146014
}
60156015
60166016
.rounded-r-full {
6017-
border-top-right-radius: 9999px;
6018-
border-bottom-right-radius: 9999px;
6017+
border-top-right-radius: 3.40282e38px;
6018+
border-bottom-right-radius: 3.40282e38px;
60196019
}
60206020
60216021
.rounded-r-none {
@@ -6066,8 +6066,8 @@ test('rounded-b', () => {
60666066
}
60676067
60686068
.rounded-b-full {
6069-
border-bottom-right-radius: 9999px;
6070-
border-bottom-left-radius: 9999px;
6069+
border-bottom-right-radius: 3.40282e38px;
6070+
border-bottom-left-radius: 3.40282e38px;
60716071
}
60726072
60736073
.rounded-b-none {
@@ -6118,8 +6118,8 @@ test('rounded-l', () => {
61186118
}
61196119
61206120
.rounded-l-full {
6121-
border-top-left-radius: 9999px;
6122-
border-bottom-left-radius: 9999px;
6121+
border-top-left-radius: 3.40282e38px;
6122+
border-bottom-left-radius: 3.40282e38px;
61236123
}
61246124
61256125
.rounded-l-none {
@@ -6168,7 +6168,7 @@ test('rounded-ss', () => {
61686168
}
61696169
61706170
.rounded-ss-full {
6171-
border-start-start-radius: 9999px;
6171+
border-start-start-radius: 3.40282e38px;
61726172
}
61736173
61746174
.rounded-ss-none {
@@ -6221,7 +6221,7 @@ test('rounded-se', () => {
62216221
}
62226222
62236223
.rounded-se-full {
6224-
border-start-end-radius: 9999px;
6224+
border-start-end-radius: 3.40282e38px;
62256225
}
62266226
62276227
.rounded-se-none {
@@ -6274,7 +6274,7 @@ test('rounded-ee', () => {
62746274
}
62756275
62766276
.rounded-ee-full {
6277-
border-end-end-radius: 9999px;
6277+
border-end-end-radius: 3.40282e38px;
62786278
}
62796279
62806280
.rounded-ee-none {
@@ -6327,7 +6327,7 @@ test('rounded-es', () => {
63276327
}
63286328
63296329
.rounded-es-full {
6330-
border-end-start-radius: 9999px;
6330+
border-end-start-radius: 3.40282e38px;
63316331
}
63326332
63336333
.rounded-es-none {
@@ -6380,7 +6380,7 @@ test('rounded-tl', () => {
63806380
}
63816381
63826382
.rounded-tl-full {
6383-
border-top-left-radius: 9999px;
6383+
border-top-left-radius: 3.40282e38px;
63846384
}
63856385
63866386
.rounded-tl-none {
@@ -6433,7 +6433,7 @@ test('rounded-tr', () => {
64336433
}
64346434
64356435
.rounded-tr-full {
6436-
border-top-right-radius: 9999px;
6436+
border-top-right-radius: 3.40282e38px;
64376437
}
64386438
64396439
.rounded-tr-none {
@@ -6486,7 +6486,7 @@ test('rounded-br', () => {
64866486
}
64876487
64886488
.rounded-br-full {
6489-
border-bottom-right-radius: 9999px;
6489+
border-bottom-right-radius: 3.40282e38px;
64906490
}
64916491
64926492
.rounded-br-none {
@@ -6539,7 +6539,7 @@ test('rounded-bl', () => {
65396539
}
65406540
65416541
.rounded-bl-full {
6542-
border-bottom-left-radius: 9999px;
6542+
border-bottom-left-radius: 3.40282e38px;
65436543
}
65446544
65456545
.rounded-bl-none {

packages/tailwindcss/src/utilities.ts

Lines changed: 30 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,125 +1955,37 @@ export function createUtilities(theme: Theme) {
19551955
staticUtility('break-keep', [['word-break', 'break-keep']])
19561956

19571957
{
1958-
function handleBareBorderRadiusValue({ value }: NamedUtilityValue) {
1959-
switch (value) {
1960-
case 'none':
1961-
return '0px'
1962-
case 'full':
1963-
return 'calc(infinity * 1px)'
1964-
default:
1965-
return null
1966-
}
1958+
// border-radius
1959+
for (let [root, properties] of [
1960+
['rounded', ['border-radius']],
1961+
['rounded-s', ['border-start-start-radius', 'border-end-start-radius']],
1962+
['rounded-e', ['border-start-end-radius', 'border-end-end-radius']],
1963+
['rounded-t', ['border-top-left-radius', 'border-top-right-radius']],
1964+
['rounded-r', ['border-top-right-radius', 'border-bottom-right-radius']],
1965+
['rounded-b', ['border-bottom-right-radius', 'border-bottom-left-radius']],
1966+
['rounded-l', ['border-top-left-radius', 'border-bottom-left-radius']],
1967+
['rounded-ss', ['border-start-start-radius']],
1968+
['rounded-se', ['border-start-end-radius']],
1969+
['rounded-ee', ['border-end-end-radius']],
1970+
['rounded-es', ['border-end-start-radius']],
1971+
['rounded-tl', ['border-top-left-radius']],
1972+
['rounded-tr', ['border-top-right-radius']],
1973+
['rounded-br', ['border-bottom-right-radius']],
1974+
['rounded-bl', ['border-bottom-left-radius']],
1975+
] as const) {
1976+
staticUtility(
1977+
`${root}-none`,
1978+
properties.map((property) => [property, '0']),
1979+
)
1980+
staticUtility(
1981+
`${root}-full`,
1982+
properties.map((property) => [property, 'calc(infinity * 1px)']),
1983+
)
1984+
functionalUtility(root, {
1985+
themeKeys: ['--radius'],
1986+
handle: (value) => properties.map((property) => decl(property, value)),
1987+
})
19671988
}
1968-
1969-
// rounded-*
1970-
functionalUtility('rounded', {
1971-
themeKeys: ['--radius'],
1972-
handleBareValue: handleBareBorderRadiusValue,
1973-
handle: (value) => [decl('border-radius', value)],
1974-
})
1975-
1976-
functionalUtility('rounded-s', {
1977-
themeKeys: ['--radius'],
1978-
handleBareValue: handleBareBorderRadiusValue,
1979-
handle: (value) => [
1980-
decl('border-start-start-radius', value),
1981-
decl('border-end-start-radius', value),
1982-
],
1983-
})
1984-
1985-
functionalUtility('rounded-e', {
1986-
themeKeys: ['--radius'],
1987-
handleBareValue: handleBareBorderRadiusValue,
1988-
handle: (value) => [
1989-
decl('border-start-end-radius', value),
1990-
decl('border-end-end-radius', value),
1991-
],
1992-
})
1993-
1994-
functionalUtility('rounded-t', {
1995-
themeKeys: ['--radius'],
1996-
handleBareValue: handleBareBorderRadiusValue,
1997-
handle: (value) => [
1998-
decl('border-top-left-radius', value),
1999-
decl('border-top-right-radius', value),
2000-
],
2001-
})
2002-
2003-
functionalUtility('rounded-r', {
2004-
themeKeys: ['--radius'],
2005-
handleBareValue: handleBareBorderRadiusValue,
2006-
handle: (value) => [
2007-
decl('border-top-right-radius', value),
2008-
decl('border-bottom-right-radius', value),
2009-
],
2010-
})
2011-
2012-
functionalUtility('rounded-b', {
2013-
themeKeys: ['--radius'],
2014-
handleBareValue: handleBareBorderRadiusValue,
2015-
handle: (value) => [
2016-
decl('border-bottom-right-radius', value),
2017-
decl('border-bottom-left-radius', value),
2018-
],
2019-
})
2020-
2021-
functionalUtility('rounded-l', {
2022-
themeKeys: ['--radius'],
2023-
handleBareValue: handleBareBorderRadiusValue,
2024-
handle: (value) => [
2025-
decl('border-top-left-radius', value),
2026-
decl('border-bottom-left-radius', value),
2027-
],
2028-
})
2029-
2030-
functionalUtility('rounded-ss', {
2031-
themeKeys: ['--radius'],
2032-
handleBareValue: handleBareBorderRadiusValue,
2033-
handle: (value) => [decl('border-start-start-radius', value)],
2034-
})
2035-
2036-
functionalUtility('rounded-se', {
2037-
themeKeys: ['--radius'],
2038-
handleBareValue: handleBareBorderRadiusValue,
2039-
handle: (value) => [decl('border-start-end-radius', value)],
2040-
})
2041-
2042-
functionalUtility('rounded-ee', {
2043-
themeKeys: ['--radius'],
2044-
handleBareValue: handleBareBorderRadiusValue,
2045-
handle: (value) => [decl('border-end-end-radius', value)],
2046-
})
2047-
2048-
functionalUtility('rounded-es', {
2049-
themeKeys: ['--radius'],
2050-
handleBareValue: handleBareBorderRadiusValue,
2051-
handle: (value) => [decl('border-end-start-radius', value)],
2052-
})
2053-
2054-
functionalUtility('rounded-tl', {
2055-
themeKeys: ['--radius'],
2056-
handleBareValue: handleBareBorderRadiusValue,
2057-
handle: (value) => [decl('border-top-left-radius', value)],
2058-
})
2059-
2060-
functionalUtility('rounded-tr', {
2061-
themeKeys: ['--radius'],
2062-
handleBareValue: handleBareBorderRadiusValue,
2063-
handle: (value) => [decl('border-top-right-radius', value)],
2064-
})
2065-
2066-
functionalUtility('rounded-br', {
2067-
themeKeys: ['--radius'],
2068-
handleBareValue: handleBareBorderRadiusValue,
2069-
handle: (value) => [decl('border-bottom-right-radius', value)],
2070-
})
2071-
2072-
functionalUtility('rounded-bl', {
2073-
themeKeys: ['--radius'],
2074-
handleBareValue: handleBareBorderRadiusValue,
2075-
handle: (value) => [decl('border-bottom-left-radius', value)],
2076-
})
20771989
}
20781990

20791991
staticUtility('border-solid', [

0 commit comments

Comments
 (0)