Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#52147] provide proper styling for icon-only columns

Tobias Dillmann8dcd011a4b17
diff --git a/app/components/projects/table_component.html.erb b/app/components/projects/table_component.html.erb
index d94300d71d6..59ffb873111 100644
--- a/app/components/projects/table_component.html.erb
+++ b/app/components/projects/table_component.html.erb
@@ -54,16 +54,6 @@ See COPYRIGHT and LICENSE files for more details.
</div>
</div>
</th>
- <%# elsif column.attribute == :favored %>
-<!-- <th>-->
-<!-- <div class="generic-table--header-outer">-->
-<!-- <div class="generic-table--header generic-table--header_centered generic-table--header_no-min-width">-->
-<!-- <span>-->
- <%#= render(Primer::Beta::Octicon.new(icon: "star-fill", color: :subtle, "aria-label": I18n.t(:label_favorite))) %>
-<!-- </span>-->
-<!-- </div>-->
-<!-- </div>-->
-<!-- </th>-->
<% else %>
<%= quick_action_table_header column.attribute, order_options(column, turbo: true) %>
<% end %>
diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb
index 0b2522c4c76..997774e7b12 100644
--- a/app/helpers/sort_helper.rb
+++ b/app/helpers/sort_helper.rb
@@ -347,13 +347,9 @@ module SortHelper
data = options.delete(:data) || {}
options[:title] = sort_header_title(column, caption, options)
+ options[:icon_only_header] = column == :favored
- additional_classes = ""
- if column == :favored
- additional_classes = "generic-table--header_centered generic-table--header_no-min-width"
- end
-
- within_sort_header_tag_hierarchy(options, sort_class(column), additional_classes) do
+ within_sort_header_tag_hierarchy(options, sort_class(column)) do
yield(column, caption, default_order, allowed_params:, param:, lang:, title: options[:title],
sortable: options.fetch(:sortable, false), data:)
end
@@ -573,10 +569,15 @@ module SortHelper
end
end
- def within_sort_header_tag_hierarchy(options, classes, sort_header_classes = "", &)
+ def within_sort_header_tag_hierarchy(options, classes, &)
+ # A column with all icon and no text requires other styles:
+ icon_header = options.fetch(:icon_only_header, false)
+ outer_classes = icon_header ? "generic-table--header_no-padding" : ""
+ inner_classes = icon_header ? "generic-table--header_centered generic-table--header_no-min-width" : ""
+
content_tag "th", options do
- content_tag "div", class: "generic-table--sort-header-outer" do
- content_tag "div", class: "generic-table--sort-header #{sort_header_classes}" do
+ content_tag "div", class: "generic-table--sort-header-outer #{outer_classes}" do
+ content_tag "div", class: "generic-table--sort-header #{inner_classes}" do
content_tag("span", class: classes, &)
end
end
diff --git a/frontend/src/global_styles/content/_table.sass b/frontend/src/global_styles/content/_table.sass
index f5566d7657d..aab02d6834d 100644
--- a/frontend/src/global_styles/content/_table.sass
+++ b/frontend/src/global_styles/content/_table.sass
@@ -282,6 +282,8 @@ thead.-sticky th
.generic-table--sort-header-outer
padding: 0 12px 0 6px
+ &.generic-table--header_no-padding
+ padding: 0
.generic-table--header-outer,
.generic-table--empty-header