-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditIconsTab.vue
168 lines (163 loc) · 4.18 KB
/
EditIconsTab.vue
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
161
162
163
164
165
166
167
168
<template>
<div>
<!--Main category icons of symbols-->
<TabGroup
as="div"
@change="
(main_k) => {
main_active = main_k;
}
"
>
<div class="flex padding_bottom">
<TabList
as="div"
class="flex-auto xl:grow-0 flex flex-wrap xl:flex-nowrap bg-white"
>
<Tab
as="button"
v-for="(tab, main_k) in mains"
:key="main_k"
class="category-icon w-24 h-12 flex-basis-like-1/3 xl:flex-basis-auto grow xl:grow-0 xl:shrink-0 order mx-0.5 border bg-gray-50 text-sm text-center cursor-pointer transition-color"
:class="{ main_active: main_active === main_k }"
@click="main_active = main_k"
>
{{ $t(`default.mains.${tab}`) }}
</Tab>
</TabList>
</div>
<div v-if="main_active === 1">
<TabPanels
as="div"
class="bg-bg2 border border-gray-300 flex flex-wrap"
>
<button
class="w-w5 h-w5 bg-white border group relative"
:aria-label="$t(`default.markdown.${icon.id}`)"
@click="$emit('insertLatex', icon)"
v-for="icon in markdowns"
:key="icon.id"
>
<SvgIcon :name="icon.id" :size="51" />
<Tab
as="div"
class="absolute p-4 shadow-lg hidden bg-bg2 group-hover:block whitespace-nowrap z-10"
style="left: 50%; transform: translateX(-50%); top: 55px"
>
{{ $t(`default.markdown.${icon.id}`) }}
</Tab>
</button>
</TabPanels>
</div>
<div v-else-if="main_active === 0">
<TabGroup
as="div"
@change="
(k) => {
active = k;
}
"
>
<div class="flex">
<TabList
as="div"
class="flex-auto flex flex-wrap xl:flex-nowrap bg-white"
>
<Tab
as="button"
v-for="(tab, k) in tabs"
:key="k"
:aria-label="$t(`default.categorys.${tab}`)"
class="group relative category-icon h-12 flex-basis-like-1/3 xl:flex-basis-auto grow xl:shrink-0 order mx-0.5 border bg-gray-50 cursor-pointer transition-color"
:class="{ active: active === k }"
@click="active = k"
>
<SvgIcon :name="tab" :size="48" />
<div
class="absolute p-4 shadow-lg hidden bg-bg2 group-hover:block whitespace-nowrap z-10"
style="left: 50%; transform: translateX(-50%); top: 55px"
>
{{ $t(`default.categorys.${tab}`) }}
</div>
</Tab>
</TabList>
</div>
<!--Sub category icons of symbols-->
<TabPanels
as="div"
class="bg-bg2 border border-gray-300 flex flex-wrap"
>
<TabPanel v-for="(tab, k) in tabs" :key="k">
<button
class="w-w5 h-w5 bg-white border group relative"
:aria-label="$t(`default.latexs.${icon.id}`)"
@click="$emit('insertLatex', icon)"
v-for="icon in orderLatexs.filter(
(latex) => latex.category === tab.toLowerCase()
)"
:key="icon.id"
>
<SvgIcon :name="icon.id" :size="51" />
<Tab
as="div"
class="absolute p-4 shadow-lg hidden bg-bg2 group-hover:block whitespace-nowrap z-10"
style="left: 50%; transform: translateX(-50%); top: 55px"
>
{{ $t(`default.latexs.${icon.id}`) }}
</Tab>
</button>
</TabPanel>
</TabPanels>
</TabGroup>
</div>
</TabGroup>
</div>
</template>
<script>
import { ref } from "vue";
import { TabGroup, TabList, Tab, TabPanels, TabPanel } from "@headlessui/vue";
import { compare } from "../utils/dataProcess";
import latexs from "../utils/latexs";
import markdowns from "../utils/markdowns";
import SvgIcon from "@/components/SvgIcon";
import tabs from "@/utils/tabs";
export default {
emits: ["insertLatex"],
components: {
SvgIcon,
TabGroup,
TabList,
Tab,
TabPanels,
TabPanel,
},
setup() {
const mains = ["math", "mark_down"];
const main_active = ref(0);
const active = ref(0);
const orderLatexs = latexs.sort(compare("order", "asc"));
return {
mains,
main_active,
tabs,
active,
orderLatexs,
markdowns,
};
},
};
</script>
<style scoped lang="scss">
.category-icon {
white-space: nowrap;
background: #f9f9f9;
.wrap &.active &:hover {
background: white;
color: #777;
}
&.active {
font-weight: 900;
color: #555;
}
}
</style>