12 changed files with 2542 additions and 168 deletions
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 1.4 KiB |
@ -1,30 +1,81 @@ |
|||||||
<template> |
<template> |
||||||
<div id="nav"> |
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> |
||||||
<router-link to="/">Home</router-link> | |
<div class="container"> |
||||||
<router-link to="/about">About</router-link> |
<a class="navbar-brand" href="#"> |
||||||
</div> |
<img src="/img/minifig.png" alt="" class="navbar-icon"> |
||||||
<router-view/> |
</a> |
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor02" |
||||||
|
aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation"> |
||||||
|
<span class="navbar-toggler-icon"></span> |
||||||
|
</button> |
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarColor02"> |
||||||
|
<ul class="navbar-nav me-auto"> |
||||||
|
<li class="nav-item"> |
||||||
|
<router-link class="nav-link" to="/">Explore</router-link> |
||||||
|
</li> |
||||||
|
<li class="nav-item"> |
||||||
|
<router-link class="nav-link" to="/">Collection</router-link> |
||||||
|
</li> |
||||||
|
<!-- <li class="nav-item dropdown">--> |
||||||
|
<!-- <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</a>--> |
||||||
|
<!-- <div class="dropdown-menu">--> |
||||||
|
<!-- <router-link class="nav-item" to="/">Home</router-link> |--> |
||||||
|
<!-- <router-link class="nav-item" to="/about">About</router-link>--> |
||||||
|
<!-- <div class="dropdown-divider"></div>--> |
||||||
|
<!-- </div>--> |
||||||
|
<!-- </li>--> |
||||||
|
</ul> |
||||||
|
<div class="d-flex"> |
||||||
|
<input class="form-control me-sm-2" type="text" placeholder="Search" v-model="searchTerm"> |
||||||
|
<router-link class="btn btn-secondary my-2 my-sm-0" to="/">Search</router-link> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</nav> |
||||||
|
|
||||||
|
<div class="container"> |
||||||
|
<div class="header"> |
||||||
|
<br/> |
||||||
|
<router-view/> |
||||||
|
</div> |
||||||
|
</div> |
||||||
</template> |
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
export default { |
||||||
|
name: 'App', |
||||||
|
data() { |
||||||
|
return { |
||||||
|
searchTerm: '' |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
<style> |
<style> |
||||||
#app { |
#app { |
||||||
font-family: Avenir, Helvetica, Arial, sans-serif; |
font-family: Avenir, Helvetica, Arial, sans-serif; |
||||||
-webkit-font-smoothing: antialiased; |
-webkit-font-smoothing: antialiased; |
||||||
-moz-osx-font-smoothing: grayscale; |
-moz-osx-font-smoothing: grayscale; |
||||||
text-align: center; |
text-align: center; |
||||||
color: #2c3e50; |
color: #2c3e50; |
||||||
} |
} |
||||||
|
|
||||||
#nav { |
#nav { |
||||||
padding: 30px; |
padding: 30px; |
||||||
} |
} |
||||||
|
|
||||||
#nav a { |
#nav a { |
||||||
font-weight: bold; |
font-weight: bold; |
||||||
color: #2c3e50; |
color: #2c3e50; |
||||||
} |
} |
||||||
|
|
||||||
#nav a.router-link-exact-active { |
#nav a.router-link-exact-active { |
||||||
color: #42b983; |
color: #42b983; |
||||||
|
} |
||||||
|
|
||||||
|
.navbar-icon { |
||||||
|
height: 1.7em; |
||||||
} |
} |
||||||
</style> |
</style> |
||||||
|
@ -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