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

Add global bar component from static #4538

Merged
merged 21 commits into from
Jan 27, 2025
Merged

Add global bar component from static #4538

merged 21 commits into from
Jan 27, 2025

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Jan 10, 2025

What

Copies the code for the global banner from static, with modifications. See commit history for details, but modifications include:

  • renaming the component
  • consolidating the JS together into the module JS and removing the 'init' JS
  • removing click events on the banner
  • removing the block list URL code (will be handled by the banners gem)
  • making version be an option passed to the component, instead of hard coded in the JS
  • significant code refactor
  • using the component wrapper helper on the component

Note that this will be a breaking change as it changes the name of the component from global-bar to global-banner. This has been changed everywhere in this repo including in the GA4 code, except for the bit where we pass data to GA4, where we keep it as global-bar because that's what GA4 expects to receive.

Corresponding PR to remove this from static: alphagov/static#3561

Why

We want to use the global banner in the new banners gem and we're working towards retiring static, so this is the logical place for the component to live.

Visual Changes

Trello card: https://trello.com/c/WtPkMQFM/386-move-global-bar-component-from-static-into-publishing-components-gem

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 10, 2025 11:20 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 10, 2025 11:28 Inactive
@govuk-ci govuk-ci had a problem deploying to components-gem-pr-4538 January 10, 2025 15:26 Failure
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 10, 2025 15:28 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 15, 2025 13:56 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 15, 2025 14:03 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 15, 2025 16:07 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 15, 2025 16:33 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 09:17 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 09:43 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 09:47 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 10:21 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 10:22 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 10:27 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 10:28 Inactive
@andysellick
Copy link
Contributor Author

Have approved the Percy build as it's helpful for me to see if any tests fail beyond that, and the Percy diff is a whole new page for this component and therefore isn't useful for this PR anyway.

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 14:03 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 14:23 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 14:26 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 16, 2025 15:18 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 17, 2025 09:55 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 17, 2025 11:35 Inactive
- also make the stylesheet compile (was unable to find mixins)
- and move global bar helper code into cookie functions
- component is almost certainly not working correctly yet, but at least stop it from breaking all the other tests
- adds a placeholder spec file for the component template, will be filled in later
- was part of the original component in static, but lack of it only caused an error once trying to render the component guide page
- modified a bit from the original, had to require active_support, rewrote minitest to rspec, added timecop, set timezone in tests, configure as app helper
- originally copied across and modified to preserve original code, but we don't need this
- remove option to pass a link for the non-title text as not currently needed
- rename options to just title and text, simpler
- remove show banner option, use existence of title as basis for displaying banner
- make banner appear in component guide
- write some rspec tests
- renaming the component from to global banner
- no changes to files (will obviously break everything) just renaming for now
- updates all the code that refers to `global-bar` or `globar_bar` or `globalBar` (etc.) to match the new name of the component
- does not update the GA4 code in terms of what is passed to GA4, because that still expects to receive something called `global bar` and if we change that it's going to mess up all the analytics
- use correct BEM syntax
- remove unused styles (checked and they don't seem to exist anywhere else in alphagov)
- click handling is handled by a dismiss link, which is no longer part of the banner, so this code isn't ever used
- the tests were all passing because they're based on a copied snippet of markup that isn't up to date
- previously prevented the banner from appearing on specific URLs
- this will be handled instead by the banners gem
- relates to the additional content, which isn't part of the banner anymore, and the dismiss link, which also doesn't exist
- not complete, some of the code happens in the wrong order and repeats itself so still requires refactoring, but tests should at least pass for now
- also make banner version a thing that gets passed to the component and read from a data attribute by the JS, instead of being hard coded in the init file
- stop setting a visible class on the HTML element and move it to on the component itself
- expand test coverage
- improve test names
@andysellick andysellick changed the title [DO NOT MERGE] Add global bar component from static Add global bar component from static Jan 27, 2025
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4538 January 27, 2025 11:59 Inactive
@andysellick andysellick merged commit a2f007b into main Jan 27, 2025
12 checks passed
@andysellick andysellick deleted the global-bar-add branch January 27, 2025 12:45
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.

4 participants