Add links back to HN

This commit is contained in:
Jeremy Dormitzer 2018-01-20 15:53:26 -05:00
parent 714ff39929
commit 93e407d32b
No known key found for this signature in database
GPG Key ID: 04F17C0F5A32C320
7 changed files with 77 additions and 10 deletions

View File

@ -285,6 +285,18 @@ html, body {
justify-content: center;
}
.commentHeader {
display: flex;
align-items: center;
justify-content: space-between;
}
.storyHeader {
display: flex;
align-items: flex-start;
justify-content: space-between;
}
.title30 {
font-size: 22px;
font-weight: 300;

6
ext/icons/back-16.svg Normal file
View File

@ -0,0 +1,6 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="context-fill" d="M15 7H3.414l4.293-4.293a1 1 0 0 0-1.414-1.414l-6 6a1 1 0 0 0 0 1.414l6 6a1 1 0 0 0 1.414-1.414L3.414 9H15a1 1 0 0 0 0-2z"></path>
</svg>

After

Width:  |  Height:  |  Size: 464 B

7
ext/icons/link-16.svg Normal file
View File

@ -0,0 +1,7 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<rect fill="context-fill" x="7" y="3.286" width="2" height="9.429" rx="1" ry="1" transform="rotate(-45 8 8)"></rect>
<path fill="context-fill" d="M2.354 4.522L4.485 2.39a.5.5 0 0 1 .711 0l3.19 3.19.014-.015a2 2 0 0 0 0-2.821L6.272.616a2 2 0 0 0-2.821 0L.616 3.451a2 2 0 0 0 0 2.821L2.744 8.4a1.993 1.993 0 0 0 2.8.02l-3.19-3.186a.5.5 0 0 1 0-.712zm13.062 5.237L13.287 7.63a2 2 0 0 0-2.821 0l-.015.015 3.189 3.189a.5.5 0 0 1 0 .711l-2.132 2.132a.5.5 0 0 1-.711 0L7.61 10.49a1.993 1.993 0 0 0 .02 2.8l2.128 2.128a2 2 0 0 0 2.821 0l2.835-2.835a2 2 0 0 0 .002-2.824z"></path>
</svg>

After

Width:  |  Height:  |  Size: 879 B

View File

@ -0,0 +1,7 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#737373" d="M5 1H4a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-1a1 1 0 0 0-2 0v1a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h1a1 1 0 1 0 0-2z"></path>
<path fill="#737373" d="M14.935 1.618A1 1 0 0 0 14.012 1h-5a1 1 0 1 0 0 2h2.586L8.305 6.293A1 1 0 1 0 9.72 7.707l3.293-3.293V7a1 1 0 1 0 2 0V2a1 1 0 0 0-.077-.382z"></path>
</svg>

After

Width:  |  Height:  |  Size: 648 B

6
ext/icons/refresh-16.svg Normal file
View File

@ -0,0 +1,6 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="context-fill" d="M15 1a1 1 0 0 0-1 1v2.418A6.995 6.995 0 1 0 8 15a6.954 6.954 0 0 0 4.95-2.05 1 1 0 0 0-1.414-1.414A5.019 5.019 0 1 1 12.549 6H10a1 1 0 0 0 0 2h5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1z"></path>
</svg>

After

Width:  |  Height:  |  Size: 519 B

View File

@ -30,6 +30,22 @@
"commentsIndicator"
(caption30 (str num-replies " " (if (not= num-replies 1) "replies" "reply")))))
(defn with-listener [el type listener]
(events/listen el type listener)
el)
(defn item-link [id]
(with-listener
(dom/createDom "a"
(clj->js {:href (str "https://news.ycombinator.com/item?id=" id)
:target "_blank"})
(dom/createDom "img"
(clj->js {:src "icons/open-in-new-16.svg"
:width 12
:height 12})))
"click"
#(.stopPropagation %)))
(defn get-time-ago-str
"Returns the string '<number> <unit>' based on how long ago `timestamp` was,
for example '3 days' or '5 hours'"
@ -62,10 +78,6 @@
(for [i (range 1 6)]
(dom/createDom "div" (str "rect" i)))))
(defn with-listener [el type listener]
(events/listen el type listener)
el)
(defn with-classes [el & classes]
(doseq [class (filter #(not (string/blank? %)) classes)]
(classes/add el class))

View File

@ -74,18 +74,31 @@
(cons
(case (:type current-item)
"story" (components/card
(components/body30 (:title current-item))
(dom/createDom
"div"
"storyHeader"
(components/body30 (:title current-item))
(components/item-link (:id current-item)))
(components/story-caption (:points current-item)
(:author current-item)
(* (:created_at_i current-item) 1000)))
"comment" (components/card
(components/comment-caption (:author current-item)
(* (:created_at_i current-item) 1000))
(dom/createDom
"div"
"commentHeader"
(components/comment-caption (:author current-item)
(* (:created_at_i current-item) 1000))
(components/item-link (:id current-item)))
(components/comment-text (:text current-item))))
(map-indexed (fn [index child]
(-> (components/card
(components/comment-caption (:author child)
(* (:created_at_i child) 1000))
(dom/createDom
"div"
"commentHeader"
(components/comment-caption
(:author child)
(* (:created_at_i child) 1000))
(components/item-link (:id child)))
(components/comment-text (:text child))
(components/replies-indicator (count (:children child))))
(components/with-classes "child")
@ -105,7 +118,11 @@
(sort-by #(count (:children %)) #(compare %2 %1))))))
(:hits state) (map (fn [hit]
(-> (components/card
(components/body30 (:title hit))
(dom/createDom
"div"
"storyHeader"
(components/body30 (:title hit))
(components/item-link (:objectID hit)))
(components/story-caption (:points hit)
(:author hit)
(* (:created_at_i hit) 1000))