-
Notifications
You must be signed in to change notification settings - Fork 9
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
Update error pages to use public layout template #2440
Conversation
42ee664
to
5f423d2
Compare
5f423d2
to
c0c4d89
Compare
c0c4d89
to
06e6e28
Compare
67c0bb6
to
12d8119
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done a full review, just writing down some of the thoughts we had when we talked about this.
//= require govuk_publishing_components/dependencies | ||
|
||
//= require govuk_publishing_components/lib | ||
//= require govuk_publishing_components/lib/track-click |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confusingly, lib
is both a directory and a file, lib.js
. I'd thought that this would include the whole directory, but that would need require_tree
, so I think this is including lib.js
. However, lib.js
then includes everything in the lib
directory, plus the polyfills.
Since lib
the directory contains track-click
, line 6 isn't needed?
|
||
//= require govuk_publishing_components/dependencies | ||
|
||
//= require govuk_publishing_components/lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is everything in lib
needed for the error pages? Based on a quick glance, you might only need track-click
and cookie-functions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a bit of trial and error, I think that the only required bits are:
cookie-functions
header-navigation
track-click
📉 👍
//= require modules/global-bar | ||
//= require modules/cross-domain-tracking | ||
|
||
//= require global-bar-init |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly global-bar-init
includes the cookie functions code from the gem, which is already pulled in by analytics.js
in the gem, which is included here on line 8. Again, possibly out scope for this PR, but I wonder if there's an optimisation to made here, or whether rails is smart enough to not duplicate this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there's any de-duping or tree-shaking going on in Rails's asset pipeline. This is the kind of thing that Webpack would help with - we could include dependencies as many times as we want and Webpack would ensure that they're only in the compiled code once.
d9a8395
to
7693dae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some finicky comments. Happy with this otherwise 👍
@@ -1,5 +1,5 @@ | |||
<%= render partial: "error_page", locals: { | |||
heading: "Sorry, there is a problem", | |||
intro: '<p class="govuk-body">Go back and change the information you entered.</p>', | |||
status_code: 400 | |||
status_code: 400, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why there were so many changed files in this PR 😂 Nice one 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do love me a dangling comma. Better diffs ftw!
@@ -1,5 +1,5 @@ | |||
<%= render partial: "error_page", locals: { | |||
heading: "Sorry, there is a problem", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe out of scope for this PR but there's a lot of hard coded content in these templates. Could we translate it? I don't know if this content would ever actually be translated, I'm picturing a situation where we implement something to set locale based on user info or whatever. It's more for good practice. At the very least it'll handle a few instances of repeated content. I don't even know if static supports translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, there's a lot of content that could be translated here. I can't see rails-i18n
or any localisation files in Static, so I think it'd need to be set up from scratch. With that in mind, setting up translations is outside of the scope of this pull request / should be a thing that is worthy of its own pull request.
I've raised this an an issue so we don't forget: #2448
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's perfectly reasonable. Is there a way we can at least make some of this content non-repeatable, maybe in a little partial or something? It's not a huge deal but just in case it has to change suddenly we can update it once.
Not a blocker for merging. Just blasting opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had a go at this and I think it ends up convoluting things - the template ends up calling a partial, which calls another partial - and then the middle partial only sometimes overwrites the variables inside. It feels like premature optimisation that'd need to be undone when translations are used.
I think your first solution of using translations would be the best, simplest, and most future proof method to solve this - and that's outside the scope of this pull request.
7693dae
to
3c9faec
Compare
* The base error page template updated to use the public layout component * Application stylesheet has been updated to include only the styles needed for the public layout component, global bar, and emergency banner. * Application JavaScript has been updated to only include the modules needed for the public layout component * Error page stylesheet has only the extra imports needed - in this case, only the the title component was needed * Minor tweak to make the apostrophe in the "We're" on some of the error pages look nicer * Updated tests to match content and layout changes
3c9faec
to
374d0f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am content with this. One final comment but otherwise I reckon this can go out (once it's ready to go out)
@@ -1,5 +1,5 @@ | |||
<%= render partial: "error_page", locals: { | |||
heading: "Sorry, there is a problem", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's perfectly reasonable. Is there a way we can at least make some of this content non-repeatable, maybe in a little partial or something? It's not a huge deal but just in case it has to change suddenly we can update it once.
Not a blocker for merging. Just blasting opinions.
What
h1
on the error page was using the default browser font size forh1
s.Why
Adding a template to static that uses the public layout component meant updating these error pages first, since they use the same default
application.scss
andapplication.js
that the public layout component uses.The default stylesheet and JavaScript file now contains only the things needed for the public layout component.
Visual differences
Note - the page footer will look different as it the public layout component uses the footer component. These changes are outside the scope of this pull request and are best raised as issues on the govuk_publishing_components repo