-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.vue
More file actions
99 lines (96 loc) · 1.84 KB
/
index.vue
File metadata and controls
99 lines (96 loc) · 1.84 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
<section v-bind:class="{ 'has-text': anyText }">
<textarea
class="input original"
v-model="textInput"
ref="mainInput"
placeholder="type here..."
></textarea>
<textarea
class="input result"
v-model="textResult"
@keydown.prevent=''
@focus="$event.target.select();"
@click="$event.target.select();"
></textarea>
</section>
</template>
<script>
export default {
components: {},
data() {
return {
textInput: ""
};
},
computed: {
textResult() {
let wideText = "";
this.textResultParts.forEach(word => {
word = this.trimAndBiggen(word);
wideText += this.widenWord(word);
wideText += "\n";
});
return wideText;
},
textResultParts() {
return this.textInput.replace(/\n/g, " ").split(" ");
},
anyText() {
return this.textInput.length >= 1;
}
},
mounted() {
this.$refs.mainInput.focus();
},
methods: {
trimAndBiggen(word) {
return word.trim().toUpperCase();
},
widenWord(word) {
let wideWord = "";
for (let i = 0; i < word.length; i++) {
let char = word[i];
let isLastChar = i + 1 === word.length;
wideWord += char;
if (!isLastChar) {
wideWord += " ";
}
}
return wideWord;
}
}
};
</script>
<style>
section {
font-size: 0;
}
.input {
width: 100vw;
height: 100vh;
background-color: black;
color: white;
padding: 1em;
font-size: 40px;
transition: height 0.4s ease;
outline: none;
font-family: "Comic Sans MS", "MarkerFelt-Thin";
border: none;
border-radius: 0;
}
.result {
height: 0;
font-size: 0;
overflow: hidden;
background-color: white;
color: black;
}
.has-text .original {
height: 50vh;
}
.has-text .result {
height: 50vh;
font-size: 40px;
}
</style>