2018-03-26 16:04:04 +08:00
|
|
|
<template>
|
2018-10-17 20:31:46 +08:00
|
|
|
<button
|
2018-03-26 16:04:04 +08:00
|
|
|
class="md-button"
|
2018-08-07 19:43:20 +08:00
|
|
|
:class="[
|
|
|
|
type,
|
|
|
|
inactive ? 'inactive' : 'active',
|
2018-10-17 20:31:46 +08:00
|
|
|
inline ? 'inline' : 'block',
|
2018-08-07 19:43:20 +08:00
|
|
|
round ? 'round' : '',
|
2018-08-09 11:04:04 +08:00
|
|
|
plain ? 'plain' : '',
|
|
|
|
size === 'small' ? 'small' : ''
|
2018-08-07 19:43:20 +08:00
|
|
|
]"
|
2018-03-26 16:04:04 +08:00
|
|
|
@click="$_onBtnClick"
|
|
|
|
>
|
|
|
|
<div class="md-button-inner">
|
|
|
|
<template v-if="icon">
|
2018-10-15 15:52:00 +08:00
|
|
|
<md-icon :name="icon" :svg="iconSvg"></md-icon>
|
2018-03-26 16:04:04 +08:00
|
|
|
</template>
|
2018-08-07 19:43:20 +08:00
|
|
|
<p class="md-button-content">
|
|
|
|
<slot></slot>
|
|
|
|
</p>
|
2018-03-26 16:04:04 +08:00
|
|
|
</div>
|
2018-10-17 20:31:46 +08:00
|
|
|
</button>
|
2018-03-26 16:04:04 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
import Icon from '../icon'
|
|
|
|
export default {
|
|
|
|
name: 'md-button',
|
|
|
|
|
|
|
|
components: {
|
|
|
|
[Icon.name]: Icon,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
type: {
|
|
|
|
type: String,
|
2018-08-29 14:47:54 +08:00
|
|
|
default: 'default', // default, primary, warning, disabled, link
|
2018-03-26 16:04:04 +08:00
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2018-10-15 15:52:00 +08:00
|
|
|
iconSvg: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2018-08-09 11:04:04 +08:00
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: 'large', // large, small
|
|
|
|
},
|
2018-08-07 19:43:20 +08:00
|
|
|
plain: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
round: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
inline: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
inactive: {
|
2018-03-26 16:04:04 +08:00
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
$_onBtnClick(event) {
|
2018-08-07 19:43:20 +08:00
|
|
|
if (this.inactive || this.type === 'disabled') {
|
2018-03-26 16:04:04 +08:00
|
|
|
event.stopImmediatePropagation()
|
2018-04-24 22:47:39 +08:00
|
|
|
} else {
|
|
|
|
this.$emit('click', event)
|
2018-03-26 16:04:04 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus">
|
|
|
|
.md-button
|
|
|
|
position relative
|
2018-08-09 11:04:04 +08:00
|
|
|
display block
|
2018-08-07 19:43:20 +08:00
|
|
|
height button-height
|
|
|
|
line-height button-height
|
|
|
|
font-size button-font-size
|
|
|
|
font-weight button-font-weight
|
2018-03-26 16:04:04 +08:00
|
|
|
text-align center
|
2018-10-17 20:31:46 +08:00
|
|
|
border none
|
2018-08-07 19:43:20 +08:00
|
|
|
border-radius button-radius
|
2018-03-26 16:04:04 +08:00
|
|
|
box-sizing border-box
|
2018-10-17 20:31:46 +08:00
|
|
|
outline none
|
2018-08-07 19:43:20 +08:00
|
|
|
transition all .3s
|
2018-10-17 20:31:46 +08:00
|
|
|
-webkit-appearance none
|
2018-08-09 11:04:04 +08:00
|
|
|
-webkit-user-select none
|
|
|
|
-webkit-tap-highlight-color transparent
|
2018-03-26 16:04:04 +08:00
|
|
|
overflow visible
|
2018-09-03 17:28:32 +08:00
|
|
|
|
|
|
|
.md-button-inner
|
|
|
|
display flex
|
|
|
|
align-items center
|
|
|
|
justify-content center
|
|
|
|
width 100%
|
|
|
|
height 100%
|
|
|
|
overflow hidden
|
|
|
|
text-overflow ellipsis
|
|
|
|
word-break break-word
|
|
|
|
white-space nowrap
|
|
|
|
|
|
|
|
.md-button-content
|
|
|
|
display flex
|
|
|
|
align-items center
|
|
|
|
padding 0 6px
|
|
|
|
.md-icon
|
|
|
|
padding 0
|
|
|
|
|
|
|
|
.md-button
|
2018-09-26 20:10:47 +08:00
|
|
|
position relative
|
2018-09-03 17:28:32 +08:00
|
|
|
.md-icon
|
2018-05-28 16:24:11 +08:00
|
|
|
display flex
|
|
|
|
align-items center
|
|
|
|
justify-content center
|
2018-09-03 17:28:32 +08:00
|
|
|
padding 0 6px
|
2018-03-26 16:04:04 +08:00
|
|
|
// type
|
2018-08-07 19:43:20 +08:00
|
|
|
&.default
|
|
|
|
background-color button-default-fill
|
|
|
|
color button-default-color
|
|
|
|
hairline(all, color-border-element, button-radius)
|
|
|
|
&.active:active
|
|
|
|
background-color button-default-active-fill
|
2018-03-26 16:04:04 +08:00
|
|
|
&.primary
|
|
|
|
background-color button-primary-fill
|
2018-08-07 19:43:20 +08:00
|
|
|
color button-primary-color
|
|
|
|
hairline(all, button-primary-fill, button-radius)
|
|
|
|
&.active:active
|
|
|
|
background-color button-primary-active-fill
|
|
|
|
&.warning
|
|
|
|
background-color button-warning-fill
|
|
|
|
color button-warning-color
|
|
|
|
hairline(all, button-warning-fill, button-radius)
|
|
|
|
&.active:active
|
|
|
|
background-color button-warning-active-fill
|
|
|
|
&.disabled
|
|
|
|
background-color button-disabled-fill
|
|
|
|
color button-disabled-color
|
|
|
|
hairline(all, button-disabled-fill, button-radius)
|
2018-09-03 17:28:32 +08:00
|
|
|
|
2018-08-07 19:43:20 +08:00
|
|
|
&.plain
|
|
|
|
background transparent
|
2018-03-26 16:04:04 +08:00
|
|
|
|
2018-08-07 19:43:20 +08:00
|
|
|
&.default
|
|
|
|
color button-default-color
|
|
|
|
hairline(all, color-border-element, button-radius)
|
|
|
|
&.active:active
|
|
|
|
background-color button-default-plain-active-fill
|
|
|
|
&.primary
|
|
|
|
color button-primary-fill
|
|
|
|
hairline(all, button-primary-fill, button-radius)
|
|
|
|
&.active:active
|
|
|
|
background-color button-primary-plain-active-fill
|
|
|
|
&.warning
|
|
|
|
color button-warning-fill
|
|
|
|
hairline(all, button-warning-fill, button-radius)
|
|
|
|
&.active:active
|
|
|
|
background-color button-warning-plain-active-fill
|
2018-03-26 16:04:04 +08:00
|
|
|
&.disabled
|
2018-08-07 19:43:20 +08:00
|
|
|
color button-disabled-fill
|
|
|
|
hairline(all, button-disabled-fill, button-radius)
|
|
|
|
|
|
|
|
&.round
|
|
|
|
border-radius button-height
|
|
|
|
&:after
|
2018-08-09 11:04:04 +08:00
|
|
|
border-radius button-height
|
2018-08-07 19:43:20 +08:00
|
|
|
|
|
|
|
&.inline
|
2018-08-09 11:04:04 +08:00
|
|
|
display inline-block
|
|
|
|
padding 0 h-gap-md
|
2018-10-17 20:31:46 +08:00
|
|
|
&.block
|
|
|
|
width 100%
|
2018-08-09 11:04:04 +08:00
|
|
|
|
|
|
|
&.small
|
|
|
|
height button-small-height
|
|
|
|
font-size button-small-font-size
|
2018-08-07 19:43:20 +08:00
|
|
|
&.round
|
2018-08-09 11:04:04 +08:00
|
|
|
border-radius button-small-height
|
2018-08-07 19:43:20 +08:00
|
|
|
&:after
|
2018-08-09 11:04:04 +08:00
|
|
|
border-radius button-small-height
|
2018-04-23 17:33:32 +08:00
|
|
|
|
2018-03-26 16:04:04 +08:00
|
|
|
&.link
|
2018-08-07 19:43:20 +08:00
|
|
|
display inline
|
|
|
|
width auto
|
|
|
|
height auto
|
|
|
|
line-height 1
|
2018-08-09 11:04:04 +08:00
|
|
|
font-size button-small-font-size
|
2018-08-07 19:43:20 +08:00
|
|
|
font-weight font-weight-normal
|
|
|
|
color button-primary-fill
|
|
|
|
&.inactive
|
|
|
|
color color-text-disabled
|
|
|
|
opacity 1
|
2018-03-26 16:04:04 +08:00
|
|
|
|
2018-08-07 19:43:20 +08:00
|
|
|
&.inactive
|
|
|
|
opacity opacity-disabled
|
|
|
|
&.disabled
|
|
|
|
opacity 1
|
2018-03-26 16:04:04 +08:00
|
|
|
</style>
|