Simplify styling tags

This way we won't have to add the `inline-block` and `no-bullet` classes
to other elements and we can define the styles in one place.

Note we're using the `ul.tags` selector instead of just `.tags` to avoid
conflicts with a `div.tags` selector which is used to select tags in a
form. Renaming the selector to `.tag-list` would be better, but we
aren't doing so because it would break custom stylesheets using that
selector.

Also note we're keeping the %tags placeholder selector in `.tags`
selector in the participation.scss file. This is so styles are not
overwritten by selectors like `.debate-show ul li`, which has the same
specifity as `ul.tags li`.
This commit is contained in:
Javi Martín
2021-01-21 01:46:06 +01:00
parent bf7ff0d004
commit 0d3c4c8154
8 changed files with 29 additions and 14 deletions

View File

@@ -29,6 +29,7 @@
@import "jquery-ui/sortable"; @import "jquery-ui/sortable";
@import "leaflet"; @import "leaflet";
@import "sticky_overrides"; @import "sticky_overrides";
@import "tags";
@import "admin/*"; @import "admin/*";
@import "sdg/**/*"; @import "sdg/**/*";
@import "sdg_management/*"; @import "sdg_management/*";

View File

@@ -226,3 +226,13 @@
} }
} }
} }
%tags {
margin-bottom: 0;
margin-left: 0;
li {
display: inline-block;
margin-bottom: 0;
}
}

View File

@@ -408,10 +408,10 @@
} }
} }
.tags,
.geozone { .geozone {
li { li {
display: inline-block;
margin-bottom: 0; margin-bottom: 0;
} }
} }
@@ -487,8 +487,7 @@
} }
.tags { .tags {
display: block; @extend %tags;
margin-bottom: 0;
a { a {
margin-right: rem-calc(6); margin-right: rem-calc(6);
@@ -673,8 +672,7 @@
} }
.tags { .tags {
display: block; @extend %tags;
margin-bottom: 0;
a { a {
font-size: $tiny-font-size; font-size: $tiny-font-size;

View File

@@ -0,0 +1,6 @@
ul {
&.tags {
@extend %tags;
}
}

View File

@@ -47,9 +47,9 @@
<small><%= t("polls.index.geozone_info") %></small> <small><%= t("polls.index.geozone_info") %></small>
</p> </p>
<% end %> <% end %>
<ul class="no-bullet inline-block tags"> <ul class="tags">
<% poll.geozones.each do |g| %> <% poll.geozones.each do |g| %>
<li class="inline-block"><span><%= g.name %></span></li> <li><span><%= g.name %></span></li>
<% end %> <% end %>
</ul> </ul>
</div> </div>

View File

@@ -12,9 +12,9 @@
<%= auto_link_already_sanitized_html simple_format(@poll.summary) %> <%= auto_link_already_sanitized_html simple_format(@poll.summary) %>
<% if @poll.geozones.any? %> <% if @poll.geozones.any? %>
<ul class="no-bullet margin-top tags"> <ul class="margin-top tags">
<% @poll.geozones.each do |g| %> <% @poll.geozones.each do |g| %>
<li class="inline-block"><span><%= g.name %></span></li> <li><span><%= g.name %></span></li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>

View File

@@ -1,15 +1,15 @@
<%- limit ||= nil %> <%- limit ||= nil %>
<% if taggable.tags.any? %> <% if taggable.tags.any? %>
<ul id="tags_<%= dom_id(taggable) %>" class="no-bullet tags"> <ul id="tags_<%= dom_id(taggable) %>" class="tags">
<% taggable.tag_list_with_limit(limit).each do |tag| %> <% taggable.tag_list_with_limit(limit).each do |tag| %>
<li class="inline-block"> <li>
<%= link_to sanitize(tag.name), <%= link_to sanitize(tag.name),
polymorphic_path(taggable.class, search: tag.name) %></li> polymorphic_path(taggable.class, search: tag.name) %></li>
<% end %> <% end %>
<% if taggable.tags_count_out_of_limit(limit) > 0 %> <% if taggable.tags_count_out_of_limit(limit) > 0 %>
<li class="inline-block"> <li>
<%= link_to "#{taggable.tags_count_out_of_limit(limit)}+", <%= link_to "#{taggable.tags_count_out_of_limit(limit)}+",
polymorphic_path(taggable) %> polymorphic_path(taggable) %>
</li> </li>

View File

@@ -2,9 +2,9 @@
<h4><%= interests_title_text(user) %></h4> <h4><%= interests_title_text(user) %></h4>
<% if user.interests.any? %> <% if user.interests.any? %>
<ul class="no-bullet tags"> <ul class="tags">
<% user.interests.each do |interest| %> <% user.interests.each do |interest| %>
<li class="inline-block"><span><%= interest %></span></li> <li><span><%= interest %></span></li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>