|
1 | 1 | <script setup> |
2 | | -import { Button } from '@/components/ui/button'; |
| 2 | +import { Button } from "@/components/ui/button"; |
3 | 3 | import CodeMirror from "./CodeMirror.vue"; |
4 | 4 | import { useAppStore } from "@/store"; |
5 | | -import { ref } from 'vue' |
| 5 | +import { ref } from "vue"; |
6 | 6 |
|
7 | 7 | const store = useAppStore(); |
8 | 8 |
|
9 | 9 | const update = (file, data) => { |
10 | | - store.code[file] = data; |
| 10 | + store.code[file] = data; |
11 | 11 | }; |
12 | 12 |
|
13 | | -const currentTab = ref('html') |
| 13 | +const currentTab = ref("html"); |
14 | 14 |
|
15 | 15 | const tabs = [ |
16 | | - ["html", "index.html"], |
17 | | - ["css", "style.css"], |
18 | | - ["js", "main.js"], |
| 16 | + ["html", "index.html"], |
| 17 | + ["css", "style.css"], |
| 18 | + ["js", "main.js"] |
19 | 19 | ]; |
20 | 20 | </script> |
21 | 21 |
|
22 | 22 | <template> |
23 | | - <div class="flex flex-col h-full relative"> |
24 | | - <div |
25 | | - class="flex items-center flex-none pl-5 sm:pl-6 pr-4 lg:pr-6 border-b overflow-x-auto"> |
26 | | - <div class="flex"> |
27 | | - <Button |
28 | | - v-for="tab in tabs" :key="tab[0]" |
29 | | - variant="ghost" |
30 | | - @click="currentTab = tab[0]" |
31 | | - :class="tab[0] === currentTab ? 'text-blue-500' : 'text-muted-foreground'" |
32 | | - class="relative rounded-none text-sm leading-6 font-semibold"> |
33 | | - <span class="absolute bottom-0 inset-x-0 bg-blue-500 h-0.5 rounded-full transition-opacity duration-150" :class="{'opacity-0': tab[0] !== currentTab}"></span> |
34 | | - <span class="uppercase sm:hidden">{{ tab[0] }}</span> |
35 | | - <span class="hidden sm:inline">{{ tab[1] }}</span> |
36 | | - </Button> |
37 | | - </div> |
38 | | - </div> |
39 | | - <div class="flex-grow overflow-y-auto"> |
40 | | - <CodeMirror v-for="tab in tabs" :key="tab[0]" :class="currentTab !== tab[0] ? 'hidden' : ''" :file="tab[1]" |
41 | | - :content="store.code[tab[0]]" :lang="tab[0]" @change="(d) => update(tab[0], d)" /> |
42 | | - </div> |
43 | | - </div> |
| 23 | + <div class="flex flex-col h-full relative"> |
| 24 | + <div |
| 25 | + class="flex items-center flex-none pl-5 sm:pl-6 pr-4 lg:pr-6 border-b overflow-x-auto" |
| 26 | + > |
| 27 | + <div class="flex"> |
| 28 | + <Button |
| 29 | + v-for="tab in tabs" |
| 30 | + :key="tab[0]" |
| 31 | + variant="ghost" |
| 32 | + @click="currentTab = tab[0]" |
| 33 | + :class=" |
| 34 | + tab[0] === currentTab |
| 35 | + ? 'text-blue-500' |
| 36 | + : 'text-muted-foreground' |
| 37 | + " |
| 38 | + class="relative rounded-none text-sm leading-6 font-semibold" |
| 39 | + > |
| 40 | + <span |
| 41 | + class="absolute bottom-0 inset-x-0 bg-blue-500 h-0.5 rounded-full transition-opacity duration-150" |
| 42 | + :class="{ 'opacity-0': tab[0] !== currentTab }" |
| 43 | + ></span> |
| 44 | + <span class="uppercase sm:hidden">{{ tab[0] }}</span> |
| 45 | + <span class="hidden sm:inline">{{ tab[1] }}</span> |
| 46 | + </Button> |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + <div class="flex-grow overflow-y-auto"> |
| 50 | + <CodeMirror |
| 51 | + v-for="tab in tabs" |
| 52 | + :key="tab[0]" |
| 53 | + :class="currentTab !== tab[0] ? 'hidden' : ''" |
| 54 | + :file="tab[1]" |
| 55 | + :content="store.code[tab[0]]" |
| 56 | + :lang="tab[0]" |
| 57 | + @change="(d) => update(tab[0], d)" |
| 58 | + /> |
| 59 | + </div> |
| 60 | + </div> |
44 | 61 | </template> |
0 commit comments