From 122e27925679f794a1b0c4509e2221cad316dcbc Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Fri, 13 Jul 2018 09:16:48 +0900 Subject: [PATCH] Add helpful ids and classes for testing --- src/frontend/newthread.nim | 11 ++++++----- src/frontend/postlist.nim | 9 ++++++--- src/frontend/replybox.nim | 5 +++-- src/frontend/threadlist.nim | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/frontend/newthread.nim b/src/frontend/newthread.nim index 8e701a2..e75b6bb 100644 --- a/src/frontend/newthread.nim +++ b/src/frontend/newthread.nim @@ -49,7 +49,7 @@ when defined(js): tdiv(class="title"): p(): text "New Thread" tdiv(class="content"): - input(class="form-input", `type`="text", name="subject", + input(id="thread-title", class="form-input", `type`="text", name="subject", placeholder="Type the title here", oninput=(e: Event, n: VNode) => onSubjectChange(e, n, state)) if state.error.isSome(): @@ -58,10 +58,11 @@ when defined(js): renderContent(state.replyBox, none[Thread](), none[Post]()) tdiv(class="footer"): - button(class=class( - {"loading": state.loading}, - "btn btn-primary" + button(id="create-thread-btn", + class=class( + {"loading": state.loading}, + "btn btn-primary" ), onClick=(ev: Event, n: VNode) => (onCreateClick(ev, n, state))): - text "Create thread" \ No newline at end of file + text "Create thread" diff --git a/src/frontend/postlist.nim b/src/frontend/postlist.nim index 006af52..6a27df3 100644 --- a/src/frontend/postlist.nim +++ b/src/frontend/postlist.nim @@ -220,8 +220,11 @@ when defined(js): ): VNode = let postCopy = post # TODO: Another workaround here, closure capture :( + let originalPost = thread.author == post.author + result = buildHtml(): - tdiv(class=class({"highlight": highlight}, "post"), id = $post.id): + tdiv(class=class({"highlight": highlight, "original-post": originalPost}, "post"), + id = $post.id): tdiv(class="post-icon"): render(post.author, "post-avatar") tdiv(class="post-main"): @@ -326,7 +329,7 @@ when defined(js): let list = state.list.get() result = buildHtml(): section(class="container grid-xl"): - tdiv(class="title"): + tdiv(id="thread-title", class="title"): p(): text list.thread.topic if list.thread.isLocked: italic(class="fas fa-lock fa-xs", @@ -368,4 +371,4 @@ when defined(js): render(state.replyBox, list.thread, state.replyingTo, false) - render(state.deleteModal) \ No newline at end of file + render(state.deleteModal) diff --git a/src/frontend/replybox.nim b/src/frontend/replybox.nim index 8d56e1d..9d815f6 100644 --- a/src/frontend/replybox.nim +++ b/src/frontend/replybox.nim @@ -114,7 +114,8 @@ when defined(js): elif state.rendering.isSome(): verbatim(state.rendering.get()) else: - textarea(class="form-input post-text-area", rows="5", + textarea(id="reply-textarea", + class="form-input post-text-area", rows="5", onChange=(e: Event, n: VNode) => onChange(e, n, state), value=state.text) @@ -162,4 +163,4 @@ when defined(js): button(class="btn"): italic(class="fas fa-arrow-up") tdiv(class="information-content"): - renderContent(state, some(thread), post) \ No newline at end of file + renderContent(state, some(thread), post) diff --git a/src/frontend/threadlist.nim b/src/frontend/threadlist.nim index 710c2c5..cceca03 100644 --- a/src/frontend/threadlist.nim +++ b/src/frontend/threadlist.nim @@ -78,7 +78,7 @@ when defined(js): button(class="btn btn-link"): text "Categories" section(class="navbar-section"): if currentUser.isSome(): - a(href=makeUri("/newthread"), onClick=anchorCB): + a(id="new-thread-btn", href=makeUri("/newthread"), onClick=anchorCB): button(class="btn btn-secondary"): italic(class="fas fa-plus") text " New Thread" @@ -243,4 +243,4 @@ when defined(js): proc renderThreadList*(currentUser: Option[User]): VNode = result = buildHtml(tdiv): genTopButtons(currentUser) - genThreadList(currentUser) \ No newline at end of file + genThreadList(currentUser)