File tree Expand file tree Collapse file tree 9 files changed +57
-25
lines changed Expand file tree Collapse file tree 9 files changed +57
-25
lines changed Original file line number Diff line number Diff line change 1515 "directory-named-webpack-plugin" : " ^4.0.1" ,
1616 "lodash" : " ^4.17.15" ,
1717 "luxon" : " ^1.16.0" ,
18+ "moment-timezone" : " ^0.5.27" ,
1819 "v-click-outside" : " ^2.1.3" ,
1920 "vue" : " ^2.6.10" ,
2021 "vue-datetime" : " ^1.0.0-beta.10" ,
Original file line number Diff line number Diff line change 22/* eslint-disable object-shorthand */
33
44import axios from 'axios' ;
5+ import moment from 'moment-timezone' ;
56import WeatherIcon from './WeatherIcon' ;
67
78export default {
8- name : 'EventWeather ' ,
9+ name : 'CityData ' ,
910
1011 props : {
1112 eventCountry : {
@@ -24,6 +25,8 @@ export default {
2425 data ( ) {
2526 return {
2627 weather : null ,
28+ triggerInt : true ,
29+ localTime : '' ,
2730 } ;
2831 } ,
2932
@@ -32,6 +35,14 @@ export default {
3235 const { data } = await axios . get ( `http://eventcountdownapi.mralansmith.com/api/weather/${ this . eventCity . id } ` ) ;
3336 this . weather = data ;
3437 } ,
38+
39+ triggerTimeUpdate ( ) {
40+ this . localTime = moment ( ) . tz ( this . eventCity . timezoneName ) . format ( 'h:mma' ) ;
41+
42+ setTimeout ( ( ) => {
43+ window . requestAnimationFrame ( ( ) => this . triggerTimeUpdate ( ) ) ;
44+ } , 10000 ) ;
45+ } ,
3546 } ,
3647
3748 watch : {
@@ -47,6 +58,10 @@ export default {
4758 mounted ( ) {
4859 if ( this . eventCity ) {
4960 this . getCurrentWeather ( ) ;
61+
62+ if ( this . eventCity . timezoneName ) {
63+ this . triggerTimeUpdate ( ) ;
64+ }
5065 }
5166 } ,
5267} ;
Original file line number Diff line number Diff line change 1- .c-event-weather {
1+ .c-city-data {
22 display : flex ;
33 flex-direction : column ;
44 align-items : center ;
1212 border-bottom-right-radius : 45% ;
1313}
1414
15- .c-event-weather__icon {
15+ .c-city-data__icon {
1616 margin-bottom : 20px ;
1717 max-width : 100px ;
1818 max-height : 80px ;
2222 }
2323}
2424
25- .c-event-weather__text {
25+ .c-city-data__text {
2626 padding : 2px 10px ;
2727 text-align : center ;
2828 font-size : 16px ;
2929}
3030
31- .c-event-weather__city {
31+ .c-city-data__city {
3232 font-weight : bold ;
3333 padding : 2px 12px ;
3434}
Original file line number Diff line number Diff line change 1+ <template >
2+ <div
3+ class =" c-city-data"
4+ v-if =" weather" >
5+ <weather-icon
6+ class =" c-city-data__icon"
7+ :icon =" weather.icon" />
8+ <span
9+ class =" c-city-data__text"
10+ v-if =" localTime" >{{ localTime }}</span >
11+ <span class =" c-city-data__text" >{{ weather.summary }}</span >
12+ <span class =" c-city-data__text" >{{ weather.temp }}</span >
13+ <span class =" c-city-data__city c-city-data__text" >
14+ in {{ eventCity.name }}, {{ eventCountry.name }}
15+ </span >
16+ </div >
17+ </template >
18+ <script src="./CityData.js "></script >
19+ <style src="./CityData.scss " lang="scss"></style >
File renamed without changes.
Original file line number Diff line number Diff line change 11import Countdown from '@chenfengyuan/vue-countdown' ;
22import format from 'date-fns/format' ;
3- import EventWeather from '@sections/EventWeather/EventWeather .vue' ;
3+ import CityData from '@sections/CityData/CityData .vue' ;
44import TrashIcon from '@/assets/icons/trash.svg' ;
55import EditIcon from '@/assets/icons/edit.svg' ;
66import CheckIcon from '@/assets/icons/check.svg' ;
@@ -45,7 +45,7 @@ export default {
4545
4646 components : {
4747 Countdown,
48- EventWeather ,
48+ CityData ,
4949 TrashIcon,
5050 EditIcon,
5151 CheckIcon,
Original file line number Diff line number Diff line change 1919 </div >
2020 </div >
2121 <span class =" c-event__title" v-if =" isReady" >{{ eventName }}</span >
22- <event-weather
22+ <city-data
2323 :event-city =" eventCity"
2424 :event-country =" eventCountry" />
2525 <countdown
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments