DemuMesDataV/lib/components/borderBox7/src/main.vue

75 lines
2.2 KiB
Vue
Raw Normal View History

2019-12-06 21:07:16 +08:00
2019-08-22 14:41:07 +08:00
<template>
2019-12-06 21:07:16 +08:00
<div
class="dv-border-box-7"
2020-04-25 16:46:33 +08:00
:style="`box-shadow: inset 0 0 40px ${mergedColor[0]}; border: 1px solid ${mergedColor[0]}; background-color: ${backgroundColor}`"
2019-12-06 21:07:16 +08:00
:ref="ref"
>
2019-08-22 14:41:07 +08:00
<svg class="dv-svg-container" :width="width" :height="height">
2019-12-06 21:07:16 +08:00
<polyline class="dv-bb7-line-width-2" :stroke="mergedColor[0]" :points="`0, 25 0, 0 25, 0`" />
<polyline class="dv-bb7-line-width-2" :stroke="mergedColor[0]" :points="`${width - 25}, 0 ${width}, 0 ${width}, 25`" />
<polyline class="dv-bb7-line-width-2" :stroke="mergedColor[0]" :points="`${width - 25}, ${height} ${width}, ${height} ${width}, ${height - 25}`" />
<polyline class="dv-bb7-line-width-2" :stroke="mergedColor[0]" :points="`0, ${height - 25} 0, ${height} 25, ${height}`" />
<polyline class="dv-bb7-line-width-5" :stroke="mergedColor[1]" :points="`0, 10 0, 0 10, 0`" />
<polyline class="dv-bb7-line-width-5" :stroke="mergedColor[1]" :points="`${width - 10}, 0 ${width}, 0 ${width}, 10`" />
<polyline class="dv-bb7-line-width-5" :stroke="mergedColor[1]" :points="`${width - 10}, ${height} ${width}, ${height} ${width}, ${height - 10}`" />
<polyline class="dv-bb7-line-width-5" :stroke="mergedColor[1]" :points="`0, ${height - 10} 0, ${height} 10, ${height}`" />
2019-08-22 14:41:07 +08:00
</svg>
<div class="border-box-content">
<slot></slot>
</div>
</div>
</template>
<script>
import autoResize from '../../../mixin/autoResize'
2019-12-06 21:07:16 +08:00
import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
2019-08-22 14:41:07 +08:00
export default {
name: 'DvBorderBox7',
mixins: [autoResize],
2019-12-06 21:07:16 +08:00
props: {
color: {
type: Array,
default: () => ([])
2020-04-25 16:46:33 +08:00
},
backgroundColor: {
type: String,
default: 'transparent'
2019-12-06 21:07:16 +08:00
}
},
2019-08-22 14:41:07 +08:00
data () {
return {
2019-12-06 21:07:16 +08:00
ref: 'border-box-7',
defaultColor: ['rgba(128,128,128,0.3)', 'rgba(128,128,128,0.5)'],
mergedColor: []
}
},
watch: {
color () {
const { mergeColor } = this
mergeColor()
2019-08-22 14:41:07 +08:00
}
2019-12-06 21:07:16 +08:00
},
methods: {
mergeColor () {
const { color, defaultColor } = this
this.mergedColor = deepMerge(deepClone(defaultColor, true), color || [])
}
},
mounted () {
const { mergeColor } = this
mergeColor()
2019-08-22 14:41:07 +08:00
}
}
</script>