Skip to content

Commit e386ea5

Browse files
adamwathanphilipp-spiess
authored andcommitted
Support bare col and row utilities
1 parent 124b82b commit e386ea5

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

packages/tailwindcss/src/utilities.test.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,8 @@ test('order', async () => {
10861086
test('col', async () => {
10871087
expect(
10881088
await run([
1089+
'col-11',
1090+
'-col-12',
10891091
'col-auto',
10901092
'col-span-4',
10911093
'col-span-17',
@@ -1094,7 +1096,15 @@ test('col', async () => {
10941096
'col-span-[var(--my-variable)]',
10951097
]),
10961098
).toMatchInlineSnapshot(`
1097-
".col-\\[span_123\\/span_123\\] {
1099+
".-col-12 {
1100+
grid-column: calc(12 * -1);
1101+
}
1102+
1103+
.col-11 {
1104+
grid-column: 11;
1105+
}
1106+
1107+
.col-\\[span_123\\/span_123\\] {
10981108
grid-column: span 123 / span 123;
10991109
}
11001110
@@ -1213,6 +1223,8 @@ test('col-end', async () => {
12131223
test('row', async () => {
12141224
expect(
12151225
await run([
1226+
'row-11',
1227+
'-row-12',
12161228
'row-auto',
12171229
'row-span-4',
12181230
'row-span-17',
@@ -1221,7 +1233,15 @@ test('row', async () => {
12211233
'row-span-[var(--my-variable)]',
12221234
]),
12231235
).toMatchInlineSnapshot(`
1224-
".row-\\[span_123\\/span_123\\] {
1236+
".-row-12 {
1237+
grid-row: calc(12 * -1);
1238+
}
1239+
1240+
.row-11 {
1241+
grid-row: 11;
1242+
}
1243+
1244+
.row-\\[span_123\\/span_123\\] {
12251245
grid-row: span 123 / span 123;
12261246
}
12271247

packages/tailwindcss/src/utilities.ts

+10
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,11 @@ export function createUtilities(theme: Theme) {
651651
*/
652652
staticUtility('col-auto', [['grid-column', 'auto']])
653653
functionalUtility('col', {
654+
supportsNegative: true,
655+
handleBareValue: ({ value }) => {
656+
if (!isPositiveInteger(value)) return null
657+
return value
658+
},
654659
themeKeys: ['--grid-column'],
655660
handle: (value) => [decl('grid-column', value)],
656661
})
@@ -719,6 +724,11 @@ export function createUtilities(theme: Theme) {
719724
*/
720725
staticUtility('row-auto', [['grid-row', 'auto']])
721726
functionalUtility('row', {
727+
supportsNegative: true,
728+
handleBareValue: ({ value }) => {
729+
if (!isPositiveInteger(value)) return null
730+
return value
731+
},
722732
themeKeys: ['--grid-row'],
723733
handle: (value) => [decl('grid-row', value)],
724734
})

0 commit comments

Comments
 (0)