Skip to content

Commit 5519b4d

Browse files
committed
v1
1 parent eff0eea commit 5519b4d

File tree

3 files changed

+114
-68
lines changed

3 files changed

+114
-68
lines changed

01-HelloWorld/01-Socks.html

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<!-- https://www.vuemastery.com -->
2+
<html>
3+
<head>
4+
<script src="https://unpkg.com/vue"></script>
5+
<link href="./assets/style.css" rel="stylesheet" type="text/css">
6+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
7+
</head>
8+
<body>
9+
<div id="app">
10+
<div class="nav-bar"></div>
11+
<div class="product">
12+
<div class="product-image">
13+
<img v-bind:src="image" :title="imageTitle">
14+
<!-- Attribute Shorthands -->
15+
<!-- :src, :alt, :title, :class, :style, :disabled -->
16+
</div>
17+
18+
<div class="product-info">
19+
<!-- Binding -->
20+
<h1>{{ product }}</h1>
21+
22+
23+
<!-- Conditionals -->
24+
<div>
25+
<!-- Falsey will not include in DOM -->
26+
<p v-if="inventory > 10">In Stock</p>
27+
<p v-else-if="inventory">Almost sold out</p>
28+
<p v-else>Out of Stock</p>
29+
30+
<!-- Render with display: none -->
31+
<p v-show="inventory < 0">Wuuk?</p>
32+
</div>
33+
34+
35+
<!-- Events -->
36+
<button
37+
v-on:click="cart++; inventory--"
38+
:disabled="!inventory"
39+
:class="{disabledButton: inventory ? false : true}"
40+
>
41+
<!-- Method: addToCart -->
42+
Add to Cart
43+
</button>
44+
45+
<div class="cart">
46+
{{cart}}
47+
<i class="fas fa-shopping-cart"></i>
48+
</div>
49+
50+
51+
<!-- Loops -->
52+
<div v-for="variant in variants"
53+
:key="variant.id"
54+
class="color-box"
55+
:style="{backgroundColor: variant.color}"
56+
@mouseover="setImage(variant.color)">
57+
</div>
58+
</div>
59+
</div>
60+
</div>
61+
</body>
62+
</html>
63+
64+
65+
<script type="text/javascript">
66+
const app = new Vue({
67+
el: '#app',
68+
data: {
69+
product: 'Socks',
70+
image: './assets/socks-green.jpg',
71+
imageTitle: 'Green Socks',
72+
variants: [
73+
{id: 1, color: 'green'},
74+
{id: 2, color: 'blue'}
75+
],
76+
inventory: 3,
77+
cart: 0
78+
},
79+
methods: {
80+
addToCart() {
81+
this.cart++;
82+
this.inventory--;
83+
},
84+
setImage(color) {
85+
console.log('Vue object with data and methods', this);
86+
this.image = `./assets/socks-${color}.jpg`;
87+
}
88+
},
89+
computed: {
90+
title() {
91+
// Return values are cached
92+
return this.product.toUpperCase();
93+
}
94+
}
95+
});
96+
console.log('Modify data directly from the console with `app.product = "Shoes";`');
97+
</script>
98+
99+
100+
<!-- livereload -->
101+
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>

01-HelloWorld/HelloWorld.html

Lines changed: 0 additions & 62 deletions
This file was deleted.

01-HelloWorld/assets/style.css

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ body {
77
.nav-bar {
88
background: linear-gradient(-90deg, #84CF6A, #16C0B0);
99
height: 60px;
10-
margin-bottom: 15px;
1110
}
1211

1312
.product {
1413
display: flex;
1514
flex-flow: wrap;
16-
padding: 1rem;
15+
padding: 0rem 1rem;
1716
}
1817

1918
img {
@@ -38,16 +37,24 @@ body {
3837
height: 40px;
3938
margin-top: 5px;
4039
}
40+
41+
.active {
42+
border: 2px solid black;
43+
}
4144

4245
.cart {
43-
margin-right: 25px;
44-
float: right;
46+
position: absolute;
4547
border: 1px solid #d8d8d8;
46-
padding: 5px 20px;
48+
padding: 11px 15px;
49+
top: 8px;
50+
right: 13px;
51+
color: royalblue;
52+
background-color: antiquewhite;
4753
}
4854

4955
button {
50-
margin-top: 30px;
56+
margin-top: -95px;
57+
float: right;
5158
border: none;
5259
background-color: #1E95EA;
5360
color: white;

0 commit comments

Comments
 (0)