Skip to content

Commit

Permalink
Update logic for showing banner styling
Browse files Browse the repository at this point in the history
  • Loading branch information
martikat committed Apr 29, 2024
1 parent 22ea5bb commit 084a783
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 24 deletions.
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
5 changes: 3 additions & 2 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ 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
if page.nil?
render 'errors/not_found'
render 'errors/not_found', layout: 'application'
else
render page.to_partial_path
end
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
14 changes: 3 additions & 11 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,17 +37,9 @@ html.govuk-template lang='en'

= navigation

- if page.nil?
.dfe-width-container
= render 'layouts/banner'
= yield :hero
- else
.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)
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.

0 comments on commit 084a783

Please sign in to comment.