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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136<template>
<section
v-if="isSectionVisible"
class="search-result"
>
<div
v-if="isSearchResultVisible"
class="search-result__content content"
>
<h2 class="search-result__title">
Your search result
</h2>
<div class="search-result__wrap">
<movie-card
v-for="movie in movies"
:key="movie.id"
:movie="movie"
/>
</div>
</div>
<div
v-else
class="search-result__empty-state"
>
<h2 class="title">
There are no results for your query
</h2>
<img
src="@/assets/images/no-results.png"
alt="No results"
class="image"
>
</div>
<i
class="close-icon"
@click="closeSearchResult"
>
x
</i>
</section>
</template>
<script>
import MovieCard from '../components/MovieCard'
export default {
name: 'SearchResult',
props: {
movies: {
required: true
}
},
components: {
MovieCard
},
computed: {
isSectionVisible () {
return this.$store.state.isSearchResultVisible
},
isSearchResultVisible () {
return JSON.stringify({ ...this.$store.state.searchMovies }) !== '{}'
}
},
methods: {
closeSearchResult () {
this.$emit('close-results')
}
}
}
</script>
<style lang="scss" scoped>
.search-result {
position: relative;
max-width: 80rem;
margin: 0 auto 2rem auto;
padding: 0 1rem;
&__content {
border-bottom: 1px solid #ccc;
}
&__title {
margin-top: 0;
font-size: 1.5rem;
font-weight: 600;
color: #333;
}
&__wrap {
margin-bottom: 2rem;
display: grid;
grid-gap: 2rem;
grid-template-columns: repeat(5, 1fr);
@media (max-width: 1280px) {
grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 900px) {
margin-right: 0;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
}
&__empty-state {
padding-bottom: 2rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-bottom: 1px solid #ccc;
.title {
text-align: center;
font-size: 2rem;
}
.image {
max-width: 100%;
}
}
.close-icon {
position: absolute;
top: 0;
right: 1rem;
font-size: 1.5rem;
cursor: pointer;
transition: transform .2s ease;
}
}
</style>