diff options
Diffstat (limited to 'iridescence/src/components')
-rw-r--r-- | iridescence/src/components/InventoryCard.vue | 13 | ||||
-rw-r--r-- | iridescence/src/components/InventoryFilter.vue | 39 | ||||
-rw-r--r-- | iridescence/src/components/InventoryList.vue | 20 | ||||
-rw-r--r-- | iridescence/src/components/InventorySearch.vue | 36 |
4 files changed, 64 insertions, 44 deletions
diff --git a/iridescence/src/components/InventoryCard.vue b/iridescence/src/components/InventoryCard.vue index 75e683a..6bcc548 100644 --- a/iridescence/src/components/InventoryCard.vue +++ b/iridescence/src/components/InventoryCard.vue @@ -15,7 +15,7 @@ <p class="subtitle is-4"> {{ dollars(cents) }} </p> - <p class="subtitle is-6">{{ quantity }} in stock.</p> + <p class="subtitle is-6">{{ stock }}</p> </div> <div class="content"> @@ -37,6 +37,17 @@ export default { imgPath: String, description: String }, + computed: { + stock() { + if (this.quantity < 0) { + return "Made to order"; + } else if (this.quantity == 0) { + return "Out of stock"; + } else { + return [this.quantity, "in stock"].join(" "); + } + } + }, methods: { dollars: cents => "$ " + (cents / 100).toFixed(2) } diff --git a/iridescence/src/components/InventoryFilter.vue b/iridescence/src/components/InventoryFilter.vue index 365c1e8..58547eb 100644 --- a/iridescence/src/components/InventoryFilter.vue +++ b/iridescence/src/components/InventoryFilter.vue @@ -1,40 +1,17 @@ <template> <div id="inventoryFilter"> - <section class="section"> - <div class="container"> - <input - class="input is-primary is-medium" - type="text" - placeholder="Find something in particular..." - v-model.trim="term" - @input="updateFilter" - autofocus - /> - </div> - <content class="has-text-centered" v-if="noResults"> - <p>We couldn't find anything like that...</p> - </content> - </section> + <h1 class="subtitle"> + Filter Products + </h1> + <label class="checkbox"> + <input type="checkbox" /> + Remember me + </label> </div> </template> <script> export default { - name: "InventoryFilter", - data() { - return { - term: "" - }; - }, - computed: { - noResults() { - return !this.$store.getters.inventory.length; - } - }, - methods: { - updateFilter() { - this.$store.commit("filterTerm", this.term); - } - } + name: "InventoryFilter" }; </script> diff --git a/iridescence/src/components/InventoryList.vue b/iridescence/src/components/InventoryList.vue index dbda9a4..a4962cd 100644 --- a/iridescence/src/components/InventoryList.vue +++ b/iridescence/src/components/InventoryList.vue @@ -1,18 +1,14 @@ <template> <div id="inventoryList"> - <section class="section"> - <div class="container"> - <div class="columns is-multiline is-variable is-7-desktop"> - <div - class="column is-one-quarter" - v-for="item in inventory" - :key="item.id" - > - <InventoryCard v-bind="item"></InventoryCard> - </div> - </div> + <div class="columns is-multiline is-variable is-7-desktop"> + <div + class="column is-one-quarter" + v-for="item in inventory" + :key="item.id" + > + <InventoryCard v-bind="item"></InventoryCard> </div> - </section> + </div> </div> </template> diff --git a/iridescence/src/components/InventorySearch.vue b/iridescence/src/components/InventorySearch.vue new file mode 100644 index 0000000..fbcaabb --- /dev/null +++ b/iridescence/src/components/InventorySearch.vue @@ -0,0 +1,36 @@ +<template> + <div id="inventorySearch"> + <input + class="input is-primary is-medium" + type="text" + placeholder="Find something in particular..." + v-model.trim="term" + @input="updateSearch" + autofocus + /> + <content class="has-text-centered" v-if="noResults"> + <p>We couldn't find anything like that...</p> + </content> + </div> +</template> + +<script> +export default { + name: "InventorySearch", + data() { + return { + term: "" + }; + }, + computed: { + noResults() { + return !this.$store.getters.inventory.length; + } + }, + methods: { + updateSearch() { + this.$store.commit("filterTerm", this.term); + } + } +}; +</script> |