mand-mobile/components/tip/tip.vue

119 lines
2.3 KiB
Vue
Raw Normal View History

2018-03-26 16:04:04 +08:00
<template>
<div class="md-tip" :class="wrapperCls">
2018-09-13 15:44:27 +08:00
<div class="tip-content">
<template>{{content}}</template>
<md-icon
v-if="closable"
name="cross"
size="md"
@click.native="$_onClose"
/>
</div>
<div class="tip-bg"></div>
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
z-index tip-zindex
2018-09-13 15:44:27 +08:00
.tip-content
position relative
padding tip-padding
color tip-color
font-size tip-font-size
line-height 1.2
z-index 2
.tip-bg
2018-09-03 17:28:32 +08:00
position absolute
2018-09-13 15:44:27 +08:00
absolute-pos()
border-radius tip-radius
background-color tip-fill
box-shadow tip-shadow
opacity tip-fill-opacity
&::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
2018-09-03 17:28:32 +08:00
&.has-close
2018-09-13 15:44:27 +08:00
.tip-content
padding-right 60px
&.is-bottom
.tip-bg::after
bottom auto
top -10px
border-width 0 11px 10px 11px
border-color transparent transparent tip-fill transparent
&.is-left
.tip-bg::after
top 50%
right -6px
left auto
margin-top -11px
border-width 11px 0 11px 10px
border-color transparent transparent transparent tip-fill
&.is-right
.tip-bg::after
top 50%
left 4px
margin-top -11px
border-width 11px 10px 11px 0
border-color transparent tip-fill transparent transparent
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>