Merge pull request #3275 from xiaofengsha/pr004
参照AntDesign,实现了Vue版本的Divider分割线组件
This commit is contained in:
commit
32fd4ffa06
8 changed files with 281 additions and 1 deletions
|
@ -64,6 +64,7 @@ nav {
|
||||||
<li><router-link to="/color-picker">ColorPicker</router-link></li>
|
<li><router-link to="/color-picker">ColorPicker</router-link></li>
|
||||||
<li><router-link to="/auto-complete">AutoComplete</router-link></li>
|
<li><router-link to="/auto-complete">AutoComplete</router-link></li>
|
||||||
<li><router-link to="/scroll">Scroll</router-link></li>
|
<li><router-link to="/scroll">Scroll</router-link></li>
|
||||||
|
<li><router-link to="/divider">Divider</router-link></li>
|
||||||
<li><router-link to="/time">Time</router-link></li>
|
<li><router-link to="/time">Time</router-link></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -211,6 +211,10 @@ const router = new VueRouter({
|
||||||
path: '/scroll',
|
path: '/scroll',
|
||||||
component: (resolve) => require(['./routers/scroll.vue'], resolve)
|
component: (resolve) => require(['./routers/scroll.vue'], resolve)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/divider',
|
||||||
|
component: (resolve) => require(['./routers/divider.vue'], resolve)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/time',
|
path: '/time',
|
||||||
component: (resolve) => require(['./routers/time.vue'], resolve)
|
component: (resolve) => require(['./routers/time.vue'], resolve)
|
||||||
|
|
65
examples/routers/divider.vue
Normal file
65
examples/routers/divider.vue
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<template>
|
||||||
|
<Row :gutter="16">
|
||||||
|
<Col span="12">
|
||||||
|
<Card title="horizontal divider">
|
||||||
|
<div>
|
||||||
|
<p>iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.</p>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<p>iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.</p>
|
||||||
|
|
||||||
|
<Divider>iView </Divider>
|
||||||
|
|
||||||
|
<p>iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.</p>
|
||||||
|
|
||||||
|
<Divider dashed />
|
||||||
|
|
||||||
|
<p>iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.</p>
|
||||||
|
|
||||||
|
<Divider orientation="left">iView</Divider>
|
||||||
|
|
||||||
|
<p>iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.</p>
|
||||||
|
|
||||||
|
<Divider orientation="right">iView</Divider>
|
||||||
|
|
||||||
|
<p>iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.
|
||||||
|
iView is a set of UI components and widgets built on Vue.js.</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
<Col span="12">
|
||||||
|
<Card title="vertical divider">
|
||||||
|
<div>
|
||||||
|
iView
|
||||||
|
<Divider type="vertical divider" />
|
||||||
|
<a href="#">Components</a>
|
||||||
|
<Divider type="vertical" />
|
||||||
|
<a href="#">Divider</a>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
61
src/components/divider/divider.vue
Normal file
61
src/components/divider/divider.vue
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<template>
|
||||||
|
<div :class="classes">
|
||||||
|
<span v-if="hasSlot" :class="slotClasses">
|
||||||
|
<slot></slot>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { oneOf } from '../../utils/assist';
|
||||||
|
|
||||||
|
const prefixCls = 'ivu-divider';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name:'Divider',
|
||||||
|
props: {
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default() { return 'horizontal'; },
|
||||||
|
validator (value) {
|
||||||
|
return oneOf(value, ['horizontal', 'vertical']);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
orientation: {
|
||||||
|
type: String,
|
||||||
|
default() { return 'left'; },
|
||||||
|
validator (value) {
|
||||||
|
return oneOf(value, ['left', 'right']);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dashed:{
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
hasSlot() {
|
||||||
|
return !!this.$slots.default;
|
||||||
|
},
|
||||||
|
classes() {
|
||||||
|
return [
|
||||||
|
`${prefixCls}`,
|
||||||
|
`${prefixCls}-${this.type}`,
|
||||||
|
{
|
||||||
|
[`${prefixCls}-with-text-${this.orientation}`]: this.hasSlot,
|
||||||
|
[`${prefixCls}-dashed`]: !!this.dashed
|
||||||
|
}
|
||||||
|
];
|
||||||
|
},
|
||||||
|
slotClasses() {
|
||||||
|
return [
|
||||||
|
`${prefixCls}-inner-text`,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
3
src/components/divider/index.js
Normal file
3
src/components/divider/index.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import Divider from './divider.vue';
|
||||||
|
|
||||||
|
export default Divider;
|
|
@ -54,6 +54,7 @@ import Tree from './components/tree';
|
||||||
import Upload from './components/upload';
|
import Upload from './components/upload';
|
||||||
import {Row, Col} from './components/grid';
|
import {Row, Col} from './components/grid';
|
||||||
import {Select, Option, OptionGroup} from './components/select';
|
import {Select, Option, OptionGroup} from './components/select';
|
||||||
|
import Divider from './components/divider';
|
||||||
import locale from './locale/index';
|
import locale from './locale/index';
|
||||||
|
|
||||||
const components = {
|
const components = {
|
||||||
|
@ -128,7 +129,8 @@ const components = {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Transfer,
|
Transfer,
|
||||||
Tree,
|
Tree,
|
||||||
Upload
|
Upload,
|
||||||
|
Divider
|
||||||
};
|
};
|
||||||
|
|
||||||
const iview = {
|
const iview = {
|
||||||
|
|
143
src/styles/components/divider.less
Normal file
143
src/styles/components/divider.less
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
|
||||||
|
|
||||||
|
@divider-prefix-cls: ~"@{css-prefix}divider";
|
||||||
|
|
||||||
|
@font-size-base : 14px;
|
||||||
|
@font-size-lg : @font-size-base + 2px;
|
||||||
|
@heading-color : fade(#000, 85%);
|
||||||
|
|
||||||
|
.reset-component() {
|
||||||
|
font-family: @font-family;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
line-height: @line-height-base;
|
||||||
|
color: @text-color;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.@{divider-prefix-cls} {
|
||||||
|
.reset-component;
|
||||||
|
background: @border-color-split;
|
||||||
|
|
||||||
|
&, // for compatiable
|
||||||
|
&-vertical {
|
||||||
|
margin: 0 8px;
|
||||||
|
display: inline-block;
|
||||||
|
height: 0.9em;
|
||||||
|
width: 1px;
|
||||||
|
vertical-align: middle;
|
||||||
|
position: relative;
|
||||||
|
top: -0.06em;
|
||||||
|
}
|
||||||
|
&-horizontal {
|
||||||
|
display: block;
|
||||||
|
height: 1px;
|
||||||
|
width: 100%;
|
||||||
|
margin: 24px 0;
|
||||||
|
}
|
||||||
|
&-horizontal&-with-text {
|
||||||
|
display: table;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
background: transparent;
|
||||||
|
font-weight: 500;
|
||||||
|
color: @heading-color;
|
||||||
|
font-size: @font-size-lg;
|
||||||
|
margin: 16px 0;
|
||||||
|
|
||||||
|
&:before,
|
||||||
|
&:after {
|
||||||
|
content: '';
|
||||||
|
display: table-cell;
|
||||||
|
position: relative;
|
||||||
|
top: 50%;
|
||||||
|
width: 50%;
|
||||||
|
border-top: 1px solid @border-color-split;
|
||||||
|
transform: translateY(50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-inner-text {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 24px;
|
||||||
|
}
|
||||||
|
&-horizontal&-with-text-left {
|
||||||
|
display: table;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
background: transparent;
|
||||||
|
font-weight: 500;
|
||||||
|
color: @heading-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
margin: 16px 0;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: '';
|
||||||
|
display: table-cell;
|
||||||
|
position: relative;
|
||||||
|
top: 50%;
|
||||||
|
width: 5%;
|
||||||
|
border-top: 1px solid @border-color-split;
|
||||||
|
transform: translateY(50%);
|
||||||
|
}
|
||||||
|
&:after {
|
||||||
|
content: '';
|
||||||
|
display: table-cell;
|
||||||
|
position: relative;
|
||||||
|
top: 50%;
|
||||||
|
width: 95%;
|
||||||
|
border-top: 1px solid @border-color-split;
|
||||||
|
transform: translateY(50%);
|
||||||
|
}
|
||||||
|
&-inner-text {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-horizontal&-with-text-right {
|
||||||
|
display: table;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
background: transparent;
|
||||||
|
font-weight: 500;
|
||||||
|
color: @heading-color;
|
||||||
|
font-size: @font-size-base;
|
||||||
|
margin: 16px 0;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: '';
|
||||||
|
display: table-cell;
|
||||||
|
position: relative;
|
||||||
|
top: 50%;
|
||||||
|
width: 95%;
|
||||||
|
border-top: 1px solid @border-color-split;
|
||||||
|
transform: translateY(50%);
|
||||||
|
}
|
||||||
|
&:after {
|
||||||
|
content: '';
|
||||||
|
display: table-cell;
|
||||||
|
position: relative;
|
||||||
|
top: 50%;
|
||||||
|
width: 5%;
|
||||||
|
border-top: 1px solid @border-color-split;
|
||||||
|
transform: translateY(50%);
|
||||||
|
}
|
||||||
|
&-inner-text {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&-dashed {
|
||||||
|
background: none;
|
||||||
|
border-top: 1px dashed @border-color-split;
|
||||||
|
}
|
||||||
|
&-horizontal&-with-text&-dashed {
|
||||||
|
border-top: 0;
|
||||||
|
&:before,
|
||||||
|
&:after {
|
||||||
|
border-style: dashed none none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,5 +45,6 @@
|
||||||
@import "avatar";
|
@import "avatar";
|
||||||
@import "color-picker";
|
@import "color-picker";
|
||||||
@import "auto-complete";
|
@import "auto-complete";
|
||||||
|
@import "divider";
|
||||||
@import "anchor";
|
@import "anchor";
|
||||||
@import "time";
|
@import "time";
|
||||||
|
|
Loading…
Add table
Reference in a new issue