Extract mixin to add font awesome icons
This way we can simplify the HTML and easily apply font awesome icons to
any element.
Note the mixin uses `extend`, which we generally try to avoid. It's OK
in this case, since `fa-` classes only have one rule, affecting the
content of its `::before` pseudo-element. Unfortunately we can't use
`include fa-content($fa-var-#{$icon})` because it's not valid SCSS. We
could make the mixin accept an icon instead of an icon name, and call it
using `has-fa-icon(r, $fa-var-plus-square)`. However, IMHO that would
make the code a bit more complex with no real benefit.
This commit is contained in:
@@ -2045,10 +2045,6 @@ table {
|
||||
padding: $line-height / 4;
|
||||
position: relative;
|
||||
|
||||
.relative {
|
||||
padding-left: rem-calc(18);
|
||||
}
|
||||
|
||||
.divider {
|
||||
color: $text-light;
|
||||
display: inline-block;
|
||||
@@ -2060,23 +2056,22 @@ table {
|
||||
}
|
||||
|
||||
.responses-count {
|
||||
.far {
|
||||
@extend .fa-minus-square;
|
||||
font-size: $small-font-size;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
text-decoration: none;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.show-children {
|
||||
@include has-fa-icon(plus-square, r);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.collapse-children {
|
||||
@include has-fa-icon(minus-square, r);
|
||||
}
|
||||
|
||||
.show-children::before,
|
||||
.collapse-children::before {
|
||||
margin-right: rem-calc(6);
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
&.collapsed {
|
||||
.far {
|
||||
@extend .fa-plus-square;
|
||||
}
|
||||
|
||||
.collapse-children {
|
||||
display: none;
|
||||
|
||||
@@ -148,3 +148,18 @@
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin has-fa-icon($icon, $style) {
|
||||
@extend .fa-#{$icon};
|
||||
|
||||
&::before {
|
||||
@extend %fa-icon;
|
||||
font-family: "Font Awesome 5 Free";
|
||||
|
||||
@if $style == "r" {
|
||||
font-weight: normal;
|
||||
} @else {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<% if count > 0 %>
|
||||
<%= link_to "", class: "js-toggle-children relative" do %>
|
||||
<span class="far"></span>
|
||||
<%= link_to "", class: "js-toggle-children" do %>
|
||||
<span class="show-children"><%= t("comments.comment.responses_show", count: count) %></span>
|
||||
<span class="collapse-children"><%= t("comments.comment.responses_collapse", count: count) %></span>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user