From cbd6e117eaac9d2b88227d3ba0ca003cb286c6a0 Mon Sep 17 00:00:00 2001 From: MoshiKoi <54333972+MoshiKoi@users.noreply.github.com> Date: Tue, 3 Jan 2023 01:12:09 -0800 Subject: [PATCH 1/3] Make voting tool sticky --- app/assets/stylesheets/posts.scss | 5 +++ app/views/posts/_expanded.html.erb | 70 +++++++++++++++--------------- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/app/assets/stylesheets/posts.scss b/app/assets/stylesheets/posts.scss index a1a548af6..047e9b8aa 100644 --- a/app/assets/stylesheets/posts.scss +++ b/app/assets/stylesheets/posts.scss @@ -12,6 +12,11 @@ } } +.vote-widget { + position: sticky; + top: 0; +} + .post--container { max-width: 100%; diff --git a/app/views/posts/_expanded.html.erb b/app/views/posts/_expanded.html.erb index 82733701f..0b775b1e5 100644 --- a/app/views/posts/_expanded.html.erb +++ b/app/views/posts/_expanded.html.erb @@ -38,44 +38,46 @@
<% if post_type.has_votes %>
-
- <% existing_vote = my_vote(post) %> - <% unless post.locked? %> - - <% end %> -
- +<%= post.upvote_count %> -
-
- −<%= post.downvote_count %> -
- <% unless post.locked? %> - - <% end %> -
- <% if user_signed_in? && post.post_type.has_reactions && post.post_type.reactions.any? %> -
+
+
+ <% existing_vote = my_vote(post) %> <% unless post.locked? %> - + <% end %> +
+ +<%= post.upvote_count %> +
+
+ −<%= post.downvote_count %> +
+ <% unless post.locked? %> + <% end %>
- <% end %> + <% if user_signed_in? && post.post_type.has_reactions && post.post_type.reactions.any? %> +
+ <% unless post.locked? %> + + <% end %> +
+ <% end %> +
<% end %> From f6a8b2c113e32e9d847376658dbf14ef6cbcfb54 Mon Sep 17 00:00:00 2001 From: MoshiKoi <54333972+MoshiKoi@users.noreply.github.com> Date: Tue, 3 Jan 2023 01:36:52 -0800 Subject: [PATCH 2/3] Put post body in its own element --- app/views/posts/_expanded.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/posts/_expanded.html.erb b/app/views/posts/_expanded.html.erb index 0b775b1e5..38b661233 100644 --- a/app/views/posts/_expanded.html.erb +++ b/app/views/posts/_expanded.html.erb @@ -150,9 +150,10 @@ <% end %> <% end %> -
+
<%= raw(sanitize(post.body, scrubber: scrubber)) %> - +
+
<% been_edited = post.last_edited_by_id != nil %> <% if been_edited then last_edited_by_self = post.user_id == post.last_edited_by_id end %> From c7d45b3cf58ee6416566575c23f922c1eaa9a485 Mon Sep 17 00:00:00 2001 From: MoshiKoi <54333972+MoshiKoi@users.noreply.github.com> Date: Tue, 3 Jan 2023 07:38:19 -0800 Subject: [PATCH 3/3] Add sticky vote preference --- app/assets/stylesheets/posts.scss | 4 ++-- app/views/posts/_expanded.html.erb | 3 ++- config/config/preferences.yml | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/posts.scss b/app/assets/stylesheets/posts.scss index 047e9b8aa..59e004d26 100644 --- a/app/assets/stylesheets/posts.scss +++ b/app/assets/stylesheets/posts.scss @@ -12,9 +12,9 @@ } } -.vote-widget { +.sticky { position: sticky; - top: 0; + top: 50px; } .post--container { diff --git a/app/views/posts/_expanded.html.erb b/app/views/posts/_expanded.html.erb index 38b661233..7a6f2710f 100644 --- a/app/views/posts/_expanded.html.erb +++ b/app/views/posts/_expanded.html.erb @@ -38,7 +38,8 @@
<% if post_type.has_votes %>
-
+ <% sticky_votes = user_preference('sticky_vote_tool', community: false) == 'true' %> +
class="sticky" <% end %>>
<% existing_vote = my_vote(post) %> <% unless post.locked? %> diff --git a/config/config/preferences.yml b/config/config/preferences.yml index 36be0760a..8ecdcaabb 100644 --- a/config/config/preferences.yml +++ b/config/config/preferences.yml @@ -72,4 +72,10 @@ sticky_header: type: boolean description: > Make the top navigation bar sticky. + default: false + +sticky_vote_tool: + type: boolean + description: > + Make the up and downvote buttons scroll along with the post default: false \ No newline at end of file