mand-mobile/components/tip/tip.vue

95 lines
1.7 KiB
Vue
Raw Normal View History

2018-03-26 16:04:04 +08:00
<template>
<div class="md-tip" :class="wrapperCls">
<template>{{content}}</template>
2018-08-28 16:43:24 +08:00
<md-icon
v-if="closable"
name="cross"
size="md"
@click.native="$_onClose"
/>
2018-03-26 16:04:04 +08:00
</div>
</template>
<script> import Icon from '../icon'
export default {
name: 'md-tip-content',
components: {
[Icon.name]: Icon,
},
props: {
placement: {
type: String,
},
2018-08-28 16:43:24 +08:00
closable: {
type: Boolean,
default: true,
},
2018-03-26 16:04:04 +08:00
content: {
type: [String, Number],
2018-03-26 16:04:04 +08:00
},
},
computed: {
wrapperCls() {
2018-08-28 16:43:24 +08:00
return {
'has-close': this.closable,
[`is-${this.placement}`]: ['left', 'bottom', 'right'].indexOf(this.placement) !== -1,
2018-03-26 16:04:04 +08:00
}
},
},
methods: {
$_onClose() {
this.$emit('close')
},
},
}
</script>
<style lang="stylus">
2018-09-03 17:28:32 +08:00
.md-tip
position relative
display inline-block
max-width 400px
color tip-color
font-size tip-font-size
line-height 1.2
padding tip-padding
border-radius tip-radius
background-color tip-fill
box-shadow tip-shadow
z-index tip-zindex
&::after
content ''
position absolute
bottom -10px
left 50%
margin-left -11px
width 0
height 0
border-style solid
border-width 10px 11px 0 11px
border-color tip-fill transparent transparent transparent
&.has-close
padding-right 60px
&.is-bottom::after
bottom auto
top -10px
border-width 0 11px 10px 11px
border-color transparent transparent tip-fill transparent
&.is-left::after,
&.is-right::after
display none
2018-08-28 16:43:24 +08:00
2018-09-03 17:28:32 +08:00
.md-icon.md-icon-cross
position absolute
right 16px
top 50%
width tip-close-size
height tip-close-size
transform translateY(-50%)
2018-03-26 16:04:04 +08:00
</style>