From a5c0fc3d72e2ecd19e50f93b92937359820d9e0e Mon Sep 17 00:00:00 2001 From: Zed Date: Sun, 13 Oct 2019 20:17:12 +0200 Subject: [PATCH] Add button to go back to top Fixes #72 --- src/sass/timeline.scss | 24 ++++++++++++++++++++++-- src/views/timeline.nim | 6 ++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/sass/timeline.scss b/src/sass/timeline.scss index 120935a..dcbbb92 100644 --- a/src/sass/timeline.scss +++ b/src/sass/timeline.scss @@ -7,8 +7,8 @@ .timeline { background-color: $bg_panel; - > div:not(:last-child) { - border-bottom: 1px solid $border_grey; + > div:not(:first-child) { + border-top: 1px solid $border_grey; } } @@ -121,6 +121,26 @@ } } +.top-ref { + background-color: #0f0f0f; + border-top: none !important; + + .icon-down { + font-size: 20px; + display: flex; + justify-content: center; + text-decoration: none; + + &:hover { + color: $accent_light; + } + + &::before { + transform: rotate(180deg) translateY(-1px); + } + } +} + .timeline-item { overflow-wrap: break-word; border-left-width: 0; diff --git a/src/views/timeline.nim b/src/views/timeline.nim index adf630f..023ab7b 100644 --- a/src/views/timeline.nim +++ b/src/views/timeline.nim @@ -32,6 +32,10 @@ proc renderNoneFound(): VNode = h2(class="timeline-none"): text "No items found" +proc renderToTop(): VNode = + buildHtml(tdiv(class="top-ref")): + icon "down", href="#" + proc renderThread(thread: seq[Tweet]; prefs: Prefs; path: string): VNode = buildHtml(tdiv(class="thread-line")): for i, threadTweet in thread.sortedByIt(it.id): @@ -68,6 +72,7 @@ proc renderTimelineUsers*(results: Result[Profile]; prefs: Prefs; path=""): VNod renderUser(user, prefs) if results.minId != "0": renderMore(results.query, results.minId) + renderToTop() elif results.beginning: renderNoneFound() else: @@ -98,3 +103,4 @@ proc renderTimelineTweets*(results: Result[Tweet]; prefs: Prefs; path: string): renderMore(results.query, results.minId) else: renderNoMore() + renderToTop()