-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
47 lines (45 loc) · 1000 Bytes
/
app.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
<template>
<div class="container">
<div v-if="mode === modes.main">
<button class="mode-button">Preview</button>
<button class="mode-button" @click="setMode(modes.text)">Edit Text</button>
<pre>
{{data.text}}
</pre>
</div>
<text-input
v-if="mode === modes.text"
:initial="data.text"
@done="handleTextEditDone" />
</div>
</template>
<script setup lang="ts">
import {ref} from 'vue'
const modes = {main: 'main', text: 'text'}
type Mode = typeof modes[keyof typeof modes]
const mode = ref('main')
const data = {
text: ''
}
const setMode = (newmode: Mode) => {
mode.value = newmode
}
const handleTextEditDone = (newText: string) => {
data.text = newText
setMode(modes.main)
}
</script>
<style scoped>
.container {
height: 100%;
}
.mode-button {
display: block;
width: 100%;
border: none;
background: rgba(255,255,255,0.1);
padding: 0.5rem;
border-bottom: 3px solid rgba(0,0,0,0.2);
cursor: pointer;
}
</style>