JoinMicrocosm.vue 3.87 KB
Newer Older
Adam Procter's avatar
init  
Adam Procter committed
1
2
3
4
5
6
7
8
9
10
<template>
  <form>
    <span class="arrow">⬇⬇</span>
    <h1>What shall we call you ? 👩‍🚀</h1>
    <p>
      First we need to connect this device to your ideas. This name is what
      allows you to create and edit your nodes and this name can be anything you
      like, this name is always anonymous.
    </p>
    <div class="breaker-one">
Adam Procter's avatar
tidy up    
Adam Procter committed
11
12
      <label for="name">Your Name: {{ nameFormatted }}</label>

Adam Procter's avatar
init  
Adam Procter committed
13
      <input
Adam Procter's avatar
tidy up    
Adam Procter committed
14
        v-model.trim="name"
Adam Procter's avatar
init  
Adam Procter committed
15
16
17
18
19
20
        type="text"
        id="name"
        autocomplete="name"
        placeholder="type name here!"
        autocorrect="off"
        autocapitalize="none"
Adam Procter's avatar
tidy up    
Adam Procter committed
21
        @keyup.enter="setName()"
Adam Procter's avatar
init  
Adam Procter committed
22
      />
Adam Procter's avatar
tidy up    
Adam Procter committed
23
      <button type="button" @click="setName()">Store</button>
Adam Procter's avatar
init  
Adam Procter committed
24
25
26
27
28
29
30
31
32
33
34
    </div>
    <h2>Next start or join a <span class="long">microcosm !</span> 🚀</h2>

    <p>
      Start your own microcosm to store your ideas and ask others to join you,
      either tell them the microcosm name or share the URL and add the ending;
      /microcosm/<strong>nameofyourmicrocosm</strong>
    </p>
    <div class="breaker-two">
      <label for="microcosm">Microcosm:</label>
      <input
Adam Procter's avatar
tidy up    
Adam Procter committed
35
36
        v-model.trim="microcosm"
        ref="microcosm"
Adam Procter's avatar
init  
Adam Procter committed
37
38
39
40
41
42
        type="text"
        id="microcosm"
        autocomplete="microcosm"
        placeholder="type microcosm name here!"
        autocorrect="off"
        autocapitalize="none"
Adam Procter's avatar
tidy up    
Adam Procter committed
43
        @keyup.enter="setMicrocosm()"
Adam Procter's avatar
init  
Adam Procter committed
44
      />
Adam Procter's avatar
tidy up    
Adam Procter committed
45
      <button type="button" @click="setMicrocosm()">Start or Join</button>
Adam Procter's avatar
init  
Adam Procter committed
46
47
48
49
50
51
    </div>
  </form>
</template>

<script>
export default {
ap2x07's avatar
updates    
ap2x07 committed
52
53
  name: 'JoinMicrocosm',

Adam Procter's avatar
Adam Procter committed
54
  data: function () {
ap2x07's avatar
updates    
ap2x07 committed
55
    return {
Adam Procter's avatar
tidy up    
Adam Procter committed
56
57
58
59
60
61
62
      // what you are calling yourself / device
      name: '',
      nameSet: false,
      nameFormatted: '',
      // Next dataset related to microcosm
      microcosm: '',
      microcosmSet: false,
Adam Procter's avatar
Adam Procter committed
63
      microcosmFormatted: '',
Adam Procter's avatar
tidy up    
Adam Procter committed
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
    }
  },

  methods: {
    setName() {
      // format name so no spaces or dashes PouchDB/ CouchDB dont like them
      var lowercasename = this.name.toLowerCase()
      var spacesremoved = lowercasename.split(' ').join('')
      this.nameFormatted = spacesremoved.split('-').join('')
      this.nameSet = true
      localStorage.setItem('nogg_name', this.nameFormatted)
      // focus on next input field for speed
      this.focusInput()
      // now we sent this same data set to the store
      // this.$store.dispatch('setName', this.nameFormatted),
    },

    setMicrocosm() {
      // format microcosm so no spaces or dashes PouchDB/ CouchDB dont like them
      var lowercasemicrocosm = this.microcosm.toLowerCase()
      var spacesremoved = lowercasemicrocosm.split(' ').join('')
      this.microcosmFormatted = spacesremoved.split('-').join('')
      this.microcosmSet = true
      localStorage.setItem('nogg_microcosm', this.microcosmFormatted)
      // now we sent this same data set to the store
Adam Procter's avatar
Adam Procter committed
89
      this.$store.dispatch('setMicrocosm', this.microcosmFormatted)
Adam Procter's avatar
tidy up    
Adam Procter committed
90
91
92
93
    },

    focusInput() {
      this.$refs.microcosm.focus()
Adam Procter's avatar
Adam Procter committed
94
95
    },
  },
ap2x07's avatar
updates    
ap2x07 committed
96
}
Adam Procter's avatar
init  
Adam Procter committed
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1 {
  margin-top: -0.5em;
  font-size: 5.2em;
  line-height: 1.2em;
}

h2 {
  font-size: 5.2em;
  line-height: 1.2em;
  margin: -0.5em 0 0 0;
  padding: 0em;
  font-family: houschka-rounded, sans-serif;
  font-weight: 700;
  font-style: normal;
  color: black;
}

.arrow {
  font-size: 6em;
  color: #1cc469;
}

.breaker-one {
  padding: 1em;
  margin-left: -1em;
  margin-right: -0.4em;
  margin-bottom: 2.5em;
  background-color: rgba(196, 47, 152, 0.4);
}

.breaker-two {
  padding: 1em;
  margin-left: -1em;
  margin-right: -0.4em;
  margin-bottom: 1em;
  background-color: rgba(37, 194, 194, 0.4);
}

label,
button {
  display: block;
}

input {
  margin-top: 0.8em;
  border: none;
  padding: 1em;
  font-size: 1em;
}
button {
  cursor: pointer;
  background-color: #1cc469;
  border: none;
  margin-top: 1em;
  padding: 1em;
  font-size: 1em;
}
</style>