This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbreaking.html
121 lines (109 loc) · 2.9 KB
/
breaking.html
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Messagist - Breaking the flow</title>
<script src="https://unpkg.com/vue"></script>
<style>
.Survey {
max-width: 640px;
margin: 0 auto;
}
label {
display: block;
}
input {
width: 100%;
display: block;
height: 2rem;
font-size: 1rem;
padding: 0 .5rem;
margin: .5rem 0;
box-sizing: border-box;
}
button {
float: right;
padding: 10px 20px;
background: darkseagreen;
color: #fff;
font-weight: bold;
border: 1px solid forestgreen;
border-radius: .5rem;
}
</style>
</head>
<body>
<div id="app">
<messagist
:messages="messages"
@custom-survey="startSurvey"
@finished="finished"
></messagist>
<div class="Survey" v-show="survey.visible">
<form action="#store" @submit.prevent="save">
<label for="name">What's your name:</label>
<input type="text" name="name" v-model="survey.name" placeholder="Jane Doe" required>
<label for="name">What's your favorite animal:</label>
<input type="text" v-model="survey.animal" placeholder="Favorite Animal" required>
<button type="submit">All set!</button>
</form>
</div>
</div>
<script src="/dist/messagist.js"></script>
<script>
console.log(Messagist)
Vue.component('messagist', Messagist)
conversation = {
init: {
content: [
'Hi, this is your automated setup assistant.',
'Before you can start using the app, we have some questions.'
],
choices: {
fill_out_survey: {
text: 'I am ready to fill out the questions',
action() {
this.trigger('custom-survey')
}
}
}
},
fill_out_survey: {
content: [
'Cool, we are all set.',
'Have a smashing day and enjoy the best app in the world.'
],
action() {
this.trigger('finished')
}
}
}
new Vue({
el: '#app',
data: {
messages: conversation,
continue: null,
survey: {
visible: false,
name: '',
animal: ''
}
},
methods: {
startSurvey(done) {
this.continue = done
this.survey.visible = true
},
save() {
this.survey.visible = false
const message = `Okay, my name is ${this.survey.name} and I adore ${this.survey.animal}.`
this.continue(message)
},
finished() {
alert('You are all done with Messagist for now.')
}
}
})
</script>
</body>
</html>