Skip to content

Commit 909d40b

Browse files
committed
Hide header meetup block if no data
1 parent 7b463c0 commit 909d40b

File tree

5 files changed

+50
-29
lines changed

5 files changed

+50
-29
lines changed

src/components/HomeHeader/HomeHeaderMeetup.vue

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
>
1818
<section class="d-flex">
1919
<span class="date-display">
20-
<span class="day">27</span>
21-
<span class="month">Oct</span>
20+
<span class="day">{{ ev.daySimple }}</span>
21+
<span class="month">{{ ev.monthSimple }}</span>
2222
</span>
2323
<div class="ml-4">
2424
<div class="body-1 blue-grey--text mb-1">{{ ev.fullDate }}</div>
@@ -50,30 +50,23 @@
5050

5151
<script>
5252
import moment from 'moment'
53-
import { mapGetters } from 'vuex'
5453
5554
export default {
5655
name: 'HomeHeaderMeetup',
57-
data() {
58-
return {
59-
ev: null,
60-
}
61-
},
62-
computed: {
63-
...mapGetters( [ 'getMeetupData' ] ),
64-
// fullDate () {
65-
// return this.getMeetupData.length
66-
// }
56+
props: {
57+
ev: {
58+
required: true,
59+
type: Object,
60+
},
6761
},
6862
created() {
6963
moment.locale( 'es' )
70-
if ( this.getMeetupData.length > 0 ) {
71-
const format = 'YYYY-MM-DD'
72-
this.ev = this.getMeetupData[ 0 ]
73-
const hour = moment( this.ev.local_time, 'hh:mm' ).format( 'hh' )
74-
const minutes = moment( this.ev.local_time, 'hh:mm' ).format( 'mm' )
75-
this.ev.fullDate = moment( this.ev.local_date, format ).hour( hour ).minutes( minutes ).format( 'LLL' )
76-
}
64+
const format = 'YYYY-MM-DD'
65+
const hour = moment( this.ev.local_time, 'hh:mm' ).format( 'hh' )
66+
const minutes = moment( this.ev.local_time, 'hh:mm' ).format( 'mm' )
67+
this.ev.fullDate = moment( this.ev.local_date, format ).hour( hour ).minutes( minutes ).format( 'LLL' )
68+
this.ev.daySimple = moment(this.ev.local_date, format).format('DD') // 02
69+
this.ev.monthSimple = moment(this.ev.local_date, format).format('MMM') // dic
7770
},
7871
methods: {
7972
goToEvent() {
@@ -111,6 +104,8 @@
111104
display block
112105
font-weight bolder
113106
line-height 1.1
107+
.month
108+
text-transform capitalize
114109
115110
.name
116111
position relative

src/components/HomeHeader/HomeHeaderTitle.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<v-flex
3-
md7
3+
:class="flexClass"
44
sm12>
55
<h1 class="hero-title display-3 text-xs-center mb-3">
66
{{ msg }}
@@ -16,6 +16,15 @@
1616
type: String,
1717
default: 'La comunidad más molona de todas ;)',
1818
},
19+
"is-full-width": {
20+
required: true,
21+
type: Boolean,
22+
},
23+
},
24+
computed: {
25+
flexClass() {
26+
return this.isFullWidth ? 'md12' : 'md7'
27+
},
1928
},
2029
}
2130
</script>

src/components/HomeHeader/Index.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,40 @@
55
<v-layout
66
row
77
wrap>
8-
<HomeHeaderTitle msg="La comunidad de software libre que hace cosas 🦄"/>
9-
<HomeHeaderMeetup/>
8+
<HomeHeaderTitle
9+
:is-full-width="!hasMeetupData"
10+
msg="La comunidad de software libre que hace cosas 🦄"/>
11+
<template v-if="hasMeetupData">
12+
<HomeHeaderMeetup :ev="ev"/>
13+
</template>
1014
</v-layout>
1115
</v-container>
1216
</v-content>
1317
</header>
1418
</template>
1519

1620
<script>
21+
import { mapGetters } from 'vuex'
1722
import HomeHeaderTitle from './HomeHeaderTitle'
1823
import HomeHeaderMeetup from './HomeHeaderMeetup'
1924
2025
export default {
2126
components: { HomeHeaderMeetup, HomeHeaderTitle },
27+
computed: {
28+
...mapGetters( [ 'getMeetupData' ] ),
29+
hasMeetupData() {
30+
return this.getMeetupData.length > 0
31+
},
32+
ev() {
33+
return this.getMeetupData[ 1 ]
34+
},
35+
},
2236
}
2337
</script>
2438

2539
<style scoped lang="stylus">
2640
.header-hero
27-
min-height 80vh
41+
min-height 450px
2842
position relative
2943
background-image url("/img/main.jpg")
3044
background-position center center

src/store/actions.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ import axios from 'axios'
33
const actions = {
44
async getMeetupData( context ) {
55
const key = '765c716753752b6f42355a45103155'
6-
const url = `https://api.meetup.com/Open-Source-Weekends/events?key=${key}&status=upcoming`
6+
const status = {
7+
past: 'past',
8+
upcoming: 'upcoming',
9+
}
10+
const url = `https://api.meetup.com/Open-Source-Weekends/events?key=${key}&status=${status.upcoming}`
711
try {
812
let res = await axios.get( url )
913
let data = res.data
1014
context.commit( 'setMeetupData', data )
11-
} catch (error) {
15+
} catch ( error ) {
1216
console.log( '😰 Err: [getMeetupData]' )
1317
console.log( { error } )
1418
}
15-
}
19+
},
1620
}
1721

1822
export default actions

src/store/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Vuex from 'vuex'
2-
import axios from 'axios'
32

43
import state from './state'
54
import getters from './getters'
@@ -11,7 +10,7 @@ const createStore = () => {
1110
state,
1211
getters,
1312
actions,
14-
mutations
13+
mutations
1514
})
1615
}
1716

0 commit comments

Comments
 (0)