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 footer alignment with grid classes and add width macro option #2462

Merged
merged 10 commits into from
Dec 9, 2021

Conversation

vanitabarrett
Copy link
Contributor

@vanitabarrett vanitabarrett commented Dec 6, 2021

Closes #1539 and #1726

Why

This PR attempts to rework what was originally spiked in #2446 and #2428 to have the same outcome, but without using flexbox. When reviewing the previous PRs, we realised that due to the fallback provided for older browsers, we were 1) duplicating a lot of what our existing grid does, and 2) flexbox was only really being used for 'dynamic' half/half layouts.

One positive of using flexbox was that we could support more 'dynamic' layouts where the footer sections could shrink/grow accordingly. However, the downsides are that it makes the code difficult to follow and it was potentially also a bit of "magic" for users.

What

This PR makes the following changes:

  • Strips out flexbox, uses our grid instead
  • Removes certain assumptions we'd made about the layout of a footer dependent on the number of sections
  • Introduces a width macro option to explicitly set the width of the section if needed, using our grid widths
  • Sets the default width of a footer section to full width - this is most similar to the current behaviour where if you pass only one section it renders as full width

Links for testing

https://govuk-frontend-pr-2462.herokuapp.com/components/footer
https://govuk-frontend-pr-2462.herokuapp.com/examples/footer-alignment
https://govuk-frontend-pr-2462.herokuapp.com/full-page-examples/campaign-page

Screenshots

Screenshot 2021-12-06 at 15 49 38

IE8

Screenshot 2021-12-06 at 15 50 41

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 6, 2021 15:26 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 6, 2021 15:34 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 6, 2021 15:41 Inactive
@vanitabarrett vanitabarrett changed the title [WIP] Footer grid without flexbox [WIP] Fix footer alignment with grid classes and add span macro option Dec 6, 2021
@vanitabarrett vanitabarrett changed the title [WIP] Fix footer alignment with grid classes and add span macro option Fix footer alignment with grid classes and add span macro option Dec 6, 2021
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 6, 2021 16:01 Inactive
@vanitabarrett vanitabarrett marked this pull request as ready for review December 6, 2021 16:05
@vanitabarrett vanitabarrett linked an issue Dec 6, 2021 that may be closed by this pull request
1 task
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 7, 2021 11:04 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 10:20 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 10:53 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 11:20 Inactive
@vanitabarrett vanitabarrett changed the title Fix footer alignment with grid classes and add span macro option Fix footer alignment with grid classes and add width macro option Dec 8, 2021
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 11:28 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 11:29 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 14:32 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 14:34 Inactive
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@EoinShaughnessy EoinShaughnessy left a comment

Choose a reason for hiding this comment

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

Content looks nice and clear! Just added a few comments.

Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

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

Generally think the approach is sound and the changes are looking good – a few minor comments.

Something of an edge case, but long words can overflow across other columns – but this is also true of the grid elsewhere. Not sure if it's worth worrying about as I couldn't think of any realistic examples, other than a long email address which seems an like unlikely thing to put in a section.

Screenshot 2021-12-08 at 14 57 01

src/govuk/components/footer/_index.scss Show resolved Hide resolved
src/govuk/components/footer/template.njk Outdated Show resolved Hide resolved
Comment on lines 190 to 185
it('renders two-column section full width by default', () => {
const $ = render('footer', examples['with default width navigation (two columns)'])

const $component = $('.govuk-footer')
const $section = $component.find('.govuk-footer__section')
expect($section.hasClass('govuk-grid-column-full')).toBeTruthy()
})
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure what this is testing. I think the only difference between this and the previous test is that this one has columns set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, you're right, that is the only difference. I think I added it just to double check that columns being set doesn't have any impact on the width class being set because originally they were linked. But maybe that's not really worth testing now?

Comment on lines 185 to 186
const $component = $('.govuk-footer')
const $section = $component.find('.govuk-footer__section')
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is consistent with some of the other tests, but not sure we're getting much from doing a query to find the 'component' and then a second query to find the section within it.

What do you think about just looking for the section in the first place?

Suggested change
const $component = $('.govuk-footer')
const $section = $component.find('.govuk-footer__section')
const $section = $('.govuk-footer__section')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good point! I've added a new commit to remove these in the footer tests.

src/govuk/components/footer/footer.yaml Show resolved Hide resolved
app/views/examples/footer-alignment/index.njk Show resolved Hide resolved
Vanita Barrett added 5 commits December 8, 2021 16:10
Allow users to set the width of a footer section explicitly.
For example: set `width: 'two-thirds'` for a two-third section.
Each list in the footer section as a bottom margin of 30px, and a top
margin (which is actually set by a bottom margin on the heading) of
40px on desktop and 30px on mobile. This means that on desktop the
spacing above and below the list is unequal.

Having spoken to Chris, we've decided to make this spacing and drop the
heading margin down to 30px on all breakpoints as it felt too large.
Update the footer YAML examples to use the new `width` macro option

Update the full GOV.UK yaml example to reflect the current layout
and use the new `width` macro option.

This commit also renames the example. When the footer example
has 'GOV.UK' in the name, it gets
flagged by Chrome as a possible spam/phishing site which
means you can't open that example in a new window.

This commit works around that issue by renaming the example -
it seems to be the word "GOV.UK" which triggers it
This commit updates the announcement example to fix the footer
layout to a two-thirds/one-third layout as it was before, using the
new `width` macro option.

This commit updates the campaign page example. It builds a footer based on
the example screenshot from #1726
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 16:11 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2462 December 8, 2021 16:16 Inactive
Vanita Barrett added 3 commits December 8, 2021 16:45
Some of the examples in the footer.yaml file that we
use for tests were not marked as `hidden`. This commit
adds those missing `hidden` attributes so they're not
shown in the review app
The footer tests included a query to look up the `.govuk-footer` component,
and then a second query to look up the specific element within that component
to test.

We can remove the first query and go straight to the second for most tests.
Copy link
Contributor

@EoinShaughnessy EoinShaughnessy left a comment

Choose a reason for hiding this comment

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

Looks great! 👍🏻

Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

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

Ship it! 🚢

@vanitabarrett vanitabarrett merged commit 429af61 into main Dec 9, 2021
@vanitabarrett vanitabarrett deleted the footer-grid branch December 9, 2021 11:03
@vanitabarrett vanitabarrett mentioned this pull request Dec 15, 2021
andymantell added a commit to surevine/govuk-react-jsx that referenced this pull request Jan 29, 2022
sarahseewhy pushed a commit to alphagov/govwifi-admin that referenced this pull request Feb 15, 2022
sarahseewhy pushed a commit to alphagov/govwifi-admin that referenced this pull request Mar 7, 2022
cbaines pushed a commit to alphagov/govwifi-admin that referenced this pull request Mar 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.

Improve the layout options for the footer component. Footer layout isn't aligned with content layout
4 participants