-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathnews-list-item.js
136 lines (112 loc) · 2.97 KB
/
news-list-item.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
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
/**
@license
Copyright (c) 2018 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
*/
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';
import '@polymer/iron-flex-layout/iron-flex-layout.js';
import './news-img.js';
class NewsListItem extends PolymerElement {
static get template() {
return html`
<style>
:host {
display: block;
}
a {
display: block;
position: relative;
text-decoration: none;
color: inherit;
overflow: hidden;
}
news-img {
height: 150px;
}
h2 {
margin: 18px 0;
font-weight: 400;
font-size: 20px;
line-height: 28px;
}
.category {
padding: 6px 20px 7px;
border: var(--app-border-style);
display: inline-block;
font-weight: bold;
font-size: 11px;
}
.category[hidden] {
visibility: hidden;
height: 0px;
margin-top: 0px;
padding: 0px;
}
.details {
@apply --layout-horizontal;
font-size: 11px;
font-weight: bold;
}
.time-ago {
white-space: nowrap;
}
.author {
padding-left: 35px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* mobile */
@media (max-width: 767px) {
news-img {
display: none;
}
}
/* desktop */
@media (min-width: 768px) {
:host([horizontal]) {
margin-bottom: 24px;
}
.category {
margin-top: 20px;
}
}
/* desktop large */
@media (min-width: 1310px) {
:host([horizontal]) a {
@apply --layout-horizontal;
}
:host([horizontal]) news-img {
min-width: 150px;
margin-right: 24px;
}
:host([horizontal]) .category {
display: none;
}
}
</style>
<a href\$="[[item.href]]">
<news-img src="[[item.imageUrl]]" alt="[[item.headline]]"></news-img>
<div class="headline">
<div class="category" hidden\$="[[!item.category]]">[[item.category]]</div>
<h2>[[item.headline]]</h2>
<div class="details">
<div class="time-ago">[[item.timeAgo]]</div>
<div class="author">[[item.author]]</div>
</div>
</div>
</a>
`;
}
static get is() { return 'news-list-item'; }
static get properties() { return {
item: {
type: Object
}
}}
}
customElements.define(NewsListItem.is, NewsListItem);