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

ER-1010 Formatting and Behaviour issues related to 404 Not found page #780

Merged
merged 8 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/assets/stylesheets/page-contents.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
.mob-section {
background: #f1f2f350;
margin-top: -20px;
margin-bottom: 20px;
padding: 20px 15px 0px;
border-bottom: 1px solid #ccc;
}
Expand All @@ -51,6 +52,21 @@
}
}

@media (max-width: 40.0525em) {
.contents-on-page ul {
font-size: 14px;
}
}

.contents-on-page li {
padding-top: 10px;
line-height: 1.3;
list-style-type: none;
position: relative;
padding-left: 25px;
padding-right: 25px
}

.app-back-to-top {
margin-top: govuk-spacing(9);
}
Expand Down
1 change: 1 addition & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class HomeController < ApplicationController
helper_method :section,
:page
layout 'hero'

def index; end

Expand Down
9 changes: 7 additions & 2 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ class PagesController < ApplicationController
:slug,
:section,
:breadcrumbs
layout 'hero'

def index
render 'errors/not_found' if page.nil?
render 'errors/not_found', layout: 'application' if page.nil?
end

def show
render page.to_partial_path
if page.nil?
render 'errors/not_found', layout: 'application'
else
render page.to_partial_path
end
end

private
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ def track_analytics?
def debug?
Dry::Types['params.bool'][ENV.fetch('DEBUG', false)]
end

# @param parts [Array<String>]
# @return [String]
def html_title(*parts)
[t('service.name'), *parts].join(' : ')
end
end
3 changes: 3 additions & 0 deletions app/views/errors/not_found.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- content_for :page_title do
= html_title 'Page not found'

.govuk-grid-row
.govuk-grid-column-two-thirds
h1.govuk-heading-xl
Expand Down
10 changes: 3 additions & 7 deletions app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ html.govuk-template lang='en'
= javascript_include_tag 'application', 'data-turbo-track': 'reload', defer: true
= yield :head

body#hero-layout.govuk-template__body
body#default-layout.govuk-template__body
script
| document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');

Expand All @@ -37,13 +37,9 @@ html.govuk-template lang='en'

= navigation

.dfe-content-page--header class='govuk-!-padding-bottom-7'
.dfe-width-container
= render 'layouts/banner'

= yield :hero

.dfe-width-container
= render 'layouts/banner'

main#main-content.govuk-main-wrapper role='main'
= yield

Expand Down
51 changes: 51 additions & 0 deletions app/views/layouts/hero.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
doctype html
html.govuk-template lang='en'
head
title= [t('service.name'), yield(:page_title).presence].compact.join(' : ')
= csrf_meta_tags
= csp_meta_tag

= tag.meta content: 'text/html; charset=UTF-8', 'http-equiv': 'Content-Type'
= render 'layouts/analytics_header'
= render 'layouts/hotjar'

= tag.meta content: 'width=device-width,initial-scale=1', name: 'viewport'
= tag.meta name: 'robots', content: 'noindex,nofollow' unless Rails.application.live?
= tag.meta property: 'og:image', content: image_path('images/govuk-opengraph-image.png')
= tag.meta name: 'description', content: @page&.meta_description if @page&.meta_description.present?
= csrf_meta_tags
= tag.meta name: 'theme-color', content: '#0b0c0c'

= favicon_link_tag image_path('dfe_favicon.ico')
= favicon_link_tag asset_path('images/govuk-mask-icon.svg'), rel: 'mask-icon', type: 'image/svg', color: "#0b0c0c"
= favicon_link_tag asset_path('images/govuk-apple-touch-icon.png'), rel: 'apple-touch-icon', type: 'image/png'
= favicon_link_tag asset_path('images/govuk-apple-touch-icon-152x152.png'), rel: 'apple-touch-icon', type: 'image/png', size: '152x152'
= favicon_link_tag asset_path('images/govuk-apple-touch-icon-167x167.png'), rel: 'apple-touch-icon', type: 'image/png', size: '167x167'
= favicon_link_tag asset_path('images/govuk-apple-touch-icon-180x180.png'), rel: 'apple-touch-icon', type: 'image/png', size: '180x180'
= stylesheet_link_tag 'application', 'data-turbo-track': 'reload'
= javascript_include_tag 'application', 'data-turbo-track': 'reload', defer: true
= yield :head

body#hero-layout.govuk-template__body
script
| document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');

= render 'layouts/analytics_body'
= render 'layouts/cookie_banner'

= govuk_skip_link

= navigation

.dfe-content-page--header class='govuk-!-padding-bottom-7'
.dfe-width-container
= render 'layouts/banner'
= yield :hero

.dfe-width-container
main#main-content.govuk-main-wrapper role='main'
= yield

= yield :other_resources

= render FooterComponent.new(pages: Page.footer.pages)
2 changes: 1 addition & 1 deletion app/views/pages/side_nav.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
= render partial: 'hero', locals: { hero: page.hero }

.govuk-grid-row
.govuk-grid-column-one-quarter.sticky.mob-section
martikat marked this conversation as resolved.
Show resolved Hide resolved
.govuk-grid-column-one-quarter.sticky.mob-section
input#menu-icon-chk.menu-btn[type="checkbox" name="menu-icon" checked]
label.menu-icon.govuk-body-l[for="menu-icon-chk"]
svg[xmlns="http://www.w3.org/2000/svg" height="1em" viewbox="0 0 448 512"]
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ en:
blank: Last name must not be blank
settings:
cookie_policy_legend: Do you want to accept analytics cookies?
preferences_saved_html: Your cookie settings were saved</br><a class='govuk-link' href='%{return_url}'>Go back to Help for early years providers</a>
martikat marked this conversation as resolved.
Show resolved Hide resolved
preferences_saved_html: Your cookie settings were saved. [Go back to Help for early years providers](/).
9 changes: 9 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rails_helper'

xdescribe 'ApplicationHelper', type: :helper do
describe '#html_title' do
it 'shows content' do
expect(page).to have_content 'content within html_title'
end
end
end
13 changes: 13 additions & 0 deletions spec/system/homepage_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'rails_helper'

RSpec.describe 'Homepage' do
before do
visit '/'
end

specify do
within '#hero-layout' do
expect(page).to have_content 'Find helpful articles and resources to support you in your setting.'
end
end
end
11 changes: 0 additions & 11 deletions spec/system/smoke_spec.rb

This file was deleted.