Skip to content

Commit 7ee4a7c

Browse files
committed
Suport negative values for col-start/col-end utilities
1 parent 04906c8 commit 7ee4a7c

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

packages/tailwindcss/src/utilities.test.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,13 @@ test('col', () => {
701701
})
702702

703703
test('col-start', () => {
704-
expect(run(['col-start-auto', 'col-start-4', 'col-start-99', 'col-start-[123]']))
704+
expect(run(['col-start-auto', 'col-start-4', 'col-start-99', 'col-start-[123]', '-col-start-4']))
705705
.toMatchInlineSnapshot(`
706-
".col-start-4 {
706+
".-col-start-4 {
707+
grid-column-start: calc(4 * -1);
708+
}
709+
710+
.col-start-4 {
707711
grid-column-start: 4;
708712
}
709713
@@ -719,28 +723,33 @@ test('col-start', () => {
719723
grid-column-start: auto;
720724
}"
721725
`)
722-
expect(run(['col-start', '-col-start-4', 'col-start-unknown'])).toEqual('')
726+
expect(run(['col-start', 'col-start-unknown'])).toEqual('')
723727
})
724728

725729
test('col-end', () => {
726-
expect(run(['col-end-auto', 'col-end-4', 'col-end-99', 'col-end-[123]'])).toMatchInlineSnapshot(`
727-
".col-end-4 {
728-
grid-column-end: 4;
729-
}
730+
expect(run(['col-end-auto', 'col-end-4', 'col-end-99', 'col-end-[123]', '-col-end-4']))
731+
.toMatchInlineSnapshot(`
732+
".-col-end-4 {
733+
grid-column-end: calc(4 * -1);
734+
}
730735
731-
.col-end-99 {
732-
grid-column-end: 99;
733-
}
736+
.col-end-4 {
737+
grid-column-end: 4;
738+
}
734739
735-
.col-end-\\[123\\] {
736-
grid-column-end: 123;
737-
}
740+
.col-end-99 {
741+
grid-column-end: 99;
742+
}
738743
739-
.col-end-auto {
740-
grid-column-end: auto;
741-
}"
742-
`)
743-
expect(run(['col-end', '-col-end-4', 'col-end-unknown'])).toEqual('')
744+
.col-end-\\[123\\] {
745+
grid-column-end: 123;
746+
}
747+
748+
.col-end-auto {
749+
grid-column-end: auto;
750+
}"
751+
`)
752+
expect(run(['col-end', 'col-end-unknown'])).toEqual('')
744753
})
745754

746755
test('row', () => {

packages/tailwindcss/src/utilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ export function createUtilities(theme: Theme) {
653653
*/
654654
staticUtility('col-start-auto', [['grid-column-start', 'auto']])
655655
functionalUtility('col-start', {
656+
supportsNegative: true,
656657
handleBareValue: ({ value }) => {
657658
if (!Number.isInteger(Number(value))) return null
658659
return value
@@ -666,6 +667,7 @@ export function createUtilities(theme: Theme) {
666667
*/
667668
staticUtility('col-end-auto', [['grid-column-end', 'auto']])
668669
functionalUtility('col-end', {
670+
supportsNegative: true,
669671
handleBareValue: ({ value }) => {
670672
if (!Number.isInteger(Number(value))) return null
671673
return value

0 commit comments

Comments
 (0)