This repository was archived by the owner on Jul 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrompt.vue
More file actions
99 lines (92 loc) · 2.46 KB
/
Prompt.vue
File metadata and controls
99 lines (92 loc) · 2.46 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>
<div class="shell" v-show="visible">
<div class="command" v-if="command">
<div class="prompt">
<span class="hostname">{{ hostname }} %</span>
<span v-if="isInteractive" class="output">{{ command }}</span>
<vue-typer v-else :text="command" :pre-type-delay="typeDelay" :repeat="0" @completed="process_prompt"/>
</div>
<span class="cursor" v-show="display_result_cursor"></span>
<transition name="result">
<pre class="result" v-if="display_result" v-html="result"></pre>
</transition>
</div>
</div>
</template>
<script>
export default {
name: 'Prompt',
props: {
id: { type: Number, default: 0 },
hostname: { type: String, default: 'localhost' },
command: { type: String, default: '' },
result: { type: String, default: '' },
delay: { type: Number, default: 0 },
interactive: { type: Boolean, default: false },
visible: { type: Boolean, default: false }
},
computed: {
isInteractive: function () {
return this.interactive
},
typeDelay: function () { return this.delay * 2 }
},
data () {
return {
display_prompt: false,
display_result: false,
display_result_cursor: false,
user_input: ''
}
},
methods: {
prompt_complete: function () {
this.display_result_cursor = false
this.display_result = true
this.display_prompt = true
this.$emit('command-complete', this.id)
},
process_prompt: function () {
this.display_result_cursor = true
setTimeout(this.prompt_complete, this.delay * 1000)
}
},
mounted: function () {
this.process_prompt()
}
}
</script>
<style>
.vue-typer .custom.char {
color: lightblue;
background-color: transparent;
}
.vue-typer .custom.caret {
background-color: lightblue;
margin-left: 0.25rem;
width: 0.5rem;
}
span.cursor {
font-weight: normal;
background-color: lightblue;
-webkit-animation: 1s blink step-end infinite;
-moz-animation: 1s blink step-end infinite;
-ms-animation: 1s blink step-end infinite;
-o-animation: 1s blink step-end infinite;
animation: 1s blink step-end infinite;
box-shadow: 0 0 10px lightblue;
padding: 0 0.25rem;
}
@keyframes blink {
from, to { visibility: hidden; }
50% { visibility: visible; }
}
</style>
<style scoped>
span.result {
display: flex;
flex-flow: column;
}
.result-enter, .result-leave-to { opacity: 0; }
.result-enter-active, .result-leave-active { opacity: 1; }
</style>