diff --git a/assets/styles.css b/assets/styles.css index c52316317..1a33ea71f 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -23,13 +23,15 @@ body { .cart { margin: 25px 100px; - float: right; border: 1px solid #d8d8d8; - padding: 10px 30px; + padding: 30px 30px; + margin-left: auto; + width: 50px; + justify-content: flex-end; background-color: white; + box-shadow: 2px 15px -12px rgba(0, 0, 0, 0.57); -webkit-box-shadow: 0px 2px 15px -12px rgba(0, 0, 0, 0.57); -moz-box-shadow: 0px 2px 15px -12px rgba(0, 0, 0, 0.57); - box-shadow: 2px 15px -12px rgba(0, 0, 0, 0.57); } .color-circle { diff --git a/components/ProductDisplay.js b/components/ProductDisplay.js new file mode 100644 index 000000000..df5c81632 --- /dev/null +++ b/components/ProductDisplay.js @@ -0,0 +1,79 @@ +app.component('product-display', { + props: { + premium: { + type: Boolean, + required: true + }, + details: { + type: Array, + required: true + } + }, + template: + /*html*/ + `
+
+
+ +
+
+

{{ title }}

+ +

In Stock

+

Out of Stock

+ +

Shipping: {{ shipping }}

+ +
    +
  • {{ detail }}
  • +
+ +
+
+ + +
+
+
`, + data() { + return { + product: 'Socks', + brand: 'Vue Mastery', + selectedVariant: 0, + variants: [ + { id: 2234, color: 'green', image: './assets/images/socks_green.jpg', quantity: 50 }, + { id: 2235, color: 'blue', image: './assets/images/socks_blue.jpg', quantity: 0 }, + ] + } + }, + methods: { + addToCart() { + this.cart += 1 + }, + updateVariant(index) { + this.selectedVariant = index + } + }, + computed: { + title() { + 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 SHIPPING' + } + return '$50.00' + } + } +}) \ No newline at end of file diff --git a/index.html b/index.html index 56c112638..33e0f48e4 100644 --- a/index.html +++ b/index.html @@ -6,14 +6,25 @@ - +
-

Product goes here

+ + +
Cart({{ cart }})
+ + + +
- + + + + diff --git a/main.js b/main.js index aedc73d86..5f1afff8c 100644 --- a/main.js +++ b/main.js @@ -1 +1,10 @@ -const product = 'Socks' +const app = Vue.createApp({ + data() { + return { + cart: 0, + premium: true + } + }, + methods: { + } +})