12 changed files with 2542 additions and 168 deletions
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 1.4 KiB |
@ -1,5 +1,7 @@ |
|||||||
import { createApp } from 'vue' |
import { createApp } from 'vue' |
||||||
import App from './App.vue' |
import App from './App.vue' |
||||||
import router from './router' |
import router from './router' |
||||||
|
import './css/app.scss' |
||||||
|
import 'bootstrap' |
||||||
|
|
||||||
createApp(App).use(router).mount('#app') |
createApp(App).use(router).mount('#app') |
||||||
|
@ -0,0 +1,57 @@ |
|||||||
|
<template> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-md-12"> |
||||||
|
<input type="text" class="form-control" v-model="searchTerm" v-on:keydown.enter="loadSearchResults"/> |
||||||
|
</div> |
||||||
|
<div class="col-md-12"> |
||||||
|
<hr v-if="results.length > 0"> |
||||||
|
</div> |
||||||
|
<div class="col col-md-3" v-for="(minifig, minifigIndex) in results" :key="minifigIndex"> |
||||||
|
<div class="card"> |
||||||
|
<img :src="minifig.set_img_url ?? placeholder" alt="" class="minifig-image"/> |
||||||
|
<div class="card-footer">{{ minifig.name }}</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import axios from 'axios'; |
||||||
|
|
||||||
|
export default { |
||||||
|
name: 'Explore', |
||||||
|
data() { |
||||||
|
return { |
||||||
|
searchTerm: '', |
||||||
|
placeholder: '/img/minifig.png', |
||||||
|
results: [] |
||||||
|
} |
||||||
|
}, |
||||||
|
components: {}, |
||||||
|
methods: { |
||||||
|
loadSearchResults() { |
||||||
|
let component = this; |
||||||
|
|
||||||
|
axios.get( |
||||||
|
'https://rebrickable.com/api/v3/lego/minifigs/?key=197650df271511a5b9f4938301b4ef80&search=' + component.searchTerm |
||||||
|
).then((response) => { |
||||||
|
component.results = response.data.results; |
||||||
|
// }).catch((error) => { |
||||||
|
// |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<style> |
||||||
|
.card { |
||||||
|
margin-bottom: 1em; |
||||||
|
} |
||||||
|
|
||||||
|
.minifig-image { |
||||||
|
max-height: 13em; |
||||||
|
width: auto; |
||||||
|
margin: 0 auto; |
||||||
|
} |
||||||
|
</style> |
@ -1,18 +0,0 @@ |
|||||||
<template> |
|
||||||
<div class="home"> |
|
||||||
<img alt="Vue logo" src="../assets/logo.png"> |
|
||||||
<HelloWorld msg="Welcome to Your Vue.js App"/> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
|
|
||||||
<script> |
|
||||||
// @ is an alias to /src |
|
||||||
import HelloWorld from '@/components/HelloWorld.vue' |
|
||||||
|
|
||||||
export default { |
|
||||||
name: 'Home', |
|
||||||
components: { |
|
||||||
HelloWorld |
|
||||||
} |
|
||||||
} |
|
||||||
</script> |
|
@ -0,0 +1,48 @@ |
|||||||
|
<template> |
||||||
|
<div class="home"> |
||||||
|
<input type="text" class="form-control" v-model="updatedSearchTerm"/> |
||||||
|
<div class="card" v-for="(minifigIndex, minifig) in results.results" v-key="minifigIndex"> |
||||||
|
<div class="card-img"> |
||||||
|
<img src="" alt=""/> |
||||||
|
</div> |
||||||
|
<div class="card-content">{{ minifig.name }}</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import axios from 'axios'; |
||||||
|
|
||||||
|
export default { |
||||||
|
name: 'Search', |
||||||
|
props: { |
||||||
|
searchTerm: { |
||||||
|
default: '', |
||||||
|
type: String |
||||||
|
} |
||||||
|
}, |
||||||
|
data() { |
||||||
|
return { |
||||||
|
updatedSearchTerm: '', |
||||||
|
results: [] |
||||||
|
} |
||||||
|
}, |
||||||
|
components: {}, |
||||||
|
mounted() { |
||||||
|
this.loadSearchResults(); |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
loadSearchResults() { |
||||||
|
let component = this; |
||||||
|
|
||||||
|
axios.get( |
||||||
|
'https://rebrickable.com/api/v3/lego/minifigs/?key=197650df271511a5b9f4938301b4ef80&search='+this.searchTerm |
||||||
|
).then((response) => { |
||||||
|
component.results = response.data; |
||||||
|
// }).catch((error) => { |
||||||
|
// |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
Loading…
Reference in new issue