77 lines
1.8 KiB
Vue
Raw Normal View History

2022-01-27 20:47:22 +08:00
<template>
<div class="go-shape-box">
<slot></slot>
2022-01-29 23:58:56 +08:00
<!-- 选中 -->
<div class="shape-modal" :style="useSizeStyle(item.attr)">
2022-01-30 19:38:12 +08:00
<div class="shape-modal-select" :class="{ active: select }" />
<div class="shape-modal-change" :class="{ active: select || hover }" />
2022-01-29 23:58:56 +08:00
</div>
2022-01-27 20:47:22 +08:00
</div>
</template>
2022-01-29 23:58:56 +08:00
<script setup lang="ts">
2022-01-30 19:38:12 +08:00
import { ref, computed, PropType, h } from 'vue';
2022-01-29 23:58:56 +08:00
import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import { CreateComponentType } from '@/packages/index.d'
import { useSizeStyle } from '../../hooks/useStyle.hook'
const props = defineProps({
item: {
type: Object as PropType<CreateComponentType>,
required: true
}
})
// 全局颜色
const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
const chartEditStore = useChartEditStoreStore()
// 计算当前选中目标
const hover = computed(() => {
2022-02-01 01:20:00 +08:00
return props.item.id === chartEditStore.getTargetChart.hoverId
2022-01-29 23:58:56 +08:00
})
const select = computed(() => {
2022-02-01 01:20:00 +08:00
return props.item.id === chartEditStore.getTargetChart.selectId
2022-01-29 23:58:56 +08:00
})
</script>
2022-01-27 20:47:22 +08:00
<style lang="scss" scoped>
@include go(shape-box) {
position: absolute;
2022-01-30 14:20:28 +08:00
cursor: move;
2022-01-29 23:58:56 +08:00
.shape-modal {
position: absolute;
top: 0;
left: 0;
2022-01-30 19:38:12 +08:00
.shape-modal-select,
.shape-modal-change {
2022-01-29 23:58:56 +08:00
position: absolute;
width: 100%;
height: 100%;
border-radius: 10px;
2022-01-30 19:38:12 +08:00
@extend .go-transition-quick;
}
.shape-modal-select {
opacity: 0.1;
top: 2px;
left: 2px;
2022-01-30 19:38:12 +08:00
&.active {
background-color: v-bind('themeColor');
}
2022-01-29 23:58:56 +08:00
}
.shape-modal-change {
border: 2px solid rgba(0, 0, 0, 0);
2022-01-30 19:38:12 +08:00
&.active {
border: 2px solid v-bind('themeColor');
2022-01-30 19:38:12 +08:00
}
2022-01-29 23:58:56 +08:00
}
}
2022-01-27 20:47:22 +08:00
}
</style>