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

Try out the statistical article hero wtih the hero component from the design system #91

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

helenb
Copy link
Contributor

@helenb helenb commented Jan 29, 2025

What is the context of this PR?

This is an initial test to try out the new grey hero on the statistical article page - relating to https://jira.ons.gov.uk/browse/CMS-307

It is very much draft and not intended to be merged yet - it shows the two hero blocks one above the other on the statistical article page, in order to highlight some of the styling and implementation issues with switching, which are going to be discussed with the design system team.

Pushing this as I would like some initial feedback on the change to move the breadcrumb logic to the back-end, which is necessary in order to use the breadcrumbs option in the hero.

Update: breadcrumb filter is now moved to be a global function, and I have followed @sanjeevz3009's approach in #85 and created a navigation_tags file.

How to review

You can check this branch out to test locally if desired, but it is not intended to be tested - more here to get feedback on the breadcrumbs approach.

Follow-up Actions

  • Discuss design differences with design team
  • Make summary fields consistent as rich text across page types.

@helenb helenb requested a review from a team as a code owner January 29, 2025 12:19
@helenb helenb marked this pull request as draft January 29, 2025 12:19
Comment on lines 44 to 45
@register.filter(name="breadcrumbs")
def breadcrumbs(page: "Page") -> list[dict[str, str]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion

Suggested change
@register.filter(name="breadcrumbs")
def breadcrumbs(page: "Page") -> list[dict[str, str]]:
@jinja2.pass_context
def breadcrumbs(context: jinja2.runtime.Context, page: "Page") -> list[dict[str, str]]:

a la https://github.com/ONSdigital/dis-wagtail/pull/85/files#diff-bfd42dbff73bbdea18630c438176ac08db2c376e9a8c3205a430e5f15caa3264R75-R76

then you can do .get_url(request=context.get("request")).

@register.filter(name="breadcrumbs") is for the Django template library, which we only use for the Wagtail admin

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Query re "@register.filter(name="breadcrumbs") is for the Django template library, which we only use for the Wagtail admin" - it seems to be being used for the social_image and social_text filters currently which are used on the front-end not in the admin.

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 think it would make sense to use the navigation app for the breadcrumbs like the ones in @sanjeevz3009's merge request so will update.

Copy link
Contributor

Choose a reason for hiding this comment

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

it seems to be being used for the social_image and social_text filters currently which are used on the front-end not in the admin.

that was part of kit and it makes sense to clean them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to leave them if that makes sense - did you mean 'keep them' not 'clean them'?

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 will leave the breadcrumbs template for now and see what becomes of this pull request - it may be that we can get rid of it entirely once we're using the new heroes more consistently.

{% set releases_text = _("View latest release") %}
{% endif %}
{% set next_release_date_text = page.next_release_date|date("DATE_FORMAT") or _("To be announced") %}
{% with breadcrumbs=page|breadcrumbs %}
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you can pass page|breadcrumbs directly to the macro.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorted

Copy link
Contributor

@zerolab zerolab left a comment

Choose a reason for hiding this comment

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

A couple of suggestions which should hopefully improve the template readability

Comment on lines +25 to +31
{% if page.is_census %}
{% import "templates/components/census/census-logo.html" as census_logo %}
{% set census_html = ['<div class="ons-container">'|safe, census_logo] | join %}
{% set census_html = [census_html, "</div>"|safe] | join %}
{% else %}
{% set census_html = "" %}
{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

you could do something like:

{% set census_html -%}
    {% if page.is_census %}
        <div class="ons-container">{% import "templates/components/census/census-logo.html"</div>
    {% endif %}
{%- endset %}

which should be much cleaner, IMHO

Comment on lines +15 to +18
page_depth = 2
for ancestor_page in page.get_ancestors().specific().defer_streamfields():
if not ancestor_page.is_root():
if ancestor_page.depth <= page_depth:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
page_depth = 2
for ancestor_page in page.get_ancestors().specific().defer_streamfields():
if not ancestor_page.is_root():
if ancestor_page.depth <= page_depth:
for ancestor_page in page.get_ancestors().specific().defer_streamfields():
if not ancestor_page.is_root():
# Root has depth 1, Homepage 2
if ancestor_page.depth <= 2:

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.

2 participants