File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,17 @@ import { onMounted, ref } from 'vue';
99import YVHeader from ' ./YvHeader.vue' ;
1010
1111const preferDark = useStorage (' vue-sfc-playground-prefer-dark' , true );
12-
1312const theme = ref <' dark' | ' light' >(' dark' );
1413function setTheme(newTheme : ' dark' | ' light' ) {
1514 theme .value = newTheme ;
1615 preferDark .value = newTheme === ' dark' ;
1716}
1817
18+ const layout = useStorage <' horizontal' | ' vertical' >(' yehyecoa-vue-layout' , ' horizontal' );
19+ function toggleLayout() {
20+ layout .value = layout .value === ' horizontal' ? ' vertical' : ' horizontal' ;
21+ }
22+
1923function setVH() {
2024 document .documentElement .style .setProperty (' --vh' , ` ${window .innerHeight }px ` );
2125}
@@ -62,13 +66,15 @@ onMounted(async () => {
6266 <YVHeader
6367 :theme =" theme"
6468 @set-theme =" setTheme"
69+ @toggle-layout =" toggleLayout"
6570 />
6671 <Repl
6772 :editor =" Monaco"
6873 :show-compile-output =" false"
6974 :show-import-map =" false"
7075 :show-ts-config =" false"
71- :theme =" theme"
76+ :theme
77+ :layout
7278 :editor-options =" {
7379 autoSaveText: false,
7480 }"
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2+ import { useStorage } from ' @vueuse/core' ;
23import { onMounted } from ' vue' ;
34
45defineProps <{
56 theme: ' dark' | ' light' ;
67}>();
78
89// TODO: implement the download functionality, just like the official playground
9- const emit = defineEmits ([' set-theme' ]);
10+ const emit = defineEmits ({
11+ ' set-theme' : (theme : ' dark' | ' light' ) => theme ,
12+ ' toggle-layout' : () => true ,
13+ });
1014const cls = document .documentElement .classList ;
1115
1216function setTheme() {
1317 cls .toggle (' dark' );
1418 emit (' set-theme' , cls .contains (' dark' ) ? ' dark' : ' light' );
1519}
1620
21+ const layout = useStorage <' horizontal' | ' vertical' >(' yehyecoa-vue-layout' , ' horizontal' );
22+ function toggleLayout() {
23+ emit (' toggle-layout' );
24+ }
25+
1726onMounted (() => {
1827 emit (' set-theme' , cls .contains (' dark' ) ? ' dark' : ' light' );
1928});
@@ -35,6 +44,9 @@ onMounted(() => {
3544 <span uno-hidden sm:inline-block >yehyecoa-vue</span >
3645 </h1 >
3746 <div flex gap-2 text-neutral-500 >
47+ <button toolbar-btn @click =" toggleLayout" >
48+ <div :class =" layout === 'vertical' ? 'i-mynaui:rectangle' : 'i-mynaui:rectangle-vertical'" />
49+ </button >
3850 <button
3951 toolbar-btn
4052 :title =" `Switch to ${theme === 'dark' ? 'light' : 'dark'} theme`"
You can’t perform that action at this time.
0 commit comments