Skip to content

Commit

Permalink
Merge pull request #63 from epimorphics/spike/additional-a11y-improve…
Browse files Browse the repository at this point in the history
…ments

Continued gem refactoring updates
  • Loading branch information
jonrandahl authored Aug 28, 2024
2 parents d305a44 + cc9be81 commit b194606
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 108 deletions.
31 changes: 22 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,34 @@ applications.

## Changes

## 1.9.6 - 2024-08

- (Jon) Additional improvements for the suite of apps that use this gem to
ensure the menu links are built correctly alongside including the appropriate
classes and/or attributes for accessibility and usability

## 1.9.5 - 2024-08

- (Dan) Updates page title tag so we can update the page titles in various repos to improve accessibility [116](https://github.com/epimorphics/standard-reports-ui/issues/116), [220](https://github.com/epimorphics/ppd-explorer/issues/220) and [409](https://github.com/epimorphics/ukhpi/issues/409)
- (Dan) Updates page title tag so we can update the page titles in various repos
to improve accessibility
[116](https://github.com/epimorphics/standard-reports-ui/issues/116),
[220](https://github.com/epimorphics/ppd-explorer/issues/220) and
[409](https://github.com/epimorphics/ukhpi/issues/409)

## 1.9.4 - 2024-08

- (Dan) Adds underline to link text for the feedback section to meet accessibility requirments [114](https://github.com/epimorphics/standard-reports-ui/issues/114)
- (Dan) Adds underline to link text in the cookie banner to meet accessibility requirments [126](https://github.com/epimorphics/lr-landing/issues/126)
- (Dan) Adds underline to link text for the feedback section to meet
accessibility requirments
[114](https://github.com/epimorphics/standard-reports-ui/issues/114)
- (Dan) Adds underline to link text in the cookie banner to meet accessibility
requirments [126](https://github.com/epimorphics/lr-landing/issues/126)

## 1.9.3 - 2023-11-27

- (Jon) If the app is running in production, and the `relative_url_root` excludes
`/app`, then the app name is appended to the relative_url_root of `/app`
This resolves the urls paths for the apps from the landing page, but not
for the apps themselves
- (Jon) If the app is running in production, and the `relative_url_root`
excludes `/app`, then the app name is appended to the relative_url_root of
`/app` This resolves the urls paths for the apps from the landing page, but
not for the apps themselves

## 1.9.2 - 2023-11-23

Expand Down Expand Up @@ -47,8 +60,8 @@ applications.

- (Jon) Updated the gemspec to ensure the dependency versions are locked to
specific base versions to avoid any potential issues with the gem being used
- (Jon) Minor text changes to the .gemspec file to update the summary
field to mirror the common fields set in other gems.
- (Jon) Minor text changes to the .gemspec file to update the summary field to
mirror the common fields set in other gems.
- (Jon) Refactored the version cadence creation to include a SUFFIX value if
provided; otherwise no SUFFIX is included in the version number.

Expand Down
38 changes: 23 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ GEM=${NAME}-${VERSION}.gem
GPR=https://rubygems.pkg.github.com/${OWNER}
SPEC=${NAME}.gemspec

all: publish

auth: ${AUTH}

build: gem

${AUTH}:
@mkdir -p ${HOME}/.gem
@echo '---' > ${AUTH}
Expand All @@ -25,23 +19,37 @@ ${AUTH}:
${GEM}: ${SPEC} ./lib/${NAME}/version.rb
gem build ${SPEC}

all: publish

auth: ${AUTH}

build: gem

clean:
@rm -rf ${GEM}

gem: ${GEM}
@echo ${GEM}

test: gem
@bundle install
@rake test

publish: ${AUTH} ${GEM}
@echo Publishing package ${NAME}:${VERSION} to ${OWNER} ...
@gem push --key github --host ${GPR} ${GEM}
@echo Done.

clean:
@rm -rf ${GEM}

realclean: clean
@rm -rf ${AUTH}
@rm -rf ${AUTH}

tags:
@echo version=${VERSION}

test: gem
@bundle install
@rake test

vars:
@echo "GEM" = ${GEM}
@echo "GPR" = ${GPR}
@echo "NAME = ${NAME}"
@echo "OWNER = ${OWNER}"
@echo "SPEC = ${SPEC}"
@echo "VERSION = ${VERSION}"
31 changes: 22 additions & 9 deletions app/models/lr_common_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ class LrCommonConfig
class << self
include ActionView::Helpers::UrlHelper

def app_link(app_name, request)
# Set the css classes for the link
css_classes = ['lr-header--header-proposition--a']
# If the current url contains the app name, set the active class
if request.original_url =~ /#{app_name}/
css_classes << 'lr-header--header-proposition--a__active'
end
def app_link(app_name, request, css_classes)
root = app_name == '/'
# Set the css classes for the link if they are not set
link_classes = set_link_classes(app_name, css_classes, root, request.original_url)
# Sub replaces just the first instance of the app name in the relative_url_root
path = relative_url_root.sub(%r{[^/]*\Z}, app_name)
path = root ? relative_url_root : relative_url_root.sub(%r{[^/]*\Z}, app_name)
# Add the lang param if it exists
path += "?lang=#{request.params[:lang]}" if request.params.key?(:lang)
# if the app name is the same as the current app, set the path to the root
t_name = root ? 'common.header.app_title' : "common.app.#{app_name}"
# Set the link id if an id is required
link_id = root ? 'proposition-name' : nil
# Return the link with the css classes and path set accordingly
link_to(I18n.t("common.app.#{app_name}"), path, class: css_classes.join(' '))
link_to(I18n.t(t_name), path, class: link_classes, id: link_id)
end

# Returns the relative url root for the app if running in a subdirectory
Expand All @@ -32,5 +33,17 @@ def relative_url_root
root_url = "/app#{root_url}" if root_url.exclude?('app') && Rails.env.production?
root_url
end

# Returns a space separated string of css classes for the link
# If the classes are not set, the default class is set
# If the app name is the same as the current url, the active class is set
def set_link_classes(name, classes, root, current_url)
classes = Array.wrap(classes) if classes.present?
# If the current url contains the app name, set the active class
if root == false && current_url =~ /#{name}/
classes << 'lr-header--header-proposition--a__active'
end
classes.join(' ')
end
end
end
25 changes: 1 addition & 24 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,7 @@
%body{ class: "government website lr lr-app" }
= render partial: "shared/cookie_banner"
= render partial: 'shared/skip_to_main_content'
%header#global-header.with-proposition.lr-header{ role: "banner" }
.header-wrapper
.header-global
.header-logo
%a.content{ href: 'https://www.gov.uk/government/organisations/land-registry/', title: I18n.t('common.header.home_link') }
= image_tag('hm_lr_logo.png', srcset: image_path('hm_lr_logo.svg'), alt: "HM Land Registry logo")
.header-proposition.lr-header--header-proposition
.content
%a.js-header-toggle.menu{ href: "#proposition-links"}
Menu
%nav#proposition-menu
%a#proposition-name.lr-header--proposition-name{ href: '/' }
= I18n.t('common.header.site_title')
%ul#proposition-links
%li
= LrCommonConfig.app_link( "ukhpi", request )
%li
= LrCommonConfig.app_link( "ppd", request )
%li
= LrCommonConfig.app_link( "standard-reports", request )
%li
= LrCommonConfig.app_link( "qonsole", request )

= render partial: "shared/header"
.o-lr-top-bar
Expand Down
23 changes: 13 additions & 10 deletions app/views/shared/_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
%h2.o-footer--h2.hidden Support links
%ul.list-inline
%li
%a{:href => "http://www.nationalarchives.gov.uk/information-management/our-services/crown-copyright.htm"}
&copy;
= t('common.footer.crown_copyright')
= Time.now.year
= link_to("&copy #{I18n.t('common.footer.crown_copyright')} #{Time.now.year}".html_safe, "http://www.nationalarchives.gov.uk/information-management/our-services/crown-copyright.htm")

%li
%a{:href => "https://www.gov.uk/government/organisations/land-registry/about/personal-information-charter"}
= t('common.footer.personal_info')
= link_to(I18n.t('common.footer.personal_info'), "https://www.gov.uk/government/organisations/land-registry/about/personal-information-charter")

%li
%a{:href => "https://www.gov.uk/land-registry-public-data"}
= t('common.footer.public_data')
= link_to(I18n.t('common.footer.public_data'), "https://www.gov.uk/land-registry-public-data")

%li
= link_to(I18n.t('common.footer.accessibility'), "#{Rails.application.config.accessibility_document_path}?lang=#{I18n.locale}")
= link_to(I18n.t('common.footer.accessibility'), "#{Rails.application.config.accessibility_document_path}#{"?lang=#{I18n.locale}" if params[:lang].present?}")
%li
= link_to(I18n.t('common.footer.privacy'), "#{Rails.application.config.privacy_document_path}?lang=#{I18n.locale}")
= link_to(I18n.t('common.footer.privacy'), "#{Rails.application.config.privacy_document_path}#{"?lang=#{I18n.locale}" if params[:lang].present?}")
.ogl.open-government-licence
%p.logo
%a{:href => "http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3", rel:"license"}
Expand All @@ -32,3 +30,8 @@
= succeed(':') do
= I18n.t('common.footer.application_release')
= Version::VERSION
- if Rails.env.development?
%pre
[puma stats:
= JSON.pretty_generate(JSON.parse(Puma.stats, symbolize_names: true))
, time: #{Time.now}]
45 changes: 11 additions & 34 deletions app/views/shared/_header.html.haml
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
%header.with-proposition.c-hmlr-header#global-header
%header#global-header.with-proposition.lr-header{ role: "banner" }
.header-wrapper
.header-global
.header-logo
%a.content{ href: '/app/ukhpi', title: t('common.header.home_link') }
= image_tag('ukhpi-icon.png', srcset: image_path('ukhpi-icon.svg'), alt: '')
%a.content{ href: 'https://www.gov.uk/government/organisations/land-registry/', title: I18n.t('common.header.home_link') }
= image_tag('hm_lr_logo.png', srcset: image_path('hm_lr_logo.svg'), alt: "HM Land Registry logo")


.header-proposition
.header-proposition.lr-header--header-proposition
.content
%a.js-header-toggle.menu{ href: '#proposition-links' } Menu
%nav#proposition-menu{ 'aria-label' => 'application menu' }
%a#proposition-name{ href: '/app/ukhpi' }
= t('common.header.app_title')

= link_to(t('common.header.menu_text'), '#proposition-links', class: 'js-header-toggle menu')
%nav#proposition-menu
= LrCommonConfig.app_link( "/", request, 'lr-header--proposition-name' )
%ul#proposition-links
%li
= link_to(t('action.browse'), browse_path(lang: I18n.locale), class: active_class(browse_path))
%li
= link_to(t('action.compare_locations'), compare_path(lang: I18n.locale), class: active_class(compare_path))
= LrCommonConfig.app_link( "ukhpi", request, 'lr-header--header-proposition--a' )
%li
= link_to(t('action.sparql'), '/app/qonsole')
= LrCommonConfig.app_link( "ppd", request, 'lr-header--header-proposition--a' )
%li
= link_to(t('action.user_guide'), doc_ukhpi_user_guide_path(lang: I18n.locale))
= LrCommonConfig.app_link( "standard-reports", request, 'lr-header--header-proposition--a' )
%li
= link_to(t('action.about'), doc_index_path(lang: I18n.locale), class: active_class(doc_index_path))
%li
= link_to(t('action.changelog'), changelog_index_path(lang: I18n.locale), class: active_class(changelog_index_path))

.o-lr-top-bar

.container.o-container
.o-secondary-banner
- if Rails.application.config.welsh_language_enabled
%nav.o-secondary-banner__lang-select{ 'aria-label' => 'language selector' }
- if @view_state.user_selections.english?
English
- else
= link_to('English', @view_state.user_selections.alternative_language_params.params)
|
- if @view_state.user_selections.welsh?
Cymraeg
- else
= link_to('Cymraeg', @view_state.user_selections.alternative_language_params.params)
= LrCommonConfig.app_link( "qonsole", request, 'lr-header--header-proposition--a' )
2 changes: 2 additions & 0 deletions app/views/shared/_lang_switch.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.o-secondary-banner
- if Rails.application.config.welsh_language_enabled
%nav.pull-right.o-secondary-banner__lang-select{ 'aria-label' => 'language selector' }
.visuallyhidden
= "#{I18n.t('common.header.language_selection')}: "
- if I18n.locale == :en
English
- else
Expand Down
4 changes: 3 additions & 1 deletion config/locales/cy.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
cy:
common:
header:
menu_text: "Dewislen"
home_link: "Ewch i hafan Mynegai Prisiau Tai y DU"
site_title: "Data Agored Cofrestrfa Tir EM"
app_title: "Data Agored Cofrestrfa Tir EM"
feedback_request: "Problem neu awgrym? Bydd eich <a rel='external' href='mailto:[email protected]'>adborth</a> yn ein helpu i wella’r gwasanaeth hwn."
language_selection: "Dewiswch eich dewis iaith"
cookie_banner:
heading: "Mae’r wefan hon yn defnyddio cwcis"
details: "Ffeiliau sy’n cael eu storio ar eich cyfrifiadur, ffôn neu lechen yw cwcis. Maen nhw’n ein helpu i ddeall sut rydych yn defnyddio’r wefan hon, er enghraifft pa dudalennau rydych yn ymweld â nhw. Am ragor o wybodaeth, edrychwch ar ein"
Expand All @@ -28,4 +30,4 @@ cy:
application_release: "Cyhoeddiad ap"
accessibility: "Hygyrchedd"
privacy: "Preifatrwydd"
additional_terms: "Mae rhai <a href='https://www.gov.uk/government/statistical-data-sets/price-paid-data-downloads#using-or-publishing-our-price-paid-data'>telerau trwyddedu ychwanegol</a> yn gymwys wrth ailgyhoeddi data cyfeiriadau."
additional_terms: "Mae rhai <a href='https://www.gov.uk/government/statistical-data-sets/price-paid-data-downloads#using-or-publishing-our-price-paid-data'>telerau trwyddedu ychwanegol</a> yn gymwys wrth ailgyhoeddi data cyfeiriadau."
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
en:
common:
header:
menu_text: "Menu"
home_link: "Go to the UK HPI homepage"
app_title: "HM Land Registry Open Data"
site_title: "HM Land Registry Open Data"
feedback_request: "Found a problem or have a suggestion? Your <a rel='external' href='mailto:[email protected]'>feedback</a> will help us to improve this service."
language_selection: "Choose your preferred language"
cookie_banner:
heading: "This site uses cookies"
details: "Cookies are files stored on your computer, phone, or tablet. They help us understand how you use this site, such as which pages you visit. For more information please read our"
Expand Down
6 changes: 3 additions & 3 deletions lib/lr_common_styles/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module LrCommonStyles
MAJOR = 1
MINOR = 9
PATCH = 5
SUFFIX = nil
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && ".#{SUFFIX}"}"
PATCH = 6
SUFFIX = nil # nil or 'rc' or 'beta' or 'alpha' for pre-release versions
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && "-#{SUFFIX}"}"
end
6 changes: 3 additions & 3 deletions lr_common_styles.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Gem::Specification.new do |s|
s.add_dependency 'rails', '~> 5.2.4'
s.add_dependency 'sass-rails', '~> 5.0.4'

s.add_development_dependency 'minitest-rails'
s.add_development_dependency 'mocha'
s.add_development_dependency 'rails_real_favicon'
s.add_development_dependency 'minitest-rails', '~> 5.2.0'
s.add_development_dependency 'mocha', '~> 2.0.0'
s.add_development_dependency 'rails_real_favicon', '~> 0.1.0'
end

0 comments on commit b194606

Please sign in to comment.