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 a helper to get active links #4285

Merged
merged 5 commits into from
Oct 15, 2024
Merged

Add a helper to get active links #4285

merged 5 commits into from
Oct 15, 2024

Conversation

leenagupte
Copy link
Contributor

@leenagupte leenagupte commented Oct 15, 2024

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What

DRY-up the contents list helper that is being created for side navigation so that it can be used in both the side and main navigation blocks.

The helper also supports nested links.

Why

Both the “side navigation” and “main navigation” blocks need to know which page the user is on to set one of the links to active.

A helper was created for the side navigation block. This code should be DRY-ed up to be used in both.

Trello card

How

The main_navigation blocks in the YAML files have been updated to demonstrate dynamic active links.

Screenshots?

Screenshot 2024-10-15 at 11 47 47

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4285 October 15, 2024 10:19 Inactive
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4285 October 15, 2024 10:29 Inactive
It will be used to help render the side and main navigation blocks that
need to know which link to set to active.

This method is a helper as it needs to be called from the view to be
able to access `request.path` for the current path so that the link
can be set to "active".
This changes it to match the labels in the contents_list component,
as well as the forthcoming side_navigation block.

Removes links being hard-coded to active as this will be set my the
new helper.

Also updates the YAML sub-page-1 so that the active link can be
demonstrated.

Fix up to links hash
@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-4285 October 15, 2024 10:46 Inactive
@leenagupte leenagupte marked this pull request as ready for review October 15, 2024 10:52
@leenagupte leenagupte changed the title [WIP] Active links helper Add a Active links helper Oct 15, 2024
@leenagupte leenagupte changed the title Add a Active links helper Add a helper to get active links Oct 15, 2024
Copy link
Contributor

@KludgeKML KludgeKML left a comment

Choose a reason for hiding this comment

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

LGTM

@leenagupte leenagupte merged commit 324ab75 into main Oct 15, 2024
12 checks passed
@leenagupte leenagupte deleted the active-links-helper branch October 15, 2024 12:41
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.

3 participants