-
Notifications
You must be signed in to change notification settings - Fork 690
Expand file tree
/
Copy pathComponentBar.vue
More file actions
160 lines (146 loc) · 3.53 KB
/
ComponentBar.vue
File metadata and controls
160 lines (146 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<script setup lang="ts">
import { toRefs } from 'vue'
import icon_delete from '@/assets/svg/icon_delete.svg'
import { Icon } from '@/components/icon-custom'
import { useEmitt } from '@/utils/useEmitt.ts'
import { useI18n } from 'vue-i18n'
import icon_more_outlined from '@/assets/svg/icon_more_outlined.svg'
import icon_chart_preview from '@/assets/svg/icon_chart_preview.svg'
const { t } = useI18n()
const emits = defineEmits(['enlargeView'])
const props = defineProps({
active: {
type: Boolean,
default: false,
},
configItem: {
type: Object,
required: true,
},
showPosition: {
required: false,
type: String,
default: 'preview',
},
canvasId: {
type: String,
default: 'canvas-main',
},
})
const { configItem } = toRefs(props)
const doPreview = () => {
// do preview
emits('enlargeView')
}
const doDeleteComponent = (e: MouseEvent) => {
e.stopPropagation()
e.preventDefault()
useEmitt().emitter.emit(`editor-delete-${props.canvasId}`, configItem.value.id)
}
</script>
<template>
<div class="component-bar-main" :class="{ 'bar-hidden': !active }">
<div>
<el-dropdown
ref="curDropdown"
popper-class="bar-main_popper"
trigger="click"
placement="bottom-end"
>
<el-icon class="bar-more" @mousedown.stop>
<el-tooltip :content="t('dashboard.more')" placement="bottom">
<icon name="icon_more_outlined"><icon_more_outlined class="svg-icon" /></icon>
</el-tooltip>
</el-icon>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
v-if="configItem.component === 'SQView'"
:icon="icon_chart_preview"
@click="doPreview"
>{{ t('dashboard.preview') }}</el-dropdown-item
>
<el-dropdown-item
:divided="configItem.component === 'SQView'"
:icon="icon_delete"
@click="doDeleteComponent"
>{{ t('dashboard.delete') }}</el-dropdown-item
>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</template>
<style scoped lang="less">
.component-bar-main {
height: 20px;
position: absolute;
right: 12px;
top: 12px;
display: flex;
z-index: 11;
cursor: pointer !important;
}
.bar-hidden {
display: none;
}
.bar-more {
width: 24px;
height: 24px;
color: rgba(31, 35, 41, 1);
border-radius: 6px;
background: rgba(255, 255, 255, 1);
border: 1px solid rgba(217, 220, 223, 1);
padding: 8px;
z-index: 10;
&:hover {
background-color: rgba(245, 246, 247, 1);
}
&:active {
background-color: rgba(245, 246, 247, 0.5);
}
}
</style>
<style lang="less">
.bar-main_popper {
box-shadow: 0px 4px 8px 0px #1f23291a !important;
border-radius: 4px;
border: 1px solid #dee0e3 !important;
width: 120px !important;
min-width: 120px !important;
padding: 0 !important;
.handle-icon {
color: #646a73;
margin-right: 8px;
}
.ed-dropdown-menu__item--divided {
margin: 4px 0;
}
.ed-dropdown-menu__item {
position: relative;
padding-left: 12px;
background: none;
color: #1f2329;
&:focus {
background: none;
color: #1f2329;
}
&:hover {
background: none;
color: #1f2329;
&::after {
content: '';
width: 112px;
height: 32px;
border-radius: 4px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #1f23291a;
}
}
}
}
</style>