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

Convert publications to local rendering #3058

Merged
merged 4 commits into from
Apr 17, 2024
Merged

Convert publications to local rendering #3058

merged 4 commits into from
Apr 17, 2024

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Jan 23, 2024

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

What

Rework form (publication) pages to render attachments locally in the application, rather than using the pre-rendered chunk of markup from the content item.

Specifically, rework the list of documents on the forms pages to use the content item data in details->attachments to render the required content, in place of the data in details->documents, which is pre-rendered. This has involved the creation of a new partial for publication pages, as the existing partial is used by other page types.

Example form pages:

Why

Relates to previous work in alphagov/govuk_publishing_components#3820

Reworked version of changes in #3048

We need to put tracking on the details components that can (sometimes) appear beneath the list of attachments, and that's very hard to do here on pre-rendered markup - normally we'd just pass some options to the component. This work will be carried out in a follow up PR.

Screenshot 2024-01-22 at 13 59 49

Visual changes

details->attachments doesn't include custom thumbnails for PDFs, as previously displayed. We looked at getting this included in the content item, but ultimately decided with consultation from leads that the default thumbnail for PDFs is acceptable. This is for several reasons:

  • we believe custom thumbnails for PDFs draw users to click on PDFs over other formats, which we don't want to encourage
  • technical difficulty of implementation
  • as reported to us some PDFs produce a landscape thumbnail, which appears distorted as the attachment component expects it in portrait. While there are other solutions to this problem, removing custom thumbnails removes this problem

With the new data it looks like the attachments display the Request an accessible format option more than they used to. This seems to be valid (it happens if you pass an email address to the component via the alternative_format_contact_email option) and allowing users this option more often seems sensible, but it raises the question why some PDFs used to have this option and some didn't.

See example below. Note how before only some of these PDFs had the accessible format option, but now all of them have.

Before After
Screenshot 2024-04-11 at 10 49 16 Screenshot 2024-04-11 at 10 49 22

Trello card: https://trello.com/c/xhASj1rp/765-add-tracking-to-details-component

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3058 January 23, 2024 09:23 Inactive
@andysellick andysellick force-pushed the tracking-details branch 5 times, most recently from 730445c to 26cbc4f Compare April 11, 2024 09:52
- create a new partial for use and modification by publications
- currently just a copy of the existing _attachments.html.erb
andysellick and others added 3 commits April 17, 2024 09:12
- modify the new partial and the publication presenter to use a different bit of the content item for generating the attachments list
- specifically, use `details->attachments` instead of `details->documents`, which is pre-rendered HTML
- `details->attachments` contains only the data for the attachments, allowing us to render them individually in the new partial using frontend components, which will allow us to add tracking later
- Add override data to support publication test
- Update tests to make more relevant
@andysellick andysellick changed the title [WIP] Add GA4 tracking to details components in attachments Convert publications to local rendering Apr 17, 2024
@andysellick andysellick marked this pull request as ready for review April 17, 2024 08:19
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3058 April 17, 2024 09:42 Inactive
Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

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

I got the review app going to test it and it looks good! 💯

@@ -11,7 +11,8 @@ def details
end

def documents
content_item["details"]["documents"].to_a.join("")
docs = content_item["details"]["attachments"].select { |a| a["locale"] == locale } if content_item["details"]["attachments"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, this is clever, so you only display attachments with the same locale as the page. Nice!

<%= render 'govuk_publishing_components/components/attachment', {
heading_level: 3,
attachment: details,
margin_bottom: 6
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

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