2018-03-26 16:04:04 +08:00
|
|
|
<template>
|
|
|
|
<div class="md-tip" :class="wrapperCls">
|
|
|
|
<template>{{content}}</template>
|
|
|
|
<md-icon name="cross" size="md" @click.native="$_onClose" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
import Icon from '../icon'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'md-tip-content',
|
|
|
|
components: {
|
|
|
|
[Icon.name]: Icon,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
placement: {
|
|
|
|
type: String,
|
|
|
|
},
|
|
|
|
content: {
|
2018-04-26 11:00:53 +08:00
|
|
|
type: [String, Number],
|
2018-03-26 16:04:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
wrapperCls() {
|
|
|
|
const cls = {}
|
|
|
|
|
|
|
|
if (['left', 'bottom', 'right'].indexOf(this.placement) !== -1) {
|
|
|
|
cls[`is-${this.placement}`] = true
|
|
|
|
}
|
|
|
|
|
|
|
|
return cls
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
$_onClose() {
|
|
|
|
this.$emit('close')
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="stylus">
|
|
|
|
.md-tip
|
|
|
|
display inline-block
|
|
|
|
max-width 400px
|
|
|
|
color tip-color
|
|
|
|
font-size tip-font-size
|
2018-06-09 20:44:42 +08:00
|
|
|
padding tip-padding
|
2018-06-05 18:34:40 +08:00
|
|
|
border-radius tip-radius
|
2018-03-26 16:04:04 +08:00
|
|
|
background-color tip-fill
|
|
|
|
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
|
|
|
|
&.is-bottom::after
|
|
|
|
bottom auto
|
|
|
|
top -10px
|
|
|
|
border-width 0 11px 10px 11px
|
|
|
|
border-color transparent transparent tip-fill transparent
|
|
|
|
&.is-left::after
|
|
|
|
bottom auto
|
|
|
|
right -10px
|
|
|
|
left auto
|
|
|
|
top 50%
|
|
|
|
margin-left 0
|
|
|
|
margin-top -11px
|
|
|
|
border-width 11px 0 11px 10px
|
|
|
|
border-color transparent transparent transparent tip-fill
|
|
|
|
&.is-right::after
|
|
|
|
bottom auto
|
|
|
|
left -10px
|
|
|
|
right auto
|
|
|
|
top 50%
|
|
|
|
margin-left 0
|
|
|
|
margin-top -11px
|
|
|
|
border-width 11px 10px 11px 0
|
|
|
|
border-color transparent tip-fill transparent transparent
|
2018-06-05 18:34:40 +08:00
|
|
|
.md-icon
|
2018-03-26 16:04:04 +08:00
|
|
|
position absolute
|
|
|
|
right 16px
|
2018-06-05 18:34:40 +08:00
|
|
|
top 50%
|
|
|
|
width tip-close-size
|
|
|
|
height tip-close-size
|
|
|
|
transform translateY(-50%)
|
2018-03-26 16:04:04 +08:00
|
|
|
</style>
|