Skip to content

Commit 365cddb

Browse files
authored
Merge pull request #190 from matthewharwood/176-split-check
Support "span X" for shorthand grid{Column,Row}
2 parents ca6c021 + a53e691 commit 365cddb

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

modules/__tests__/createPrefixer-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,21 @@ describe('Static Prefixer', () => {
555555
}
556556
expect(prefix(input)).toEqual(output)
557557
})
558+
559+
it('should expand the shorthand gridRow without a slash', () => {
560+
const input = { gridRow: 'span 3' }
561+
const output = {
562+
gridRow: 'span 3',
563+
}
564+
expect(prefix(input)).toEqual(output)
565+
})
566+
it('should expand the shorthand gridColumn without a slash', () => {
567+
const input = { gridColumn: 'span 3' }
568+
const output = {
569+
gridColumn: 'span 3',
570+
}
571+
expect(prefix(input)).toEqual(output)
572+
})
558573
})
559574
})
560575
})

modules/plugins/grid.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ function isSimplePositionValue(value: any) {
44
return typeof value === 'number' && !isNaN(value)
55
}
66

7+
function isComplexSpanValue(value: string) {
8+
return typeof value === 'string' && value.includes('/')
9+
}
10+
711
const alignmentValues = ['center', 'end', 'start', 'stretch']
812

913
const displayValues = {
@@ -21,7 +25,7 @@ const propertyConverters = {
2125
gridColumn: (value: any, style: Object) => {
2226
if (isSimplePositionValue(value)) {
2327
style.msGridColumn = value
24-
} else {
28+
} else if (isComplexSpanValue(value)) {
2529
const [start, end] = value.split('/')
2630
propertyConverters.gridColumnStart(+start, style)
2731

@@ -31,6 +35,8 @@ const propertyConverters = {
3135
} else {
3236
propertyConverters.gridColumnEnd(+end, style)
3337
}
38+
} else {
39+
propertyConverters.gridColumnStart(value, style)
3440
}
3541
},
3642

@@ -50,7 +56,7 @@ const propertyConverters = {
5056
gridRow: (value: any, style: Object) => {
5157
if (isSimplePositionValue(value)) {
5258
style.msGridRow = value
53-
} else {
59+
} else if (isComplexSpanValue(value)) {
5460
const [start, end] = value.split('/')
5561
propertyConverters.gridRowStart(+start, style)
5662

@@ -60,6 +66,8 @@ const propertyConverters = {
6066
} else {
6167
propertyConverters.gridRowEnd(+end, style)
6268
}
69+
} else {
70+
propertyConverters.gridRowStart(value, style)
6371
}
6472
},
6573

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@
7676
"prettier": "^1.14.2",
7777
"rimraf": "^2.6.2"
7878
}
79-
}
79+
}

0 commit comments

Comments
 (0)