Skip to content

Commit

Permalink
Fix applications tables column alignment
Browse files Browse the repository at this point in the history
In #2341, the table component from `govuk_publishing_components` was
copied over and customised

In #2664, we migrated the applications tables to use this. In the
process, we lost the custom classes on the first two columns, which set
the widths to 1/4 and 1/3 respectively. This was noted as "acceptable"
in the PR body in exchange for improved consistency and other benefits
from using the component

However, since we have a custom version of the table component, it's
very easy for us to support custom classes. This was in fact done in the
same PR that copies the component into the Signon codebase, adding
custom class support for the outer table element in 4f09fbc

This adds support for custom classes in the headers, which is then used
to restore the old classes and therefore consistent column widths
between tables (irrespective of content width)

In #2341, it was suggested that we might try to get the customisations
merged upstream - it might be worth exploring that with both this and
earlier changes as a separate piece of work

#2341: #2341
#2664: #2664
  • Loading branch information
yndajas committed Jun 27, 2024
1 parent 4a12eaf commit 6092dc1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/helpers/components/table_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def row

def header(str, opt = {})
classes = %w[govuk-table__header]
classes << opt[:classes] if opt[:classes]
classes << "govuk-table__header--#{opt[:format]}" if opt[:format]
classes << "govuk-table__header--active" if opt[:sort_direction]
link_classes = %w[app-table__sort-link]
Expand Down
8 changes: 4 additions & 4 deletions app/views/account/applications/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<%= render "components/table", {
caption: "Apps you have access to",
head: [
{ text: "Name" },
{ text: "Description" },
{ text: "Name", classes: "govuk-!-width-one-quarter" },
{ text: "Description", classes: "govuk-!-width-one-third" },
{ text: content_tag(:span, "Actions", class: "govuk-visually-hidden") },
],
rows: @applications_with_signin.map do |application|
Expand All @@ -47,8 +47,8 @@
<%= render "components/table", {
caption: "Apps you don't have access to",
head: [
{ text: "Name" },
{ text: "Description" },
{ text: "Name", classes: "govuk-!-width-one-quarter" },
{ text: "Description", classes: "govuk-!-width-one-third" },
{ text: content_tag(:span, "Actions", class: "govuk-visually-hidden") }
],
rows: @applications_without_signin.map do |application|
Expand Down
4 changes: 2 additions & 2 deletions app/views/api_users/applications/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<%= render "components/table", {
caption: "Apps #{@api_user.name} has access to",
head: [
{ text: "Name" },
{ text: "Description" },
{ text: "Name", classes: "govuk-!-width-one-quarter" },
{ text: "Description", classes: "govuk-!-width-one-third" },
{ text: content_tag(:span, "Actions", class: "govuk-visually-hidden") },
],
rows: @applications.map do |application|
Expand Down
1 change: 1 addition & 0 deletions app/views/components/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<%= t.head do %>
<% head.each_with_index do |item, cellindex| %>
<%= t.header item[:text], {
classes: item[:classes],
format: item[:format],
href: item[:href],
data_attributes: item[:data_attributes],
Expand Down
8 changes: 4 additions & 4 deletions app/views/users/applications/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<%= render "components/table", {
caption: "Apps #{@user.name} has access to",
head: [
{ text: "Name" },
{ text: "Description" },
{ text: "Name", classes: "govuk-!-width-one-quarter" },
{ text: "Description", classes: "govuk-!-width-one-third" },
{ text: content_tag(:span, "Actions", class: "govuk-visually-hidden") },
],
rows: @applications_with_signin.map do |application|
Expand All @@ -52,8 +52,8 @@
<%= render "components/table", {
caption: "Apps #{@user.name} does not have access to",
head: [
{ text: "Name" },
{ text: "Description" },
{ text: "Name", classes: "govuk-!-width-one-quarter" },
{ text: "Description", classes: "govuk-!-width-one-third" },
{ text: content_tag(:span, "Actions", class: "govuk-visually-hidden") }
],
rows: @applications_without_signin.map do |application|
Expand Down

0 comments on commit 6092dc1

Please sign in to comment.