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

Refactor header #982

Merged
merged 3 commits into from Dec 30, 2019
Merged

Refactor header #982

merged 3 commits into from Dec 30, 2019

Conversation

adamsilver
Copy link
Contributor

Context

We (@duncanjbrown and I) made this change because the same HTML for the header is used across candidate, provider, support and API doc interfaces.

There was a lot of repeated code, and logic in the view that's better isolated outside of the Header component itself.

This repeated code caused a bug whereby the mobile toggle menu button appeared even when there were no menu items to show/hide.

Changes proposed in this pull request

We proposed abstracting the header and navigation items into a component that closely resembles the GOV.UK Frontend Header component.

Link to Trello card

https://trello.com/c/hKy03E02/691-create-header-component

@tvararu tvararu temporarily deployed to apply-for-te-refactor-h-yd1ahc December 24, 2019 16:28 Inactive
@tvararu tvararu temporarily deployed to apply-for-te-refactor-h-yd1ahc December 24, 2019 16:58 Inactive
@tvararu tvararu temporarily deployed to apply-for-te-refactor-h-yd1ahc December 24, 2019 17:10 Inactive
@duncanjbrown
Copy link
Contributor

duncanjbrown commented Dec 24, 2019

Added a commit to include yarn in the GitHub Actions build as unit tests touching components depend upon it, or at least they do now

Copy link
Contributor

@tvararu tvararu left a comment

Choose a reason for hiding this comment

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

👌 beaut

app/components/header_component.html.erb Show resolved Hide resolved
app/components/header_component.html.erb Outdated Show resolved Hide resolved
This component brings together the logic for constructing header
navigation for the various parts of the application.

Instead of putting links into partials, header navigations are now
configured by NavigationItems.for_candidate_interface,
.for_provider_interface etc.

These methods return lists of NavigationItems which the HeaderComponent
knows how to turn into links.

This means that no logic about what should be in navigations lives in
templates. It exposes some wrinkles about the way we handle eg
SupportUsers vs DfE Sign-in users in the same way across Support and
Provider interfaces and should make refactoring these easier.

This resolves a bug where the dropdown menu was appearing on a screen
where it shouldn't, and hopefully prevents that kind of bug in the
future.

We also get to throw away a lot of repeated markup which risked
being brittle.
Bring the rest of the <header> inside HeaderComponent.

Add a classes: attr in line with the convention established by
govuk-frontend, and use the appropriate HostingEnvironment to set it.
Components need frontend assets to render
@tvararu
Copy link
Contributor

tvararu commented Dec 30, 2019

Have added review comments with minor nits, then fixed them up + force pushed into the relevant commit.

@tvararu tvararu temporarily deployed to apply-for-te-refactor-h-gidjal December 30, 2019 07:54 Inactive
@tvararu
Copy link
Contributor

tvararu commented Dec 30, 2019

Took a good look at this on the review app, looks great!

@tvararu tvararu merged commit 71a8a0d into master Dec 30, 2019
@tvararu tvararu deleted the refactor-header branch December 30, 2019 08:00
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.

None yet

3 participants