@wral/active-alerts 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/define.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -4,13 +4,13 @@ const v = {
|
|
|
4
4
|
lg: 1366
|
|
5
5
|
}, y = "https://api.wral.com/alerts/v1/active/alerts", x = "https://assets.wral.com/a1cc0e86-adab-48e9-bd80-703cd2c56aff?w=1200&h=630", $ = (e) => String(e || "Alert").replace(/[^\p{L}\p{N}]/gu, " ").replace(/\s+/g, " ").trim() || "Alert", I = (e) => {
|
|
6
6
|
if (!e) return null;
|
|
7
|
-
const t = e.link || e.url || e.href || "",
|
|
8
|
-
if (!
|
|
9
|
-
const a = String(e.topic || "").trim(),
|
|
7
|
+
const t = e.link || e.url || e.href || "", l = e.title || e.headline || "";
|
|
8
|
+
if (!l) return null;
|
|
9
|
+
const a = String(e.topic || "").trim(), s = a.toLowerCase(), r = e.caption || a || "Alert", n = e.image || e.imageUrl || e.image_url || x;
|
|
10
10
|
return {
|
|
11
11
|
url: t,
|
|
12
|
-
title:
|
|
13
|
-
topic:
|
|
12
|
+
title: l,
|
|
13
|
+
topic: s || a,
|
|
14
14
|
caption: r,
|
|
15
15
|
image: n,
|
|
16
16
|
body: e.body || e.summary || "",
|
|
@@ -178,6 +178,7 @@ class _ extends g {
|
|
|
178
178
|
}
|
|
179
179
|
@media (max-width: 720px) {
|
|
180
180
|
.wrapper { padding: .75rem .75rem 1.25rem; }
|
|
181
|
+
.alert-card { grid-template-columns: 1fr; }
|
|
181
182
|
}
|
|
182
183
|
`;
|
|
183
184
|
async firstUpdated() {
|
|
@@ -219,7 +220,7 @@ class _ extends g {
|
|
|
219
220
|
this._refreshId && (globalThis.clearInterval(this._refreshId), this._refreshId = null);
|
|
220
221
|
}
|
|
221
222
|
render() {
|
|
222
|
-
const { items: t, loading:
|
|
223
|
+
const { items: t, loading: l, error: a } = this, s = (r, n) => {
|
|
223
224
|
const o = A(r.effectiveFrom), h = String(r.topic || "").trim().toLowerCase(), c = r.title || r.body, d = String(r.title || "").trim(), m = String(r.body || "").trim(), f = d && m && d !== m ? r.body : "", p = i`
|
|
224
225
|
<div class="thumb">
|
|
225
226
|
<img
|
|
@@ -260,17 +261,17 @@ class _ extends g {
|
|
|
260
261
|
return i`
|
|
261
262
|
<div class="wrapper" role="region" aria-live="polite">
|
|
262
263
|
<div class="heading">
|
|
263
|
-
${
|
|
264
|
+
${l ? i`<span class="pill">Loading…</span>` : ""}
|
|
264
265
|
</div>
|
|
265
266
|
|
|
266
267
|
${a ? i`<div class="status error">${a}</div>` : ""}
|
|
267
|
-
${!a && !
|
|
268
|
+
${!a && !l && !t.length ? i`
|
|
268
269
|
<div class="empty">No active alerts right now.</div>
|
|
269
270
|
` : ""}
|
|
270
271
|
|
|
271
272
|
${t.length ? i`
|
|
272
273
|
<ul class="list">
|
|
273
|
-
${t.map(
|
|
274
|
+
${t.map(s)}
|
|
274
275
|
</ul>
|
|
275
276
|
` : ""}
|
|
276
277
|
</div>
|