Skip to content

Commit 9026c7b

Browse files
committed
Completed Course
1 parent 1d5f2eb commit 9026c7b

12 files changed

+6350
-3
lines changed

components/CardComponent.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
landing.component("card-component", {
2+
props: {
3+
title: {
4+
type: String,
5+
required: true
6+
},
7+
description: {
8+
type: String,
9+
required: true
10+
},
11+
link: {
12+
type: Object,
13+
required: true
14+
}
15+
},
16+
template:
17+
/*html*/
18+
`<div class="card">
19+
<h2>{{ title }}</h2>
20+
<img :src="link.image" width="400" height="400"/>
21+
<br />
22+
<p>{{ description }}</p>
23+
<br /><br />
24+
<a :href="link.url" class="button">Visit {{ title }} website</a>
25+
</div>`
26+
})

components/FinalComponent.js

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
final.component("game-detail", {
2+
template:
3+
/*html*/
4+
`<table>
5+
<thead>
6+
<tr>
7+
<th class="table-columns"
8+
v-for="key in columns"
9+
@click="sortBy(key)"
10+
:class="{ active: sortKey === key }">
11+
{{ key }}
12+
<span class="arrow" :class="sortColumns[key] > 0 ? 'asc' : 'desc'"></span>
13+
</th>
14+
</tr>
15+
</thead>
16+
<tbody>
17+
<tr v-for="game in filteredTitles">
18+
<td v-for="key in columns" class="game-data" :class="game[key] == 'Y'? 'yes' : game[key] == 'N' ? 'no' : ''"><span>{{ game[key] }}</span></td>
19+
</tr>
20+
</tbody>
21+
</table>`,
22+
props: {
23+
entries: {
24+
type: Array,
25+
required: true
26+
},
27+
columns: {
28+
type: Array,
29+
required: true
30+
},
31+
filterKey: {
32+
type: String,
33+
required: true
34+
}
35+
},
36+
data: function() {
37+
return {
38+
sortKey: ""
39+
}
40+
},
41+
computed: {
42+
filteredTitles: function() {
43+
const sortKey = this.sortKey
44+
const filterKey = this.filterKey && this.filterKey.toLowerCase()
45+
const order = this.sortColumns[sortKey] || 1
46+
47+
let entries = this.entries
48+
if (filterKey) {
49+
entries = entries.filter(function(row) {
50+
return Object.keys(row).some(function(key) {
51+
return (
52+
String(row[key])
53+
.toLowerCase()
54+
.indexOf(filterKey) > -1
55+
)
56+
})
57+
})
58+
}
59+
60+
if (sortKey) {
61+
entries = entries.slice().sort(function(x,y) {
62+
x = x[sortKey]
63+
y = y[sortKey]
64+
65+
return (x === y ? 0 : x > y ? 1 : -1) * order
66+
})
67+
}
68+
69+
return entries
70+
71+
},
72+
73+
sortColumns() {
74+
const sortedColumns = {}
75+
76+
this.columns.forEach(function(key) {
77+
sortedColumns[key] = 1
78+
})
79+
80+
return sortedColumns
81+
}
82+
},
83+
methods: {
84+
capitalize(data) {
85+
return data.charAt(0).toUpperCase() + data.slice(1)
86+
},
87+
88+
sortBy(key) {
89+
this.sortKey = key
90+
this.sortColumns[key] = this.sortColumns[key] * -1
91+
}
92+
}
93+
})

components/ToDoComponent.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
toDo.component("todo-item", {
2+
props: {
3+
title: {
4+
type: String,
5+
required: true
6+
}
7+
},
8+
template:
9+
/*html*/
10+
`<li>
11+
<h4>{{ title }}</h4>
12+
<button @click="$emit('remove')">Remove Task</button>
13+
</li>`
14+
})

final.html

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>To Do List</title>
6+
<link href="style.css" rel="stylesheet" type="text/css" />
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" integrity="sha512-5A8nwdMOWrSz20fDsjczgUidUBR8liPYU+WymTZP1lmY9G6Oc7HlZv156XqnsgNUzTyMefFTcsFH/tnJE/+xBg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
8+
<script src="https://unpkg.com/vue@next"></script>
9+
</head>
10+
<body>
11+
<div id="final">
12+
<h1>Final Project</h1>
13+
<div id="game-database">
14+
<form id="search">
15+
<label for="search">Search: <input type="text" id="search" v-model="searchInput" /></label>
16+
</form>
17+
<br />
18+
<game-detail
19+
:entries="dataset"
20+
:columns="dataColumns"
21+
:filter-key="searchInput"
22+
></game-detail>
23+
</div>
24+
</div>
25+
26+
<script src="final.js"></script>
27+
<script src="./components/FinalComponent.js"></script>
28+
<script>const mountedFinal = final.mount("#final")</script>
29+
</body>
30+
</html>

0 commit comments

Comments
 (0)