-
Notifications
You must be signed in to change notification settings - Fork 4
/
x-chat-list.html
160 lines (141 loc) · 3.51 KB
/
x-chat-list.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!-- <link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout.html"> add to top with other imports -->
<!--
A single user list with a username, avatar, and desc.
##### Example
<x-chat-list avatar="url" username="name" message="hello" status="online" timestamp="1420145273945"></x-chat-list>
-->
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="x-translate.html">
<script src="bower_components/time-elements/time-elements.js"></script>
<dom-module id='x-chat-list'>
<style>
:host {
display: block;
position: relative;
width: 100%;
border-bottom: 1px solid #e0e0e0;
font-size: 16px;
min-height: 72px;
z-index: 0;
}
.user-list {
padding: 16px;
}
.avatar {
border-radius: 50%;
width: 40px;
height: 40px;
margin: 0 16px 0 0;
background: #9e9e9e url(lion.png);
background-size: contain;
position: relative;
}
.status {
position: absolute;
bottom: -3px;
right: -3px;
border-radius: 50%;
width: 14px;
height: 14px;
background-color: #7EDF25;
display: none;
}
.status.online {
display: block;
}
.username {
text-transform: capitalize;
font-weight: 500;
color: #919191;
line-height: 1.3em;
max-width: 90%;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.timestamp {
font-size: 0.75em;
color: #919191;
}
.avatar {
border: solid 3px silver;
}
.avatar.navy {
border-color: #393b79;
}
.avatar.slate {
border-color: #6b6ecf;
}
.avatar.olive {
border-color: #637939;
}
.avatar.moss {
border-color: #b5cf6b;
}
.avatar.chocolate {
border-color: #8c6d31;
}
.avatar.buttercup {
border-color: #e7ba52;
}
.avatar.maroon {
border-color: #843c39;
}
.avatar.cerise {
border-color: #d6616b;
}
.avatar.plum {
border-color: #7b4173;
}
.avatar.orchid {
border-color: #ce6dbd;
}
</style>
<template>
<section class="user-list layout horizontal">
<div id="avatar" class="avatar {{color}}">
<div class="status {{status}}"></div>
</div>
<div class="flex">
<div class="username">{{username}}</div>
<div class="text">{{text}}</div>
<div class="text"><x-translate query="{{text}}"></x-translate></div>
</div>
<time class="timestamp relative-time" is=datetime="{{timestamp}}"></time>
</section>
</template>
<script>
Polymer({
is: 'x-chat-list',
properties: {
avatar: {
type: 'String',
value: ''
},
color: {
type: 'String',
value: ''
},
username: {
type: 'String',
value: ''
},
text: {
type: 'String',
value: ''
},
status: {
type: 'String',
value: ''
},
timestamp: {
type: 'String',
value: new Date().toISOString()
}
},
ready: function () {
this.$.avatar.style.backgroundImage = 'url(' + this.avatar + ')';
}
});
</script>
</dom-module>