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

Do not make the service name in the header a link if no serviceUrl is provided #2617

Merged
merged 2 commits into from
May 23, 2022

Conversation

36degrees
Copy link
Contributor

The header macro currently assumes that if there is a serviceName then there will always be a serviceUrl. If no serviceUrl is provided then the service name is wrapped with a link with an empty href attribute.

There’s not always a logical place to link the service name in the header to, so it makes sense to allow for service names that don’t link anywhere.

Update the macro so that when serviceUrl is omitted from the options a span is used to wrap the service name rather than a link.

As the current class used on the service name is a modifier for links (govuk-header__link--service-name) but will not be used on a link in this context, rename it to govuk-header__service-name to make it more generic.

Keep the old class name around as an alias to prevent this being a breaking change, but mark it as deprecated.

Fixes #1826

Comment on lines +145 to +147
// The govuk-header__link--service-name class is deprecated - use
// govuk-header__service-name instead.
.govuk-header__service-name,
Copy link
Contributor Author

@36degrees 36degrees May 13, 2022

Choose a reason for hiding this comment

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

Are we happy with this approach? If so, will need to create an issue to remove the govuk-header__link--service-name class and attach it to the milestone for v5.0, and include this in the release notes as a deprecation.

The alternative I think is to either:

  • live with having a link modifier class on something that isn't a link (which feels icky)
  • keep both classes around forever

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've created an issue to remove the deprecated class here: #2636

Copy link
Contributor

@owenatgov owenatgov left a comment

Choose a reason for hiding this comment

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

Looking fab. I'm happy with the approach and am in favour of us removing govuk-header__link--service-name. It makes sense to keep our styles clean at least in the long term.

@owenatgov
Copy link
Contributor

Afterthought: Does this need a changelog entry?

@36degrees
Copy link
Contributor Author

Yep! I also need to create an issue to tidy up that deprecated class.

@36degrees 36degrees changed the title Allow for unlinked service names in header Do not make the service name in the header a link if no href is provided May 20, 2022
The header macro currently assumes that if there is a serviceName then there will always be a serviceUrl. If no serviceUrl is provided then the service name is wrapped with a link with an empty `href` attribute.

There’s not always a logical place to link the service name in the header to, so it makes sense to allow for service names that don’t link anywhere.

Update the macro so that when serviceUrl is omitted from the options a span is used to wrap the service name rather than a link.

As the current class used on the service name is a modifier for links (`govuk-header__link--service-name`) but will not be used on a link in this context, rename it to `govuk-header__service-name` to make it more generic.

Keep the old class name around as an alias to prevent this being a breaking change, but mark it as deprecated.
@36degrees 36degrees changed the title Do not make the service name in the header a link if no href is provided Do not make the service name in the header a link if no serviceUrl is provided May 20, 2022
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 good! Made 2 small suggestions, but not feeling strongly about either so feel free to accept/ignore.

Co-authored-by: EoinShaughnessy <72507742+EoinShaughnessy@users.noreply.github.com>
@36degrees 36degrees merged commit 272e202 into main May 23, 2022
@36degrees 36degrees deleted the header-service-name-no-url branch May 23, 2022 13:53
@domoscargin domoscargin mentioned this pull request Jun 27, 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.

Prevent creating <a> without href in header service name
3 participants