aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mixins/comment.pug25
-rw-r--r--src/mixins/post.pug2
-rw-r--r--src/public/styles.css11
-rw-r--r--src/views/comments.pug11
-rw-r--r--src/views/single_comment_thread.pug10
5 files changed, 47 insertions, 12 deletions
diff --git a/src/mixins/comment.pug b/src/mixins/comment.pug
index f6d7b5e..a7bf9d9 100644
--- a/src/mixins/comment.pug
+++ b/src/mixins/comment.pug
@@ -1,9 +1,15 @@
1include ../utils 1include ../utils
2 2
3mixin infoContainer(data) 3mixin infoContainer(data, next_id, prev_id)
4 div.comment-info-container 4 div.comment-info-container
5 | #{fmtnum(data.ups)} ↑ 5 | #{fmtnum(data.ups)} ↑
6 |  ·  6 | · 
7 if next_id
8 a(href=`#${next_id}`).nav-link next
9 |  · 
10 if prev_id
11 a(href=`#${prev_id}`).nav-link prev
12 |  · 
7 span(class=`${data.is_submitter ? 'op' : ''}`) 13 span(class=`${data.is_submitter ? 'op' : ''}`)
8 | u/#{data.author} #{data.is_submitter ? '(op)' : ''} 14 | u/#{data.author} #{data.is_submitter ? '(op)' : ''}
9 |  ·  15 |  · 
@@ -17,7 +23,7 @@ mixin infoContainer(data)
17 return data.replies && data.replies.data && data.replies.data.children && data.replies.data.children.length > 0; 23 return data.replies && data.replies.data && data.replies.data.children && data.replies.data.children.length > 0;
18 } 24 }
19 25
20mixin comment(com, isfirst, parent_id) 26mixin comment(com, isfirst, parent_id, next_id, prev_id)
21 - var data = com.data 27 - var data = com.data
22 - var hasReplyData = hasReplies(data) 28 - var hasReplyData = hasReplies(data)
23 29
@@ -29,10 +35,17 @@ mixin comment(com, isfirst, parent_id)
29 div(class=`comment ${isfirst ? 'first' : ''}`) 35 div(class=`comment ${isfirst ? 'first' : ''}`)
30 details(id=`${data.id}` open="") 36 details(id=`${data.id}` open="")
31 summary.expand-comments 37 summary.expand-comments
32 +infoContainer(data) 38 +infoContainer(data, next_id, prev_id)
33 div.comment-body 39 div.comment-body
34 != data.body_html 40 != data.body_html
35 if hasReplyData 41 if hasReplyData
36 div.replies 42 div.replies
37 each reply in data.replies.data.children 43 - var total = data.replies.data.children.length
38 +comment(reply, false, parent_id) 44 each reply, index in data.replies.data.children
45 - var next_idx = index + 1
46 - var prev_idx = index - 1
47 - var next_com = next_idx < total ? data.replies.data.children[next_idx] : null
48 - var prev_com = prev_idx >= 0 ? data.replies.data.children[prev_idx] : null
49 - var next_id = next_com ? next_com.data.id : null
50 - var prev_id = prev_com ? prev_com.data.id : null
51 +comment(reply, false, parent_id, next_id, prev_id)
diff --git a/src/mixins/post.pug b/src/mixins/post.pug
index 4287801..027e42f 100644
--- a/src/mixins/post.pug
+++ b/src/mixins/post.pug
@@ -13,7 +13,7 @@ mixin post(p)
13 | #{fmtnum(p.ups)} ↑ 13 | #{fmtnum(p.ups)} ↑
14 span.post-author 14 span.post-author
15 | &nbsp;·&nbsp; 15 | &nbsp;·&nbsp;
16 by u/#{p.author} 16 | u/#{p.author}
17 | &nbsp;·&nbsp; 17 | &nbsp;·&nbsp;
18 | #{timeDifference(Date.now(), p.created * 1000)} 18 | #{timeDifference(Date.now(), p.created * 1000)}
19 | &nbsp;·&nbsp; 19 | &nbsp;·&nbsp;
diff --git a/src/public/styles.css b/src/public/styles.css
index 090205e..3114173 100644
--- a/src/public/styles.css
+++ b/src/public/styles.css
@@ -33,6 +33,10 @@
33 :root { font-family: InterVariable, sans-serif; } 33 :root { font-family: InterVariable, sans-serif; }
34} 34}
35 35
36html {
37 scroll-behavior: smooth;
38}
39
36body { 40body {
37 overflow-x: hidden; 41 overflow-x: hidden;
38 background-color: var(--bg-color); 42 background-color: var(--bg-color);
@@ -50,7 +54,8 @@ main {
50.info-container a, 54.info-container a,
51.comment-info-container a, 55.comment-info-container a,
52.sort-opts a, 56.sort-opts a,
53.more a { 57.more a
58{
54 text-decoration: none; 59 text-decoration: none;
55} 60}
56 61
@@ -565,3 +570,7 @@ form input[type="submit"]:hover {
565.about { 570.about {
566 padding-bottom: 20px; 571 padding-bottom: 20px;
567} 572}
573
574a.nav-link {
575 color: var(--text-color-muted);
576}
diff --git a/src/views/comments.pug b/src/views/comments.pug
index 844dfcc..bbd7855 100644
--- a/src/views/comments.pug
+++ b/src/views/comments.pug
@@ -59,5 +59,12 @@ html
59 hr 59 hr
60 60
61 div.comments-container 61 div.comments-container
62 each child in comments 62 - var total = comments.length
63 +comment(child, true, post.id) 63 each child, index in comments
64 - var next_idx = index + 1
65 - var prev_idx = index - 1
66 - var next_com = next_idx < total ? comments[next_idx] : null
67 - var prev_com = prev_idx >= 0 ? comments[prev_idx] : null
68 - var next_id = next_com ? next_com.data.id : null
69 - var prev_id = prev_com ? prev_com.data.id : null
70 +comment(child, true, post.id, next_id, prev_id)
diff --git a/src/views/single_comment_thread.pug b/src/views/single_comment_thread.pug
index 1f37e9f..b12da6f 100644
--- a/src/views/single_comment_thread.pug
+++ b/src/views/single_comment_thread.pug
@@ -16,6 +16,12 @@ html
16 div 16 div
17 p nothing to see here, this thread was shadow-banned? 17 p nothing to see here, this thread was shadow-banned?
18 else 18 else
19 each comment in comments 19 each comment, index in comments
20 +comment(comment, true, parent_id) 20 - var next_idx = index + 1
21 - var prev_idx = index - 1
22 - var next_com = next_idx < total ? comments[next_idx] : null
23 - var prev_com = prev_idx >= 0 ? comments[prev_idx] : null
24 - var next_id = next_com ? next_com.data.id : null
25 - var prev_id = prev_com ? prev_com.data.id : null
26 +comment(comment, true, parent_id, next_idx, prev_idx)
21 27