Skip to content

Commit 7429107

Browse files
author
Shaun Pelling
committed
added lesson 21 code example
1 parent dcabd4e commit 7429107

File tree

6 files changed

+110
-38
lines changed

6 files changed

+110
-38
lines changed

src/App.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
<template>
22
<div>
3-
<h1>{{ title }}</h1>
4-
<ninjas></ninjas>
3+
<app-header></app-header>
4+
<app-ninjas></app-ninjas>
5+
<app-footer></app-footer>
56
</div>
67
</template>
78

89
<script>
910
// Imports
10-
import Ninjas from './Ninjas.vue';
11+
import Header from './components/Header.vue';
12+
import Footer from './components/Footer.vue';
13+
import Ninjas from './components/Ninjas.vue';
1114
1215
export default {
1316
components: {
14-
'ninjas': Ninjas
17+
'app-header': Header,
18+
'app-footer': Footer,
19+
'app-ninjas': Ninjas
1520
},
1621
data () {
1722
return {
18-
title: 'Ninja App'
23+
1924
}
2025
}
2126
}
2227
</script>
2328

2429
<style>
25-
h1{
26-
color: purple;
30+
body{
31+
margin: 0;
32+
font-family: 'Nunito SemiBold';
2733
}
2834
</style>

src/Ninjas.vue

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

src/components/Footer.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<footer>
3+
<p>{{ copyright }}</p>
4+
</footer>
5+
</template>
6+
<script>
7+
export default {
8+
data(){
9+
return{
10+
copyright: 'Copyright 2017 Vue Ninjas'
11+
}
12+
}
13+
}
14+
</script>
15+
<style scoped>
16+
footer{
17+
background: #222;
18+
padding: 6px;
19+
}
20+
p{
21+
color: lightgreen;
22+
text-align: center;
23+
}
24+
</style>

src/components/Header.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<header>
3+
<h1>{{ title }}</h1>
4+
</header>
5+
</template>
6+
<script>
7+
export default {
8+
data(){
9+
return{
10+
title: 'Vue Ninjas'
11+
}
12+
}
13+
}
14+
</script>
15+
<style scoped>
16+
header{
17+
background: lightgreen;
18+
padding: 10px;
19+
}
20+
h1{
21+
color: #222;
22+
text-align: center;
23+
}
24+
</style>

src/components/Ninjas.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<div id="ninjas">
3+
<ul>
4+
<li v-for="ninja in ninjas" v-on:click="ninja.show = !ninja.show">
5+
<h2>{{ ninja.name }}</h2>
6+
<h3 v-show="ninja.show">{{ ninja.speciality }}</h3>
7+
</li>
8+
</ul>
9+
</div>
10+
</template>
11+
<script>
12+
export default {
13+
data(){
14+
return{
15+
ninjas: [
16+
{name: 'Ryu', speciality: 'Vue Components', show: false},
17+
{name: 'Crystal', speciality: 'HTML Wizardry', show: false},
18+
{name: 'Hitoshi', speciality: 'Click Events', show: false},
19+
{name: 'Tango', speciality: 'Conditionals', show: false},
20+
{name: 'Kami', speciality: 'Webpack', show: false},
21+
{name: 'Yoshi', speciality: 'Data Diggin', show: false}
22+
]
23+
}
24+
}
25+
}
26+
</script>
27+
<style scoped>
28+
#ninjas{
29+
width: 100%;
30+
max-width: 1200px;
31+
margin: 40px auto;
32+
padding: 0 20px;
33+
box-sizing: border-box;
34+
}
35+
ul{
36+
display: flex;
37+
flex-wrap: wrap;
38+
list-style-type: none;
39+
padding: 0;
40+
}
41+
li{
42+
flex-grow: 1;
43+
flex-basis: 300px;
44+
text-align: center;
45+
padding: 30px;
46+
border: 1px solid #222;
47+
margin: 10px;
48+
}
49+
</style>

src/main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import Vue from 'vue'
22
import App from './App.vue'
3-
//import Ninjas from './Ninjas.vue'
4-
5-
//Vue.component('ninjas', Ninjas);
63

74
new Vue({
85
el: '#app',

0 commit comments

Comments
 (0)