add gutter to Row and Col

add gutter to Row and Col
This commit is contained in:
梁灏 2016-10-31 22:28:13 +08:00
parent e3a12bd330
commit d2203972af
7 changed files with 105 additions and 26 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
<template> <template>
<div :class="classes"> <div :class="classes" :style="styles">
<slot></slot> <slot></slot>
</div> </div>
</template> </template>
@ -17,6 +17,11 @@
pull: [Number, String], pull: [Number, String],
className: String className: String
}, },
data () {
return {
gutter: 0
}
},
computed: { computed: {
classes () { classes () {
return [ return [
@ -30,6 +35,17 @@
[`${this.className}`]: !!this.className [`${this.className}`]: !!this.className
} }
] ]
},
styles () {
let style = {};
if (this.gutter !== 0) {
style = {
paddingLeft: this.gutter / 2 + 'px',
paddingRight: this.gutter / 2 + 'px'
}
}
return style;
} }
} }
} }

View file

@ -1,5 +1,5 @@
<template> <template>
<div :class="classes"> <div :class="classes" :style="styles">
<slot></slot> <slot></slot>
</div> </div>
</template> </template>
@ -25,6 +25,10 @@
return oneOf(value, ['start', 'end', 'center', 'space-around', 'space-between']); return oneOf(value, ['start', 'end', 'center', 'space-around', 'space-between']);
} }
}, },
gutter: {
type: Number,
default: 0
},
className: String className: String
}, },
computed: { computed: {
@ -38,7 +42,35 @@
[`${this.className}`]: !!this.className [`${this.className}`]: !!this.className
} }
] ]
},
styles () {
let style = {};
if (this.gutter !== 0) {
style = {
marginLeft: this.gutter / -2 + 'px',
marginRight: this.gutter / -2 + 'px'
} }
} }
return style;
}
},
methods: {
updateGutter (val) {
this.$children.forEach((child) => {
if (val !== 0) {
child.gutter = val;
}
});
}
},
watch: {
gutter (val) {
this.updateGutter(val);
}
},
ready () {
this.updateGutter(this.gutter);
}
} }
</script> </script>

View file

@ -2,12 +2,12 @@
@css-prefix : ivu-; @css-prefix : ivu-;
@css-prefix-iconfont : ivu-icon; @css-prefix-iconfont : ivu-icon;
// Color // Color
@primary-color : #0099e5; @primary-color : #3399ff;
@info-color : #2db7f5; @info-color : #2db7f5;
@success-color : #5cb85c; @success-color : #00cc66;
@warning-color : #ff9900;
@error-color : #ff5500; @error-color : #ff5500;
@warning-color : #f0ad4e; @link-color : #3399ff;
@link-color : #0099e5;
@link-hover-color : tint(@link-color, 20%); @link-hover-color : tint(@link-color, 20%);
@link-active-color : shade(@link-color, 5%); @link-active-color : shade(@link-color, 5%);
@selected-color : fade(@primary-color, 90%); @selected-color : fade(@primary-color, 90%);
@ -17,7 +17,7 @@
@body-background : #fff; @body-background : #fff;
@font-family : "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif; @font-family : "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
@code-family : Consolas,Menlo,Courier,monospace; @code-family : Consolas,Menlo,Courier,monospace;
@text-color : #525558; @text-color : #657180;
@font-size-base : 14px; @font-size-base : 14px;
@font-size-small : 12px; @font-size-small : 12px;
@line-height-base : 1.5; @line-height-base : 1.5;
@ -27,8 +27,8 @@
@cursor-disabled : not-allowed; @cursor-disabled : not-allowed;
// Border color // Border color
@border-color-base : #d9d9d9; // outside @border-color-base : #d7dde4; // outside
@border-color-split : #e9e9e9; // inside @border-color-split : #e3e8ee; // inside
// Background color // Background color
@background-color-base : #f7f7f7; // base @background-color-base : #f7f7f7; // base
@ -55,7 +55,7 @@
@btn-border-radius-small: 3px; @btn-border-radius-small: 3px;
@btn-group-border : shade(@primary-color, 5%); @btn-group-border : shade(@primary-color, 5%);
@btn-disable-color : #ccc; @btn-disable-color : #c3cbd6;
@btn-disable-bg : @background-color-base; @btn-disable-bg : @background-color-base;
@btn-disable-border : @border-color-base; @btn-disable-border : @border-color-base;

View file

@ -1,23 +1,54 @@
<style>
.example-demo .ivu-col div{
color: #fff;
padding: 10px 0;
text-align: center;
background: rgba(0, 153, 229, .9);
}
.example-demo .ivu-col:nth-child(odd) div{
background: rgba(0, 153, 229, .7);
}
</style>
<template> <template>
<Card :bordered="true" style="width:300px"> <div class="example-demo">
<template slot="title"> <Row :gutter="16">
<p>放寒假的发货会计师</p> <i-col span="6">
</template> <div>1 | order-4</div>
<a href="#" slot="extra">More</a> </i-col>
</Card> <i-col span="6">
<Card style="width:300px"> <div>1 | order-4</div>
<p>hello</p> </i-col>
<p>hndshf</p> <i-col span="6">
<h3>jfds</h3> <div>1 | order-4</div>
</Card> </i-col>
<i-col span="6">
<div>1 | order-4</div>
</i-col>
</Row>
<Row>
<i-col span="6">
<div>1 | order-4</div>
</i-col>
<i-col span="6">
<div>1 | order-4</div>
</i-col>
<i-col span="6">
<div>1 | order-4</div>
</i-col>
<i-col span="6">
<div>1 | order-4</div>
</i-col>
</Row>
</div>
</template> </template>
<script> <script>
import { Row, Col, Card } from 'iview'; import { Row, iCol, Card } from 'iview';
export default { export default {
components: { components: {
Row, Row,
iCol: Col, iCol,
Card Card
}, },
props: { props: {

View file

@ -29,7 +29,7 @@
<Timeline pending> <Timeline pending>
<Timeline-item color="red">发布3.0版本</Timeline-item> <Timeline-item color="red">发布3.0版本</Timeline-item>
<Timeline-item color="green"> <Timeline-item color="green">
<Icon type="time" slot="dot"></Icon> <Icon type="cloak" slot="dot"></Icon>
发布2.0版本 发布2.0版本
</Timeline-item> </Timeline-item>
<Timeline-item color="#ff6600">发布1.0版本</Timeline-item> <Timeline-item color="#ff6600">发布1.0版本</Timeline-item>