-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Change nuxt rendering mode to SPA, universal mode was overkill for this type of app -Better Components and better data fetch
- Loading branch information
1 parent
5aa068d
commit 954948b
Showing
5 changed files
with
209 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<div class="flex-1 relative my-4 m-2 border-b-2 focus-within:border-black"> | ||
<input | ||
:type="inputType" | ||
:id="inputId" | ||
placeholder | ||
class="block w-full appearance-none focus:outline-none bg-transparent" | ||
v-on:input="updateValue($event.target.value)" | ||
/> | ||
<label :for="inputId" class="absolute top-0 left-0 -z-1 duration-300 origin-0">{{ inputName }}</label> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "Input", | ||
props: { | ||
inputType: String, | ||
inputId: String, | ||
inputName: { | ||
type: String, | ||
default: null, | ||
}, | ||
value: { | ||
type: String, | ||
default: null, | ||
}, | ||
}, | ||
methods: { | ||
updateValue: function (value) { | ||
this.$emit("input", value); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<template> | ||
<div class="flex-1 m-2"> | ||
<div class="relative"> | ||
<select | ||
class="block w-full appearance-none bg-transparent border-b-2 focus:outline-none focus-within:border-black" | ||
:id="selectId" | ||
v-on:input="updateValue($event.target.value)" | ||
> | ||
<option value>{{ selectName }}</option> | ||
<option v-for="item in items.results" :key="item.id" :value="item">{{ item }}</option> | ||
</select> | ||
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2"> | ||
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> | ||
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" /> | ||
</svg> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "Select", | ||
props: { | ||
items: { | ||
type: Object, | ||
}, | ||
selectName: { | ||
type: String, | ||
}, | ||
selectId: { | ||
type: String, | ||
}, | ||
value: { | ||
type: String, | ||
}, | ||
}, | ||
methods: { | ||
updateValue: function (value) { | ||
this.$emit("input", value); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<form class="flex items-center"> | ||
<Input inputName="Nom de la Sneaker" inputId="sneakerName" v-model="sneakerName" /> | ||
<Select :items="brands" selectName="Marque" selectId="brands" v-model="sneakerBrand"></Select> | ||
<Select :items="genders" selectName="Genre" selectId="genders" v-model="sneakerGender"></Select> | ||
<Input inputName="Date de sortie" inputId="releaseYear" v-model="sneakerReleaseYear" /> | ||
<button @click.prevent="searchSneaker" class="btn"> | ||
search | ||
<span class="badge badge-primary"></span> | ||
</button> | ||
</form> | ||
</template> | ||
|
||
<script> | ||
import Select from "~/components/atoms/Select"; | ||
export default { | ||
name: "Form", | ||
props: { | ||
// sneakerName: String, | ||
// sneakerBrand: String, | ||
// sneakerGender: String, | ||
// sneakerReleaseYear: String, | ||
searchSneaker: Function, | ||
}, | ||
components: { | ||
Select, | ||
}, | ||
created() { | ||
fetch("https://api.thesneakerdatabase.com/v1/brands") | ||
.then((response) => response.json()) | ||
.then((result) => (this.brands = result.results)); | ||
fetch("https://api.thesneakerdatabase.com/v1/genders") | ||
.then((response) => response.json()) | ||
.then((result) => (this.genders = result.results)); | ||
}, | ||
data() { | ||
return { | ||
brands: [], | ||
genders: [], | ||
sneakerName: "", | ||
sneakerBrand: "", | ||
sneakerGender: "", | ||
sneakerReleaseYear: "", | ||
}; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters