From 53c0bd89b9c5d49a496078cd6d127d01399e521d Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sat, 12 May 2018 14:46:13 +0100 Subject: [PATCH] Use old post anchors. Highlight anchored post. --- redesign/nimforum.scss | 13 +++++++++++++ redesign/post.nim | 8 +++++++- redesign/postlist.nim | 5 +---- redesign/replybox.nim | 5 +++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/redesign/nimforum.scss b/redesign/nimforum.scss index c62b9b3..a7fcdcb 100644 --- a/redesign/nimforum.scss +++ b/redesign/nimforum.scss @@ -213,6 +213,19 @@ $views-color: #545d70; @extend .tile; border-top: 1px solid $border-color; padding-top: $control-padding-y-lg; + + &:target .post-main { + animation: highlight 2000ms ease-out; + } +} + +@keyframes highlight { + 0% { + background-color: lighten($primary-color, 20%); + } + 100% { + background-color: inherit; + } } .post-icon { diff --git a/redesign/post.nim b/redesign/post.nim index da0ac10..8d7b8da 100644 --- a/redesign/post.nim +++ b/redesign/post.nim @@ -1,4 +1,7 @@ +import strformat + import threadlist +import karaxutils type PostInfo* = object @@ -15,4 +18,7 @@ type ## post in a thread for example. history*: seq[PostInfo] ## If the post was edited this will contain the ## older versions of the post. - info*: PostInfo \ No newline at end of file + info*: PostInfo + +proc renderPostUrl*(post: Post, thread: Thread): string = + makeUri(fmt"/t/{thread.id}#{post.id}") \ No newline at end of file diff --git a/redesign/postlist.nim b/redesign/postlist.nim index a6c8755..a28585b 100644 --- a/redesign/postlist.nim +++ b/redesign/postlist.nim @@ -56,9 +56,6 @@ when defined(js): else: state.list = some(list) - proc renderPostUrl(post: Post, thread: Thread): string = - makeUri(fmt"/t/{thread.id}/p/{post.id}") - proc onReplyClick(e: Event, n: VNode, p: Option[Post]) = state.replyingTo = p state.replyBox.show() @@ -66,7 +63,7 @@ when defined(js): proc genPost(post: Post, thread: Thread, isLoggedIn: bool): VNode = let postCopy = post # TODO: Another workaround here, closure capture :( result = buildHtml(): - tdiv(class="post"): + tdiv(class="post", id = $post.id): tdiv(class="post-icon"): render(post.author, "post-avatar") tdiv(class="post-main"): diff --git a/redesign/replybox.nim b/redesign/replybox.nim index 883c1a2..752e01f 100644 --- a/redesign/replybox.nim +++ b/redesign/replybox.nim @@ -47,6 +47,11 @@ when defined(js): else: text "Replying to " renderUserMention(post.get().author) + tdiv(class="post-buttons", + style=style(StyleAttr.marginTop, "-0.3rem")): + a(href=renderPostUrl(post.get(), thread)): + button(class="btn"): + italic(class="fas fa-arrow-up") tdiv(class="information-content"): tdiv(class="panel"): tdiv(class="panel-nav"):