-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathOverflowMenu.vue
More file actions
84 lines (76 loc) · 1.73 KB
/
OverflowMenu.vue
File metadata and controls
84 lines (76 loc) · 1.73 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
<script setup>
import { getCurrentInstance, ref, computed } from 'vue';
import ToolbarButton from './ToolbarButton.vue';
import ButtonGroup from './ButtonGroup.vue';
const { proxy } = getCurrentInstance();
const props = defineProps({
toolbarItem: {
type: Object,
required: true,
},
overflowItems: {
type: Array,
required: true,
},
});
const isDropdownOpened = ref(false);
const overflowToolbarItem = computed(() => ({
...props.toolbarItem,
active: isDropdownOpened,
}));
const toggleOverflowMenu = () => {
isDropdownOpened.value = !isDropdownOpened.value;
};
const handleCommand = ({ item, argument }) => {
proxy.$toolbar.emitCommand({ item, argument });
};
</script>
<template>
<div
class="overflow-menu"
>
<div class="overflow-menu-trigger">
<ToolbarButton
:toolbar-item="overflowToolbarItem"
@buttonClick="toggleOverflowMenu"
/>
</div>
<div v-if="isDropdownOpened" class="overflow-menu_items" role="group">
<ButtonGroup
class="superdoc-toolbar-overflow"
:toolbar-items="overflowItems"
from-overflow
@command="handleCommand"
/>
</div>
</div>
</template>
<style lang="postcss" scoped>
.overflow-menu {
position: relative;
&_items {
position: absolute;
width: 200px;
top: calc(100% + 3px);
right: 0;
padding: 4px 8px;
background-color: #fff;
border-radius: 8px;
z-index: 100;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.25);
box-sizing: border-box;
}
}
.superdoc-toolbar-overflow {
min-width: auto !important;
max-width: 200px;
flex-wrap: wrap;
}
@media (max-width: 300px) {
.overflow-menu_items {
right: auto;
left: 0;
transform: translateX(-50%);
}
}
</style>