forked from googlearchive/more-routing
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpolyfora-forum.html
112 lines (86 loc) · 2.86 KB
/
polyfora-forum.html
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!--
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../../paper-styles/shadow.html">
<link rel="import" href="../../paper-styles/typography.html">
<link rel="import" href="../more-route.html">
<link rel="import" href="polyfora-user-ref.html">
<dom-module id="polyfora-forum">
<style>
:host {
display: block;
padding: 16px;
}
header {
@apply(--paper-font-headline);
}
.headers {
@apply(--paper-font-caption);
@apply(--layout-horizontal);
margin-bottom: -8px;
}
.headers > * {
padding: 0 8px;
}
.title {
@apply(--layout-flex);
}
.author {
width: 80px;
}
.thread {
@apply(--shadow-elevation-2dp);
@apply(--layout-horizontal);
@apply(--paper-font-subhead);
margin: 8px 0;
cursor: pointer;
}
.thread > * {
padding: 8px;
}
</style>
<template>
<more-route context name="forum" params="{{params}}"></more-route>
<header>{{_forum.title}}</header>
<section class="headers" layout horizontal>
<div class="title">Thread</div>
<div class="posts">Posts</div>
<div class="author">Author</div>
</section>
<template is="dom-repeat" items="[[_forum.threads]]" as="thread">
<section class="thread" layout horizontal center on-tap="_onThreadTapped" thread-id$="[[thread.id]]">
<div class="title">[[thread.title]]</div>
<div class="posts">[[thread.posts.length]]</div>
<polyfora-user-ref class="author" user="[[thread.author]]"></polyfora-user-ref>
</section>
</template>
</template>
<script>
Polymer({
is: 'polyfora-forum',
properties: {
data: Object,
},
observers: [
'_forumChanged(params.forumId, data)',
],
_forumChanged: function() {
this._forum = this.data && this.data.forumsById[this.params.forumId];
},
_onThreadTapped: function(event) {
var threadId = event.currentTarget.getAttribute('thread-id');
// In addition to routing via a `more-route` element, more-routing's
// JavaScript API also exposes helpers:
MoreRouting.navigateTo('thread', {forumId: this._forum.id, threadId: threadId});
event.stopPropagation();
},
});
</script>
</dom-module>