-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
62 lines (61 loc) · 1.61 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const submissionComponent = {
template: `
<div style="display: flex; width: 100%;">
<figure class="media-left">
<img
class="image is-64x64"
:src="submission.submissionImage"
/>
</figure>
<div class="media-content">
<div class="content">
<p>
<strong>
<a :href="submission.url" class="has-text-info"
>{{submission.title}}</a
>
<span class="tag is-small">#{{submission.id}}</span>
</strong>
<br />
{{submission.description}}
<br />
<small class="is-size-7">
Submitted by:
<img class="image is-24x24" :src="submission.avatar" />
</small>
</p>
</div>
</div>
<div class="media-right">
<span class="icon is-small">
<i class="fa fa-chevron-up" @click="vote(submission.id)"></i>
<strong class="has-text-info">{{submission.votes}}</strong>
</span>
</div>
</div>
`,
props: ['submission', 'submissions'],
methods: {
vote(submissionId) {
const submission = this.submissions.find(
(submission) => submission.id === submissionId
);
submission.votes++;
},
},
}
new Vue({
el: "#app",
data: {
config: config,
submissions: submissions,
},
computed: {
sortedSubmissions() {
return this.submissions.sort((a, b) => b.votes - a.votes);
},
},
components: {
'submission-component': submissionComponent
},
});