Skip to content

Commit

Permalink
ER-961 Formatting bug fixes (#770)
Browse files Browse the repository at this point in the history
* Address formatting bugs in ticket and add back to top link

* Update padding for contents list

* Update width for bullet points at end of page

* Update logo to not show in footer

* Update cookie setting page

* Fix rubocop error

* Update to address PR comments and temporary update for error page and citation

* Update error logic to use Contentful

* Use released at value for citation published at logic and add specs

* Fix rubocop errors

* Delete system spec and update side nav citation component logic

* Update to fix bullet point width

* Update based on PR comments

* Update error files
  • Loading branch information
martikat authored Apr 22, 2024
1 parent 61be928 commit b642162
Show file tree
Hide file tree
Showing 27 changed files with 217 additions and 64 deletions.
8 changes: 7 additions & 1 deletion app/assets/stylesheets/_links.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@

.govuk-breadcrumbs li {
font-size: 16px;
}
}

@media (max-width: 40.0525em) {
.govuk-breadcrumbs li {
font-size: 14px;
}
}
8 changes: 8 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ main img {
margin-bottom: govuk-spacing(8);
}

#flash .govuk-notification-banner {
margin-bottom: govuk-spacing(4);
}

@include govuk-media-query($until: tablet) {

.govuk-grid-column-one-half>p,
Expand Down Expand Up @@ -178,3 +182,7 @@ ul>li>ul>li {
top: 1.5rem;
}
}

.govuk-footer__copyright-logo {
display: none;
}
4 changes: 0 additions & 4 deletions app/assets/stylesheets/dfe-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ header #service-name {
.dfe-content-page--header {
background: $light-blue;

@include govuk-media-query($until: tablet) {
padding: govuk-spacing(2);
}

img {
max-width: 100%;
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/dfe/side-nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,4 @@ label.menu-icon svg {
.content-with-side-menu {
margin-top: 0px;
}
}
}
5 changes: 5 additions & 0 deletions app/assets/stylesheets/page-contents.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
background-color: #F3F2F150;
}

@media (max-width: 40.0525em) {
.contents-on-page {
padding: 20px;
}
}

/*
The following was govspeak and custom kramdown for the list of page content anchors
Expand Down
37 changes: 31 additions & 6 deletions app/controllers/settings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
class SettingsController < ApplicationController
def create
set_cookie_pref
redirect_to params[:return_url]
end

private
if settings_params[:settings_updated].present?
flash[:notice] = t(:preferences_saved_html, scope: 'settings')
end

def track_analytics
params.fetch(:track_analytics, 'No')
redirect_to request_path
end

private

def set_cookie_pref
cookies[:track_analytics] = { value: track_analytics, expires: 6.months.from_now }
cookies[:track_analytics] = {
value: settings_params[:track_analytics],
expires: 6.months.from_now,
}

if params.fetch(:notify_if_successful, false)
flash[:notice] = t(:preferences_saved_html, return_url: helpers.root_path, scope: :settings)
end
end

def request_path
params[:request_path] || params[:return_url]
end

def settings_params
params.permit(:request_path, :track_analytics, :settings_updated)
end

def track_analytics
params.fetch(:track_analytics, 'No')
end

def template
page_params[:id].underscore
end

def page_params
params.permit(:id)
end
end
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def footer_menu
@footer_menu ||= Page.footer.pages
end

def track_analytics?
cookies[:track_analytics] == 'Yes'
end

# @return [Boolean]
def debug?
Dry::Types['params.bool'][ENV.fetch('DEBUG', false)]
Expand Down
16 changes: 16 additions & 0 deletions app/helpers/content_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ def signup
Resource.by_name('ctas.signup') || null_resource('ctas.signup')
end

def not_found
Resource.by_name('error.not_found') || null_resource('error.not_found')
end

def internal_server_error
Resource.by_name('error.internal_server_error') || null_resource('error.internal_server_error')
end

def unprocessable_entity
Resource.by_name('error.unprocessable_entity') || null_resource('error.unprocessable_entity')
end

def service_unavailable
Resource.by_name('error.service_unavailable') || null_resource('error.service_unavailable')
end

def feedback
Resource.by_name('ctas.feedback') || null_resource('ctas.feedback')
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def self.by_slug(slug)
end
end

def created_at
released_at || super
end

def path
['/', parent&.parent&.slug, parent&.slug, slug].join('/').gsub(/home/, '').squeeze('/')
end
Expand Down
10 changes: 3 additions & 7 deletions app/views/errors/internal_server_error.html.slim
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
.govuk-grid-row
.govuk-grid-column-two-thirds
h1.govuk-heading-xl Sorry, there is a problem with the website
h1.govuk-heading-xl
= internal_server_error.title

p.govuk-body Please try again later.

p.govuk-body Please contact the Help for early years team on:

p.govuk-body
= govuk_link_to '[email protected]', 'mailto:[email protected]'
= m(internal_server_error.body)
12 changes: 3 additions & 9 deletions app/views/errors/not_found.html.slim
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
.govuk-grid-row
.govuk-grid-column-two-thirds
h1.govuk-heading-xl Page not found
h1.govuk-heading-xl
= not_found.title

p.govuk-body
| Use this link to go back to the homepage
= govuk_link_to 'Help for early years providers', root_path

p.govuk-body
| If the web address is correct or you selected a link or button, contact
= govuk_link_to '[email protected]', 'mailto:[email protected]'
| to report a fault about the service.
= m(not_found.body)
11 changes: 3 additions & 8 deletions app/views/errors/service_unavailable.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
.govuk-grid-column-two-thirds
h1.govuk-heading-l Help for early years providers

h2.govuk-heading-m Sorry, the site is unavailable

p.govuk-body You will be able to use the website later.

p.govuk-body Please contact the Help for early years team on:

p.govuk-body
a.govuk-link.email href='mailto:[email protected]' target='_blank' rel='noopener noreferrer' [email protected]
h2.govuk-heading-m
= service_unavailable.title

= m(service_unavailable.body)
8 changes: 3 additions & 5 deletions app/views/errors/unprocessable_entity.html.slim
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.govuk-grid-row
.govuk-grid-column-two-thirds
h1.govuk-heading-xl The change you wanted was rejected

p.govuk-body Maybe you tried to change something you didn't have access to.

p.govuk-body If you are the application owner check the logs for more information.
h1.govuk-heading-xl
= unprocessable_entity.title

= m(unprocessable_entity.body)
4 changes: 1 addition & 3 deletions app/views/home/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

= m(page.body)

- page.pages.each_slice(3).with_index do |row, index|
.govuk-grid-row class=('govuk-!-margin-bottom-6' unless index == (page.pages.count / 3.0 - 1).ceil)
= render partial: 'shared/card', collection: row
= render 'pages/cards'

= render 'shared/ctas'

Expand Down
5 changes: 2 additions & 3 deletions app/views/layouts/_banner.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
aside.govuk-width-container title='Beta Banner'
= govuk_phase_banner(tag: { text: 'Beta' }, classes: 'noprint') do
= t 'phase_banner_html', feedback_link: govuk_link_to('feedback', Rails.configuration.feedback_url, target: :_blank, rel: 'noopener noreferrer')
= govuk_phase_banner(tag: { text: 'Beta' }, classes: 'noprint') do
= t 'phase_banner_html', feedback_link: govuk_link_to('feedback', Rails.configuration.feedback_url, target: :_blank, rel: 'noopener noreferrer')
5 changes: 5 additions & 0 deletions app/views/layouts/_flash.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- if flash.any?
#flash.govuk-grid-row
.govuk-grid-column-full
- flash.each do |variant, message|
= govuk_notification_banner title_text: t("banners.#{variant}"), text: m(message), success: %w[notice].include?(variant), classes: "govuk-notification-banner--#{variant}"
2 changes: 1 addition & 1 deletion app/views/markup/_downloadable_media.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
section.gem-c-attachment class='govuk-!-display-none-print govuk-!-margin-bottom-6 govuk-!-margin-top-'
section.gem-c-attachment class='govuk-!-display-none-print govuk-!-margin-bottom-6 govuk-!-margin-top-7'
.gem-c-attachment__thumbnail

a.govuk-link target='_self' tabindex='-1' aria-hidden='true' href=pdf_url
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions app/views/pages/_cards.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- page.pages.each_slice(3).with_index do |row, index|
.govuk-grid-row class=('govuk-!-margin-bottom-6' unless index == (page.pages.count / 3.0 - 1).ceil)
= render partial: 'pages/card', collection: row, as: :card
14 changes: 3 additions & 11 deletions app/views/pages/default.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,14 @@
= render 'shared/print'

.govuk-grid-row class='govuk-!-margin-top-4 govuk-!-margin-bottom-5'
.govuk-grid-column-full
.govuk-grid-column-three-quarters
= render 'debug'
= m(page.body)

.hf-citation
.gem-c-metadata data-module="gem-toggle metadata" data-gem-toggle-module-started="true" data-metadata-module-started="true"
dl.gem-c-metadata__list data-module="gem-track-click" data-gem-track-click-module-started="true"
dt.gem-c-metadata__term From:
dd.gem-c-metadata__definition
a.govuk-link href="https://www.gov.uk/government/organisations/department-for-education" Department for Education
dt.gem-c-metadata__term Published:
dd.gem-c-metadata__definition = page.created_at.to_s(:long)
dt.gem-c-metadata__term Updated:
dd.gem-c-metadata__definition data-module="ga4-link-tracker" data-ga4-track-links-only="" data-ga4-link="{&quot;event_name&quot;:&quot;navigation&quot;,&quot;type&quot;:&quot;content history&quot;,&quot;section&quot;:&quot;Top&quot;,&quot;action&quot;:&quot;opened&quot;}" data-ga4-link-tracker-module-started="true" #{page.updated_at.to_s(:long)}
= render 'shared/citation'

- if page.content_list.present?
= render 'shared/back_to_top'
= render 'shared/print'

.govuk-grid-column-full
Expand Down
11 changes: 7 additions & 4 deletions app/views/pages/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@

= render 'debug'

- if page.pages.any?
- page.pages.each_slice(3).with_index do |row, index|
.govuk-grid-row class=('govuk-!-margin-bottom-6' unless index == (page.pages.count / 3.0 - 1).ceil)
= render partial: 'shared/card', collection: row
= render 'layouts/flash'

- if page.children?
= render 'cards'
- else
= m(page.body)

- if page.slug == 'cookie-policy'
= render 'settings/cookie_policy'

= render 'shared/ctas'

= render 'shared/other_resources'
4 changes: 4 additions & 0 deletions app/views/pages/side_nav.slim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
= render 'debug'
= m(page.body)

- if !page.children?
= render 'shared/citation'

- if page.content_list.present?
= render 'shared/back_to_top'
= render 'shared/print'

.govuk-grid-column-full
Expand Down
10 changes: 10 additions & 0 deletions app/views/settings/_cookie_policy.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.govuk-grid-row class='govuk-!-margin-bottom-7'
.govuk-grid-column-two-thirds-from-desktop
= form_with url: settings_path, method: :post, local: true do |f|
= f.hidden_field :request_path, value: request.path
= f.hidden_field :settings_updated, value: 'Yes'
= f.govuk_radio_buttons_fieldset(:checked, legend: { size: 'm', text: t('settings.cookie_policy_legend') }, inline: true ) do
= f.govuk_radio_button :track_analytics, 'Yes', label: { text: 'Yes' }, checked: track_analytics?
= f.govuk_radio_button :track_analytics, 'No', label: { text: 'No' }, checked: !track_analytics?

= f.govuk_submit 'Save cookie settings'
2 changes: 2 additions & 0 deletions app/views/shared/_back_to_top.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
div.app-back-to-top class='govuk-!-margin-bottom-7' data-module='app-back-to-top'
= govuk_back_to_top_link('#top')
10 changes: 10 additions & 0 deletions app/views/shared/_citation.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.hf-citation
.gem-c-metadata data-module="gem-toggle metadata" data-gem-toggle-module-started="true" data-metadata-module-started="true"
dl.gem-c-metadata__list data-module="gem-track-click" data-gem-track-click-module-started="true"
dt.gem-c-metadata__term From:
dd.gem-c-metadata__definition
a.govuk-link href="https://www.gov.uk/government/organisations/department-for-education" Department for Education
dt.gem-c-metadata__term Published:
dd.gem-c-metadata__definition = (page.released_at || page.created_at).to_fs(:long)
dt.gem-c-metadata__term Updated:
dd.gem-c-metadata__definition data-module="ga4-link-tracker" data-ga4-track-links-only="" data-ga4-link="{&quot;event_name&quot;:&quot;navigation&quot;,&quot;type&quot;:&quot;content history&quot;,&quot;section&quot;:&quot;Top&quot;,&quot;action&quot;:&quot;opened&quot;}" data-ga4-link-tracker-module-started="true" #{page.updated_at.to_fs(:long)}
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ en:
last_name:
blank: Last name must not be blank
settings:
cookie-policy: Cookies
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>
Loading

0 comments on commit b642162

Please sign in to comment.