Skip to content

Commit f2e8962

Browse files
committed
fix(grid): add responsive grid
1 parent 9146b18 commit f2e8962

1 file changed

Lines changed: 48 additions & 2 deletions

File tree

src/components/grid/column.vue

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ export default {
1414
width: {
1515
type: Number,
1616
default: 1
17+
},
18+
lg: {
19+
type: Number,
20+
default: 0
21+
},
22+
md: {
23+
type: Number,
24+
default: 0
25+
},
26+
sm: {
27+
type: Number,
28+
default: 0
29+
},
30+
xs: {
31+
type: Number,
32+
default: 0
1733
}
1834
},
1935
computed: {
@@ -31,6 +47,10 @@ export default {
3147
style () {
3248
const columns = this.$parent.$props.columns
3349
const gutter = this.$parent.$props.gutter
50+
const xs = this.xs ? this.xs : this.width
51+
const sm = this.sm ? this.sm : this.width
52+
const md = this.md ? this.md : this.width
53+
const lg = this.lg ? this.lg : this.width
3454
3555
return {
3656
'--gutter': `${gutter / 2}px`,
@@ -39,7 +59,15 @@ export default {
3959
'--margin-left': this.offset ? 'var(--marginLeftB)' : `${gutter / 2}px`,
4060
'--widthA': `calc(100% / ${columns} * ${this.width}`,
4161
'--vertical-align': this._verticalAlign,
42-
'--widthB': `calc(var(--widthA) - ${gutter}px)`
62+
'--widthB': `calc(var(--widthA) - ${gutter}px)`,
63+
'--width-xs-pre': `calc(100% / ${columns} * ${xs}`,
64+
'--width-xs': `calc(var(--width-xs-pre) - ${gutter}px)`,
65+
'--width-sm-pre': `calc(100% / ${columns} * ${sm}`,
66+
'--width-sm': `calc(var(--idth-sm-pre) - ${gutter}px)`,
67+
'--width-md-pre': `calc(100% / ${columns} * ${md}`,
68+
'--width-md': `calc(var(--width-md-pre) - ${gutter}px)`,
69+
'--width-lg-pre': `calc(100% / ${columns} * ${lg}`,
70+
'--width-lg': `calc(var(--width-lg-pre) - ${gutter}px)`
4371
}
4472
}
4573
}
@@ -61,8 +89,26 @@ export default {
6189
.w-column {
6290
align-self: var(--vertical-align);
6391
box-sizing: border-box;
64-
flex: 0 0 var(--widthB);
92+
flex: 0 0 var(--width-xs);
6593
margin: 0 var(--gutter);
6694
margin-left: var(--margin-left)
6795
}
96+
97+
@media only screen and (min-width: 768px) {
98+
.w-column {
99+
flex: 0 0 var(--width-sm);
100+
}
101+
}
102+
103+
@media only screen and (min-width: 992px) {
104+
.w-column {
105+
flex: 0 0 var(--width-md);
106+
}
107+
}
108+
109+
@media only screen and (min-width: 1200px) {
110+
.w-column {
111+
flex: 0 0 var(--width-lg);
112+
}
113+
}
68114
</style>

0 commit comments

Comments
 (0)