|
1 | 1 | <template> |
2 | 2 | <div class="container" v-if="nav && currencies"> |
| 3 | + <div class="edit-button"> |
| 4 | + <i class="fa fa-gear" v-if="!edit" @click="edit=true"></i> |
| 5 | + </div> |
| 6 | + <div class="portfolio-total"> |
| 7 | + <p> My Total Asset Value in Exchange </p> |
| 8 | + <h2 class="portfolio">{{ Number(exchangeTotal).toLocaleString('en-US', { style: 'currency', currency: base}) }}</h2> |
| 9 | + <p> 24hr Change </p> |
| 10 | + <h3 :class="{'up': (exchangeInfo.percent_change_24h > 0), 'down': (exchangeInfo.percent_change_24h < 0)}"> |
| 11 | + {{ exchangeInfo.percent_change_24h }}% |
| 12 | + <i class="fa fa-arrow-up" v-if="exchangeInfo.percent_change_24h > 0"></i> |
| 13 | + <i class="fa fa-arrow-down" v-if="exchangeInfo.percent_change_24h < 0"></i> |
| 14 | + </h3> |
| 15 | + </div> |
3 | 16 |
|
4 | | - <div class="field-area"> |
5 | | - <div class="area"> |
6 | | - <h2 class="nav">{{ nav }}</h2> |
7 | | - <h4>Nav Price</h4> |
| 17 | + <div class="asset-table value"> |
| 18 | + <div> |
| 19 | + <h3>Tokens</h3> |
| 20 | + <h4>{{ c20 }}</h4> |
| 21 | + </div> |
| 22 | + <div> |
| 23 | + <h3>NAV Price</h3> |
| 24 | + <h4>{{ nav }}</h4> |
| 25 | + </div> |
| 26 | + <div> |
| 27 | + <h3>Exchange</h3> |
| 28 | + <h4>{{ exchangeRate }}</h4> |
| 29 | + </div> |
| 30 | + <div> |
| 31 | + <h3>Asset Value</h3> |
| 32 | + <h4>{{ Number(total).toLocaleString('en-US', { style: 'currency', currency: base}) }}</h4> |
8 | 33 | </div> |
9 | | - <div class="area"> |
10 | | - <h2 class="nav"> |
| 34 | + </div> |
| 35 | + |
| 36 | + <div v-if="edit"> |
| 37 | + <div class="edit-area"> |
| 38 | + <div class="element"> |
| 39 | + <label>Your C20 Tokens</label> |
11 | 40 | <input type="text" v-model="c20"> |
12 | | - </h2> |
13 | | - <h4>Tokens</h4> |
| 41 | + </div> |
| 42 | + <div class="element"> |
| 43 | + <label>Portfolio Currency</label> |
| 44 | + <select v-model="base" v-if="currencies"> |
| 45 | + <option v-for="(item, index) in currencies">{{ index }}</option> |
| 46 | + </select> |
| 47 | + </div> |
14 | 48 | </div> |
15 | | - <div class="area"> |
16 | | - <h2 class="portfolio">{{ Number(total).toLocaleString('en-US', { style: 'currency', currency: base}) }}</h2> |
17 | | - <h4>Portfolio</h4> |
| 49 | + <div class="button-area"> |
| 50 | + <button type="button" @click.prevent="saveToken()">Save Changes </button> |
| 51 | + <button type="button" @click.prevent="getC20()">Refresh Stats </button> |
18 | 52 | </div> |
19 | 53 | </div> |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + <!-- |
| 58 | + <div class="field-area"> |
| 59 | + <div class="area"> |
| 60 | + <h2 class="nav">{{ nav }}</h2> |
| 61 | + <h4>Nav Price</h4> |
| 62 | + </div> |
| 63 | + <div class="area"> |
| 64 | + <h2 class="portfolio">{{ exchangeRate }}</h2> |
| 65 | + <h4>Exchange Price</h4> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + <div class="field-area"> |
| 69 | + <div class="area"> |
| 70 | + <h2 class="nav"> |
| 71 | + <input type="text" v-model="c20"> |
| 72 | + </h2> |
| 73 | + <h4>Tokens</h4> |
| 74 | + </div> |
| 75 | + <div class="area"> |
| 76 | + <h2 class="portfolio">{{ Number(total).toLocaleString('en-US', { style: 'currency', currency: base}) }}</h2> |
| 77 | + <h4>Portfolio</h4> |
| 78 | + </div> |
| 79 | + |
| 80 | + <div class="area"> |
| 81 | + <h2 class="portfolio">{{ Number(exchangeTotal).toLocaleString('en-US', { style: 'currency', currency: base}) }}</h2> |
| 82 | + <h4>Exchange Value</h4> |
| 83 | + </div> |
| 84 | + </div> |
| 85 | + --> |
| 86 | + |
| 87 | + |
| 88 | + <!-- |
20 | 89 | <hr> |
21 | 90 | <div class="movements"> |
22 | 91 | <div class="items" v-for="(item, index) in movements"> |
|
30 | 99 | </div> |
31 | 100 | <hr> |
32 | 101 | <div class="footer-area"> |
33 | | - <p>{{ (nav / .95).toFixed(2) * 100 }}% increase from ICO</p> |
34 | 102 | <div |
35 | 103 | <button type="button" @click.prevent="saveToken()"><i class="fa fa-floppy-o"></i> </button> |
36 | 104 | <button type="button" @click.prevent="getC20()"><i class="fa fa-refresh"></i> </button> |
37 | 105 | <select v-model="base" v-if="currencies"> |
38 | 106 | <option v-for="(item, index) in currencies">{{ index }}</option> |
39 | 107 | </select> |
40 | 108 | </div> |
41 | | - </div> |
| 109 | + </div> --> |
42 | 110 | </div> |
43 | 111 | </template> |
44 | 112 |
|
|
50 | 118 | c20: 1500, |
51 | 119 | currencies: null, |
52 | 120 | movements: null, |
| 121 | + exchangeRate: 0, |
| 122 | + exchangeInfo: null, |
53 | 123 | base: 'USD', |
| 124 | + edit : false |
54 | 125 | } |
55 | 126 | }, |
56 | 127 | mounted(){ |
57 | 128 | this.getRates(); |
58 | 129 | this.getC20(); |
| 130 | + this.getExchangeRate(); |
59 | 131 | }, |
60 | 132 | |
61 | 133 | watch: { |
|
67 | 139 | computed:{ |
68 | 140 | total(){ |
69 | 141 | return (this.nav * this.c20 * this.currencies[this.base]).toFixed(2); |
| 142 | + }, |
| 143 | + exchangeTotal(){ |
| 144 | + return (this.exchangeRate * this.c20 * this.currencies[this.base]).toFixed(2); |
70 | 145 | } |
71 | 146 | }, |
72 | 147 | |
|
78 | 153 | }) |
79 | 154 | }, |
80 | 155 | |
| 156 | + getExchangeRate(){ |
| 157 | + axios.get('https://api.coinmarketcap.com/v1/ticker/c20/').then((res)=>{ |
| 158 | + this.exchangeInfo = res.data[0]; |
| 159 | + this.exchangeRate = res.data[0].price_usd; |
| 160 | + }) |
| 161 | + }, |
| 162 | + |
81 | 163 | getC20(){ |
82 | 164 | if(localStorage.getItem('c20Token')){ |
83 | 165 | this.c20 = localStorage.getItem('c20Token'); |
|
97 | 179 | |
98 | 180 | saveToken(){ |
99 | 181 | localStorage.setItem('c20Token', this.c20); |
| 182 | + this.edit = false; |
100 | 183 | }, |
101 | 184 | }, |
102 | 185 | } |
103 | 186 | </script> |
104 | 187 |
|
105 | 188 | <style lang="scss" scoped> |
106 | | -
|
107 | 189 | .movements{ |
108 | 190 | display: flex; |
109 | 191 | width: 100%; |
|
141 | 223 | p { |
142 | 224 | font-size: 16px; |
143 | 225 | } |
144 | | - .container{ |
145 | | - // width: 250px; |
146 | | - padding: 10px; |
147 | | - background: #f9f9f9; |
148 | | - } |
149 | 226 | .field-area{ |
150 | 227 | display: flex; |
151 | 228 | justify-content: space-between; |
|
158 | 235 | } |
159 | 236 | h2.nav{ |
160 | 237 | font-size: 20px; |
161 | | - color: #2595ff; |
162 | | - } |
163 | | - h2.portfolio{ |
164 | | - color: #6cb305; |
165 | 238 | } |
166 | 239 | h4{ |
167 | 240 | text-transform: uppercase; |
|
190 | 263 | border-bottom: 1px dashed #ccc; |
191 | 264 | background: #fff; |
192 | 265 | } |
| 266 | + .container{ |
| 267 | + background: #38414d; |
| 268 | + color: white; |
| 269 | + padding: 30px; |
| 270 | + min-width: 250px; |
| 271 | + display: flex; |
| 272 | + flex-direction: column; |
| 273 | + align-items: center; |
| 274 | + } |
| 275 | + |
| 276 | + |
| 277 | + |
| 278 | + .portfolio-total{ |
| 279 | + text-align: center; |
| 280 | + margin-bottom: 20px; |
| 281 | + } |
| 282 | + .portfolio-total h2{ |
| 283 | + font-size: 22px; |
| 284 | + font-weight: 600; |
| 285 | + letter-spacing: 1px; |
| 286 | + } |
| 287 | + .portfolio-total h3{ |
| 288 | + padding: 0; |
| 289 | + margin: 3px 0; |
| 290 | + font-size: 12px; |
| 291 | + font-weight: 400; |
| 292 | + } |
| 293 | + .portfolio-total h3.down{ |
| 294 | + background: #ff7200; |
| 295 | + border-radius: 32px; |
| 296 | + display: inline-block; |
| 297 | + padding: 1px 8px; |
| 298 | + } |
| 299 | + .portfolio-total h3.up{ |
| 300 | + background: #b3e804; |
| 301 | + border-radius: 32px; |
| 302 | + display: inline-block; |
| 303 | + padding: 1px 8px; |
| 304 | + } |
| 305 | + .portfolio-total p{ |
| 306 | + font-size: 12px; |
| 307 | + padding: 0; |
| 308 | + margin: 5px; |
| 309 | + color: #dadada54; |
| 310 | + } |
| 311 | + |
| 312 | + |
| 313 | + |
| 314 | + .asset-table{ |
| 315 | + display: flex; |
| 316 | + width: 100%; |
| 317 | + justify-content: space-between; |
| 318 | + padding: 10px 20px; |
| 319 | + border-radius: 5px; |
| 320 | + margin: 0 20px; |
| 321 | + width: 100%; |
| 322 | + } |
| 323 | + .asset-table h3{ |
| 324 | + opacity: 1; |
| 325 | + text-transform: none; |
| 326 | + margin: 2px 0; |
| 327 | + font-size: 11px; |
| 328 | + color: #629bd6; |
| 329 | + } |
| 330 | + |
| 331 | + .asset-table.value h4{ |
| 332 | + font-size: 14px; |
| 333 | + opacity: 1; |
| 334 | + } |
| 335 | + |
| 336 | + |
| 337 | + .edit-button{ |
| 338 | + position: absolute; |
| 339 | + right: 15px; |
| 340 | + top: 15px; |
| 341 | + } |
| 342 | + .edit-button i{ |
| 343 | + font-size: 16px; |
| 344 | + opacity: 0.3; |
| 345 | + cursor: pointer; |
| 346 | + transition: 0.3s all; |
| 347 | + } |
| 348 | + .edit-button i:hover{ |
| 349 | + opacity: 1; |
| 350 | + } |
| 351 | + |
| 352 | + .edit-area{ |
| 353 | + width: 100%; |
| 354 | + padding: 10px; |
| 355 | + display: flex; |
| 356 | + border-top: 1px dashed #cccccc3b; |
| 357 | + padding-top: 20px; |
| 358 | + margin-top: 10px; |
| 359 | + } |
| 360 | + .edit-area input{ |
| 361 | + width: 80%; |
| 362 | + background: transparent; |
| 363 | + border: none; |
| 364 | + font-size: 16px; |
| 365 | + color: white; |
| 366 | + border-bottom: 1px dashed #ffffff1f; |
| 367 | + padding: 2px 0; |
| 368 | + outline: none; |
| 369 | + } |
| 370 | + .edit-area label{ |
| 371 | + margin-bottom: 4px; |
| 372 | + display: block; |
| 373 | + opacity: 0.3; |
| 374 | + } |
| 375 | + |
| 376 | + .edit-area .element{ |
| 377 | + margin-bottom: 15px; |
| 378 | + } |
| 379 | + .edit-area .element:first-child{ |
| 380 | + margin-right: 10px; |
| 381 | + } |
| 382 | + select{ |
| 383 | + background: none; |
| 384 | + border: none; |
| 385 | + padding: 0; |
| 386 | + margin: 0 -7px; |
| 387 | + color: white; |
| 388 | + width: 100%; |
| 389 | + font-size: 16px; |
| 390 | + } |
| 391 | + |
| 392 | + |
| 393 | + |
| 394 | + .button-area{ |
| 395 | + display: flex; |
| 396 | + width: 100%; |
| 397 | + } |
| 398 | + button{ |
| 399 | + background: #5e9bd6; |
| 400 | + border-radius: 3px; |
| 401 | + padding: 10px; |
| 402 | + color: white; |
| 403 | + border: none; |
| 404 | + outline: none; |
| 405 | + width: 100%; |
| 406 | + margin: 0 2px; |
| 407 | + cursor: pointer; |
| 408 | + transition: 0.3s all; |
| 409 | + } |
| 410 | + button:hover{ |
| 411 | + background: #55acee; |
| 412 | + } |
193 | 413 | </style> |
0 commit comments