Skip to content

Commit 64a1d6a

Browse files
author
Shaun Pelling
committed
added lesson 11 code
1 parent 96bf558 commit 64a1d6a

File tree

3 files changed

+15
-29
lines changed

3 files changed

+15
-29
lines changed

app.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
new Vue({
22
el: '#vue-app',
33
data: {
4-
available: false,
5-
nearby: false
4+
error: false,
5+
success: false
66
},
77
methods: {
88

99
},
1010
computed: {
11-
compClasses: function(){
12-
return{
13-
available: this.available,
14-
nearby: this.nearby,
15-
}
16-
}
11+
1712
}
1813
});

index.html

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@
88
</head>
99
<body>
1010
<div id="vue-app">
11-
<h1>Dynamic CSS</h1>
12-
<!-- <h2>Example 1</h2>
13-
<div v-on:click="available = !available" v-bind:class="{available: available}">
14-
<span>Ryu</span>
15-
</div> -->
16-
<h2>Example 2</h2>
17-
<button v-on:click="nearby = !nearby">Toggle nearby</button>
18-
<button v-on:click="available = !available">Toggle available</button>
19-
<div v-bind:class="compClasses">
20-
<span>Ryu</span>
21-
</div>
11+
<h1>Conditionals</h1>
12+
<button v-on:click="error = !error">Toggle error</button>
13+
<button v-on:click="success = !success">Toggle success</button>
14+
<!-- <p v-if="error" class="error">There has been an error</p>
15+
<p v-if="success" class="success">Whooo, success :)</p> -->
16+
<p v-show="error" class="error">There has been an error</p>
17+
<p v-show="success" class="success">Whooo, success :)</p>
2218
</div>
2319
</body>
2420

styles.css

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
span{
1+
.error{
22
background: red;
3-
display: inline-block;
43
padding: 10px;
5-
color: #fff;
6-
margin: 10px 0;
4+
color: white;
75
}
86

9-
.available span{
7+
.success{
108
background: green;
11-
}
12-
13-
.nearby span:after{
14-
content: "nearby";
15-
margin-left: 10px;
9+
padding: 10px;
10+
color: white;
1611
}

0 commit comments

Comments
 (0)