Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Summary List action link alignment #2668

Merged
merged 4 commits into from
Jun 28, 2022

Conversation

querkmachine
Copy link
Member

@querkmachine querkmachine commented Jun 22, 2022

When there are several action links in the Summary List component, the links become misaligned on large screens, due to the links being right-aligned and the separator being appended to the right of each link. Links are aligned correctly on narrow screens, as the links are left-aligned in that context.

Additionally, the spacing on each side of the separator is uneven due to extra whitespace being counted between each link.

This PR intends to fix these issues by:

  • Using media queries to swap which side of the link the separator line, margin and padding are applied to, depending on the viewport size.
  • Using flexbox on the link container, so that whitespace isn't included in layout calculations.

Fixes #2281.

Comparisons

Small screens (modern browsers, IE11, IE10)

Before After
image image

Large screens (modern browsers, IE11, IE10)

Before After
image image

Large screens (IE9)

Flexbox is not supported by IE9, so the uneven spacing between separators is still present.

Before After
image image

Large screens (IE8)

Neither flexbox, nor the :first-child and :last-child pseudo-selectors, are supported in IE8.

Before After
image image

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2668 June 22, 2022 13:36 Inactive
@querkmachine querkmachine requested a review from a team June 22, 2022 13:37
@querkmachine querkmachine force-pushed the fix-summary-list-action-alignment branch from 0db63e1 to 5b3b57d Compare June 23, 2022 15:43
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2668 June 23, 2022 15:43 Inactive
Copy link
Contributor

@vanitabarrett vanitabarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Would be good to get this in a Changelog entry before merging.

@querkmachine
Copy link
Member Author

@vanitabarrett Would this be listed as a regular fix, or do we want to provide additional guidance about removing whitespace from within list items?

@vanitabarrett
Copy link
Contributor

@querkmachine I think it would just be listed as a regular fix? If we want to tell our users how to remove whitespace if they're not using Nunjucks macros I think we should consider either 1) having the flex fix in combination with the Nunjucks whitespace fix and/or documenting it somewhere a bit more permanent than the release notes

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2668 June 28, 2022 14:53 Inactive
Adds ':first-child)' to the disallow list for postcss-pseudo-classes, so PostCSS doesn't attempt to transform it and triggers an error.
Fixes the alignment on the Summary List component action links, if there are enough links to wrap onto multiple lines. It does this by reversing the side of the link that margin, padding and
borders are applied to depending on the breakpoint.

On mobile, links are left aligned with spacing and borders on the right. On tablet and above, links are right aligned with spacing and borders on the left.
Fixes errant whitespace causing one side of the separators appearing larger than the other.
@querkmachine querkmachine force-pushed the fix-summary-list-action-alignment branch from f684468 to 1df31ba Compare June 28, 2022 14:53
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2668 June 28, 2022 14:54 Inactive
@querkmachine querkmachine merged commit db42757 into main Jun 28, 2022
@querkmachine querkmachine deleted the fix-summary-list-action-alignment branch June 28, 2022 16:28
@querkmachine querkmachine mentioned this pull request Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple actions in Summary list don't align when they go over one line
3 participants