Use CSS to show separators in moderation actions
This is useful for people using screen readers, since the character used as a separator won't be read aloud. Since many screen readers also read content generated via CSS pseudoelements, we aren't using `content: "|";` or similar but using elements with a very small width instead.
This commit is contained in:
@@ -7,4 +7,30 @@
|
|||||||
button {
|
button {
|
||||||
@include link;
|
@include link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mixin separator {
|
||||||
|
content: "";
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 0.3em;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
> * + *::before {
|
||||||
|
@include separator;
|
||||||
|
background: currentcolor;
|
||||||
|
height: 1em;
|
||||||
|
opacity: 0.5;
|
||||||
|
width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment & {
|
||||||
|
> *::before {
|
||||||
|
@include separator;
|
||||||
|
background: $text-light;
|
||||||
|
border-radius: 100%;
|
||||||
|
opacity: 1;
|
||||||
|
height: 0.25em;
|
||||||
|
width: 0.25em;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if can? :hide, author %>
|
<% if can? :hide, author %>
|
||||||
<%= raw separator %>
|
|
||||||
|
|
||||||
<%= render Admin::ActionComponent.new(
|
<%= render Admin::ActionComponent.new(
|
||||||
:block_author,
|
:block_author,
|
||||||
author,
|
author,
|
||||||
|
|||||||
@@ -19,12 +19,4 @@ class Shared::ModerationActionsComponent < ApplicationComponent
|
|||||||
def hide_path
|
def hide_path
|
||||||
polymorphic_path([:moderation, record], action: :hide)
|
polymorphic_path([:moderation, record], action: :hide)
|
||||||
end
|
end
|
||||||
|
|
||||||
def separator
|
|
||||||
if record.is_a?(Comment)
|
|
||||||
" • "
|
|
||||||
else
|
|
||||||
" | "
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<% if can?(:hide, comment) || can?(:hide, comment.user) %>
|
<% if can?(:hide, comment) || can?(:hide, comment.user) %>
|
||||||
<span class="divider"> • </span>
|
|
||||||
<% if comment.author == current_user %>
|
<% if comment.author == current_user %>
|
||||||
|
<span class="divider"> • </span>
|
||||||
<%= link_to t("comments.actions.delete"),
|
<%= link_to t("comments.actions.delete"),
|
||||||
hide_comment_path(comment),
|
hide_comment_path(comment),
|
||||||
method: :put, remote: true, class: "delete-comment",
|
method: :put, remote: true, class: "delete-comment",
|
||||||
|
|||||||
Reference in New Issue
Block a user