tag_set_presenter: refactor inline_tag_list_html.
* Sort tags by category in inline tag lists (on /comments page, /uploads page, and modqueue). * Move tags css to common/erb/tags.scss.erb.
This commit is contained in:
@@ -6,5 +6,5 @@
|
||||
// directory and load them explicitly to work around this.
|
||||
// https://github.com/rails/sass-rails/issues/185
|
||||
@import "specific/*";
|
||||
@import "specific/erb/posts";
|
||||
@import "specific/erb/mod_queue";
|
||||
@import "common/erb/tags";
|
||||
|
||||
25
app/assets/stylesheets/common/erb/tags.scss.erb
Normal file
25
app/assets/stylesheets/common/erb/tags.scss.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<% TagCategory.css_mapping.each do |category,cssmap| %>
|
||||
.category-<%= category %> a, a.tag-type-<%= category %>, .ui-state-focus a.tag-type-<%= category %> {
|
||||
color: <%= cssmap["color"] %>;
|
||||
|
||||
&:hover {
|
||||
color: <%= cssmap["hover"] %>;
|
||||
}
|
||||
}
|
||||
<% end %>
|
||||
|
||||
.category-banned a, a.tag-type-banned, .ui-state-focus a.tag-type-banned {
|
||||
color: black;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.inline-tag-list {
|
||||
ul {
|
||||
display: inline;
|
||||
|
||||
li {
|
||||
display: inline;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,12 +66,6 @@ div#c-comments {
|
||||
margin-right: 0.3em;
|
||||
}
|
||||
|
||||
div.list-of-tags {
|
||||
a {
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
div.notices {
|
||||
margin: 1em 0;
|
||||
}
|
||||
@@ -133,12 +127,6 @@ div#c-comments {
|
||||
div.post.blacklisted.blacklisted-active {
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.list-of-tags {
|
||||
span {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@import "../../common/000_vars.scss";
|
||||
@import "../common/000_vars.scss";
|
||||
|
||||
article.post-preview {
|
||||
height: 154px;
|
||||
@@ -179,21 +179,6 @@ body[data-user-can-approve-posts="true"] .post-preview {
|
||||
}
|
||||
}
|
||||
|
||||
<% TagCategory.css_mapping.each do |category,cssmap| %>
|
||||
.category-<%= category %> a, a.tag-type-<%= category %>, .ui-state-focus a.tag-type-<%= category %> {
|
||||
color: <%= cssmap["color"] %>;
|
||||
|
||||
&:hover {
|
||||
color: <%= cssmap["hover"] %>;
|
||||
}
|
||||
}
|
||||
<% end %>
|
||||
|
||||
.category-banned a, a.tag-type-banned,, .ui-state-focus a.tag-type-banned {
|
||||
color: black;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.post-count {
|
||||
color: #CCC;
|
||||
margin-left: 0.2em;
|
||||
@@ -41,14 +41,9 @@ class TagSetPresenter < Presenter
|
||||
end
|
||||
|
||||
# compact (horizontal) list, as seen in the /comments index.
|
||||
def inline_tag_list_html(template)
|
||||
@tags.map do |tag_name|
|
||||
<<-EOS
|
||||
<span class="category-#{categories[tag_name]}">
|
||||
#{template.link_to(tag_name.tr("_", " "), template.posts_path(tags: tag_name))}
|
||||
</span>
|
||||
EOS
|
||||
end.join.html_safe
|
||||
def inline_tag_list_html(template, classes: "inline-tag-list", **options)
|
||||
html = split_tag_list_html(template, category_list: TagCategory.categorized_list, headers: false, name_only: true, humanize_tags: true, **options)
|
||||
template.tag.span(html, class: classes)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user