Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L7 end #148

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ body {
margin: 25px 100px;
float: right;
border: 1px solid #d8d8d8;
padding: 10px 30px;
padding: 30px 30px;
background-color: white;
-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);
Expand Down
46 changes: 43 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,54 @@
<!-- Import Styles -->
<link rel="stylesheet" href="./assets/styles.css" />
<!-- Import Vue.js -->
<script src="https://unpkg.com/vue@3.0.0-beta.12/dist/vue.global.js"></script>
<script src="https://unpkg.com/vue@3.0.11/dist/vue.global.js"></script>
</head>
<body>
<div id="app">
<h1>Product goes here</h1>
<div class="nav-bar"></div>

<div class="cart">Cart({{ cart }})</div>

<div class="product-display">
<div class="product-container">
<div class="product-image">
<!-- solution -->
<img :class="{ 'out-of-stock-img': !inStock }" v-bind:src="image">
<!-- solution -->
</div>
<div class="product-info">
<h1>{{ product }}</h1>
<p v-if="inStock">In Stock</p>
<p v-else>Out of Stock</p>
<ul>
<li v-for="detail in details">{{ detail }}</li>
</ul>

<div
v-for="variant in variants"
:key="variant.id"
@mouseover="updateImage(variant.image)"
class="color-circle"
:style="{ backgroundColor: variant.color }">
</div>

<button
class="button"
:class="{ disabledButton: !inStock }"
:disabled="!inStock"
@click="addToCart">
Add to Cart
</button>
</div>
</div>
</div>
</div>

<!-- Import Js -->
<script src="./main.js"></script>

<!-- Mount App -->
<script>
const mountedApp = app.mount('#app')
</script>
</body>
</html>
25 changes: 24 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
const product = 'Socks'
const app = Vue.createApp({
data() {
return {
cart:0,
product: 'Socks',
brand: 'Vue Mastery',
image: './assets/images/socks_blue.jpg',
inStock: false,
details: ['50% cotton', '30% wool', '20% polyester'],
variants: [
{ id: 2234, color: 'green', image: './assets/images/socks_green.jpg' },
{ id: 2235, color: 'blue', image: './assets/images/socks_blue.jpg' },
]
}
},
methods: {
addToCart() {
this.cart += 1
},
updateImage(variantImage) {
this.image = variantImage
}
}
})