commit d91ab1deb2115a251d0eb948666defa319555110 Author: Adam Jahr Date: Thu May 14 04:43:10 2020 -0400 Vue 2 code to change over diff --git a/assets/socks_blue.jpg b/assets/socks_blue.jpg new file mode 100644 index 0000000..000c7aa Binary files /dev/null and b/assets/socks_blue.jpg differ diff --git a/assets/socks_green.jpg b/assets/socks_green.jpg new file mode 100644 index 0000000..01f0fe0 Binary files /dev/null and b/assets/socks_green.jpg differ diff --git a/assets/styles.css b/assets/styles.css new file mode 100644 index 0000000..cc13c4b --- /dev/null +++ b/assets/styles.css @@ -0,0 +1,123 @@ +body { + font-family: tahoma; + color: #282828; + margin: 0px; +} + +.button { + margin-top: 30px; + background-color: #1e95ea; + color: white; + height: 50px; + width: 150px; + font-size: 20px; + cursor: pointer; +} + +.cart { + margin: 25px; + float: right; + border: 1px solid #d8d8d8; + padding: 5px 20px; +} + +.color-box { + width: 40px; + height: 40px; + margin-top: 5px; +} + +.container { + display: flex; + flex-direction: row; + flex-wrap: wrap; +} + +.disabledButton { + background-color: #d8d8d8; +} + +img { + border: 2px solid #d8d8d8; + width: 70%; + margin: 40px; + box-shadow: 0px 0.5px 1px #d8d8d8; +} + +input { + width: 100%; + height: 40px; + margin-bottom: 20px; +} + +label { + font-size: 20px; + margin-bottom: 5px; +} + +.nav-bar { + background: linear-gradient(-90deg, #84cf6a, #16c0b0); + height: 60px; + margin-bottom: 15px; +} + +p { + font-size: 20px; +} + +.product { + display: flex; + flex-direction: column; + padding: 1rem; +} + +.product-image, +.product-info { + width: 50%; +} + +.review-form { + display: flex; + flex-direction: column; + width: 400px; + padding: 20px; + margin: 40px; + border: 2px solid #d8d8d8; +} + +.review-container { + margin-left: 40px; +} + +select { + height: 40px; + font-size: 20px; +} + +textarea { + width: 95%; + height: 70px; + padding: 10px; + font-size: 20px; + margin-bottom: 20px; +} + +ul { + list-style-type: none; +} + +@media only screen and (max-width: 600px) { + .container { + flex-direction: column; + } + + .product-image, + .product-info { + margin-left: 10px; + width: 100%; + } + + .review-form { + width: 90%; + } +} diff --git a/components/ProductDisplay.js b/components/ProductDisplay.js new file mode 100644 index 0000000..3473ce6 --- /dev/null +++ b/components/ProductDisplay.js @@ -0,0 +1,101 @@ +Vue.component('product-display', { + props: { + premium: { + type: Boolean, + required: true, + }, + }, + template: ` +
+ +
+
+ +
+ +
+

{{ productName }}

+

In Stock

+

Out of Stock

+

Shipping: {{ shipping }}

+ +
    +
  • {{ detail }}
  • +
+ +
+
+ + + +
+
+ + + +
+ `, + data() { + return { + product: 'Socks', + brand: 'Vue Mastery', + selectedVariant: 0, + details: ['80% cotton', '20% polyester', 'Gender-neutral'], + variants: [ + { + id: 2234, + color: 'green', + image: './assets/socks_green.jpg', + quantity: 10, + }, + { + id: 2235, + color: 'blue', + image: './assets/socks_blue.jpg', + quantity: 0, + }, + ], + reviews: [], + tabs: ['review-form', 'review-list'], + activeTab: 'review-form', + } + }, + methods: { + addToCart() { + this.$emit('add-to-cart', this.variants[this.selectedVariant].id) + }, + updateProduct(index) { + this.selectedVariant = index + }, + addReview(review) { + this.reviews.push(review) + }, + }, + computed: { + productName() { + return this.brand + ' ' + this.product + }, + image() { + return this.variants[this.selectedVariant].image + }, + inStock() { + return this.variants[this.selectedVariant].quantity + }, + shipping() { + if (this.premium) { + return 'Free' + } + return 2.99 + }, + }, +}) diff --git a/components/ReviewForm.js b/components/ReviewForm.js new file mode 100644 index 0000000..feef958 --- /dev/null +++ b/components/ReviewForm.js @@ -0,0 +1,45 @@ +Vue.component('review-form', { + template: ` +
+

Leave a review

+ + + + + + + + + + + + +
+ `, + data() { + return { + name: '', + text: '', + rating: null, + } + }, + methods: { + onSubmit() { + const review = { + name: this.name, + text: this.text, + rating: this.rating, + } + this.$emit('review-submitted', review) + this.name = '' + this.text = '' + this.rating = null + }, + }, +}) diff --git a/components/ReviewList.js b/components/ReviewList.js new file mode 100644 index 0000000..a32cb5c --- /dev/null +++ b/components/ReviewList.js @@ -0,0 +1,20 @@ +Vue.component('review-list', { + template: ` +
+

There are no reviews yet.

+ +
+ `, + props: { + reviews: { + type: Array, + required: true, + }, + }, +}) diff --git a/index.html b/index.html new file mode 100644 index 0000000..10f98ff --- /dev/null +++ b/index.html @@ -0,0 +1,33 @@ + + + + + Vue Mastery + + + + + + + + + + + + +
+ + +
+

Cart({{ cart.length }})

+
+ +
+ + + + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..b3a4576 --- /dev/null +++ b/main.js @@ -0,0 +1,12 @@ +const app = new Vue({ + el: '#app', + data: { + premium: true, + cart: [], + }, + methods: { + updateCart(id) { + this.cart.push(id) + }, + }, +})