Skip to content

Commit bd803f9

Browse files
authored
Merge pull request #1874 from codidact/0valt/sidebar
2 parents e35b237 + ae19a27 commit bd803f9

File tree

4 files changed

+53
-32
lines changed

4 files changed

+53
-32
lines changed

app/assets/stylesheets/application.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ mjx-container {
287287
overflow-y: hidden;
288288
}
289289

290+
code,
291+
kbd {
292+
padding: {
293+
top: 0.1em;
294+
bottom: 0.1em;
295+
left: 0.25em;
296+
right: 0.25em;
297+
};
298+
}
299+
290300
kbd {
291301
border: {
292302
color: $muted-graphic;
@@ -302,10 +312,4 @@ kbd {
302312
left: 0.15em;
303313
right: 0.15em;
304314
};
305-
padding: {
306-
top: 0.1em;
307-
bottom: 0.1em;
308-
left: 0.25em;
309-
right: 0.25em;
310-
};
311315
}

app/assets/stylesheets/posts.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ h1 .badge.is-tag.is-master-tag {
6464
}
6565
}
6666

67+
.post-widget--title {
68+
line-height: 1.5em;
69+
70+
del {
71+
background-color: transparent;
72+
}
73+
}
74+
6775
.post-list--content {
6876
font-size: 14px;
6977
width: 100%;

app/views/layouts/_sidebar.html.erb

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,7 @@
7575
<% end %>
7676
<% end %>
7777

78-
<%# Hot Posts widget %>
79-
<% if Rails.env.development? || @hot_questions.to_a.size > 0 %>
80-
<% collapse_hot = user_preference('collapse_hot_posts') == 'true' %>
81-
<% cache @hot_questions do %>
82-
<div class="widget has-margin-4 is-tertiary" data-collapsed="<%= user_preference('collapse_hot_posts') %>">
83-
<div class="widget--header">
84-
Hot Posts
85-
<button type="button" class="widget--header-link button is-icon-only-button js-widget-hide"
86-
aria-label="Collapse Hot Posts">
87-
<i class="fas <%= collapse_hot ? 'fa-chevron-down' : 'fa-chevron-up' %>"></i>
88-
</button>
89-
</div>
90-
<% @hot_questions.each do |hq| %>
91-
<div class="widget--body <%= 'hidden' if collapse_hot %>">
92-
<% unless hq.category.nil? %>
93-
<%= hq.category.name %>
94-
&mdash;
95-
<% end %>
96-
<%= link_to generic_share_link(hq) do %>
97-
<%= hq.title %>
98-
<% end %>
99-
</div>
100-
<% end %>
101-
</div>
102-
<% end %>
103-
<% end %>
78+
<%= render 'shared/hot_posts', posts: @hot_questions %>
10479
<% end %>
10580

10681
<% if Rails.env.development? || rand(100) <= 10 %>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<%#
2+
"Render s a Hot Posts widget
3+
4+
Variables:
5+
posts : ActiveRecord::Relation<Post> to list in the widget
6+
"%>
7+
8+
<% if Rails.env.development? || posts.to_a.size > 0 %>
9+
<% collapse_hot = user_preference('collapse_hot_posts') == 'true' %>
10+
<% cache posts do %>
11+
<div class="widget has-margin-4 is-tertiary"
12+
data-collapsed="<%= user_preference('collapse_hot_posts') %>">
13+
<div class="widget--header">
14+
Hot Posts
15+
<button type="button"
16+
class="widget--header-link button is-icon-only-button js-widget-hide"
17+
aria-label="Collapse Hot Posts">
18+
<i class="fas <%= collapse_hot ? 'fa-chevron-down' : 'fa-chevron-up' %>"></i>
19+
</button>
20+
</div>
21+
<% posts.each do |post| %>
22+
<div class="widget--body <%= 'hidden' if collapse_hot %>">
23+
<% unless post.category.nil? %>
24+
<%= post.category.name %>
25+
&mdash;
26+
<% end %>
27+
<%= link_to generic_share_link(post), class: 'post-widget--title' do %>
28+
<%= rendered_title(post) %>
29+
<% end %>
30+
</div>
31+
<% end %>
32+
</div>
33+
<% end %>
34+
<% end %>

0 commit comments

Comments
 (0)