add button

This commit is contained in:
niunai
2017-02-06 10:30:43 +08:00
parent 347dc1751c
commit 4562ca8b19
23 changed files with 616 additions and 117 deletions
+64
View File
@@ -0,0 +1,64 @@
@import "../../zenui/src/common/var.pcss";
@component-namespace o2 {
@component button {
position: relative;
display: block;
height: 45px;
border-radius: 4px;
border: 0;
box-sizing: border-box;
font-size: 16px;
text-align: center;
appearance: none;
outline: 0;
overflow: hidden;
&::after {
content: " ";
position: absolute 0 0 0 0;
background-color: #000;
opacity: 0;
}
&:not(.is-disabled):active::after {
opacity: .3;
}
@modifier default {
color: $button-default-color;
background-color: $button-default-background-color;
}
@modifier primary {
color: $button-primary-color;
background-color: $button-primary-background-color;
}
@modifier danger {
color: $button-danger-color;
background-color: $button-danger-background-color;
}
@modifier large {
display: block;
width: 100%;
}
@modifier normal {
display: inline-block;
padding: 0 12px;
}
@modifier small {
display: inline-block;
font-size: 14px;
padding: 0 12px;
height: 33px;
}
@when disabled {
opacity: .6;
}
}
}
+73
View File
@@ -0,0 +1,73 @@
<template>
<button
:type="nativeType"
:class="[
'o2-button',
'o2-button--' + type,
'o2-button--' + size,
{
'is-disabled': disabled,
'is-loading': loading
}
]"
:disabled="disabled"
@click="handleClick"
>
<i v-if="loading" class="o2-icon-loading"></i>
<span class="o2-button-text"><slot></slot></span>
</button>
</template>
<script>
/**
* o2-header
* @module components/button
* @desc 按钮
* @param {string} [type=default] - 显示类型,接受 default, primary, danger
* @param {boolean} [disabled=false] - 禁用
* @param {string} [size=normal] - 尺寸,接受 normal, mini, small, large
* @param {string} [native-type] - 原生 type 属性
* @param {slot} - 显示文本
*
* @example
* <o2-button size="large" type="primary">按钮</o2-button>
*/
export default {
name: 'o2-button',
methods: {
handleClick(e) {
this.$emit('click', e);
}
},
props: {
disabled: Boolean,
loading: Boolean,
nativeType: String,
type: {
type: String,
default: 'default',
validator(value) {
return [
'default',
'danger',
'primary'
].indexOf(value) > -1;
}
},
size: {
type: String,
default: 'normal',
validator(value) {
return [
'mini',
'small',
'normal',
'large'
].indexOf(value) > -1;
}
}
}
};
</script>