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 files for secondary navigation: #4229

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

davidtrussler
Copy link
Contributor

What

Add secondary navigation component.

Files added

  • ERB
  • YML
  • SCSS
  • Rspec test

Why

This component currently exists only on Whitehall (see here). Since it is now needed on other apps (e.g. Mainstream Publisher) this is to make it more widely available.

Visual Changes

This is a new component - screenshot below.

Screenshot 2024-09-16 at 15 57 14

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4229 September 16, 2024 15:01 Inactive
@davidtrussler davidtrussler force-pushed the Create-new-component_secondary-navigation branch from ce2e4e8 to 40e72c6 Compare September 16, 2024 15:30
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4229 September 16, 2024 15:31 Inactive
@davidtrussler davidtrussler force-pushed the Create-new-component_secondary-navigation branch from 40e72c6 to ccc6412 Compare September 16, 2024 15:35
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4229 September 16, 2024 15:36 Inactive
@davidtrussler davidtrussler force-pushed the Create-new-component_secondary-navigation branch from ccc6412 to 37e9dec Compare September 16, 2024 15:39
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4229 September 16, 2024 15:40 Inactive
Copy link
Contributor

@AshGDS AshGDS 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, just had a few questions/comments 👍

assert_select ".gem-c-secondary-navigation", count: 1
assert_select ".gem-c-secondary-navigation__list-item", count: 3
assert_select ".gem-c-secondary-navigation__list-item--current", count: 1
assert_select ".gem-c-secondary-navigation__list-item--current", text: "Nav item 1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly worth adding an aria-current check in here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot: have added that.

add_gem_component_stylesheet("secondary-navigation")

id ||= nil
items ||= []
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth using the component wrapper here? I think the shared_helper would be needed on this component as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @AshGDS - not sure what the component wrapper is that you are referring to here. And also what the shared_helper does in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

@davidtrussler The component wrapper is something built by Andy to standardise the way data attributes / classes / aria tags are added to the parent HTML tag of the component. The shared helper AFAIK allows margin bottom to be applied to the component for styling purposes.

An example of both helpers exist in the password input component I added - see lines 9 to 16, as well as line 40:

shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)

You would then need to reflect the existence of these helpers in your .yml file - you would add uses_component_wrapper_helper: true to the file, and give an example of your component with margin bottom:

A test of the margin functionality in your spec file would be needed as well.

Component wrapper docs: https://github.com/alphagov/govuk_publishing_components/blob/main/docs/component-wrapper-helper.md

Shared helper docs: https://github.com/alphagov/govuk_publishing_components/blob/main/docs/component_conventions.md#shared-helper

Though not sure these are necessary for all components - may be worth asking Andy.

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 for that, Ash. Have now added the wrapper as suggested.

<%
add_gem_component_stylesheet("secondary-navigation")

id ||= nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This id is not exposed in the .yml example, and is also untested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, added an id in the yml and added a test for it.
At the same time we noticed the two tests that were there could really be reduced to one since there was some duplication going on.

<% end %>
<% end %>
<% end %>
<% end %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth wrapping the render in an if items statement, so that there isn't a scenario where an empty nav/ul is rendered? (I appreciate this may be a very rare edge case)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, probably rare but worth it - have now add that.

Copy link
Contributor

@jon-kirwan jon-kirwan 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. Just a small comment to update the changelog.

@davidtrussler davidtrussler force-pushed the Create-new-component_secondary-navigation branch from 37e9dec to ebe7f2a Compare September 18, 2024 09:57
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4229 September 18, 2024 09:58 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4229 September 18, 2024 10:38 Inactive
@davidtrussler
Copy link
Contributor Author

Looks good to me. Just a small comment to update the changelog.

Thanks Jon, have done that.

Add Component wrapper helper
@davidtrussler davidtrussler force-pushed the Create-new-component_secondary-navigation branch from cc35494 to 4748e05 Compare September 18, 2024 10:45
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4229 September 18, 2024 10:45 Inactive
Copy link
Contributor

@AshGDS AshGDS left a comment

Choose a reason for hiding this comment

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

Nice, thanks 👍

@syed-ali-tw syed-ali-tw merged commit de00a0c into main Sep 18, 2024
12 checks passed
@syed-ali-tw syed-ali-tw deleted the Create-new-component_secondary-navigation branch September 18, 2024 11:28
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.

5 participants