Skip to content

Commit

Permalink
Merge pull request #319 from id-sk/feature/IDSKRP-64-create-new-header
Browse files Browse the repository at this point in the history
header web accisibility fix
  • Loading branch information
LubosKat authored Nov 2, 2021
2 parents 58fd3df + 225fa2d commit 9665943
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 34 deletions.
43 changes: 40 additions & 3 deletions src/idsk/components/header-web/_header-web.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
$idsk-header-link: govuk-colour("white") !default;
$idsk-header-dark-blue: govuk-colour("dark-blue") !default;

$idsk-header-logo-height: 40px;
$idsk-header-logo-height: 50px;
$idsk-header-logo-height--mobile: 40px;

.idsk-header-web {

Expand Down Expand Up @@ -115,8 +116,18 @@
color: $idsk-header-text-secondary;
}

.govuk-grid-column-full {
display: flex;
justify-content: space-between;
}

&-gestor {
float: left;

.govuk-width-container {
position: absolute;
width: 100vw;
}

.govuk-body-s {
display: inline-block;
Expand Down Expand Up @@ -162,6 +173,7 @@
border: none;
color: $idsk-header-text-secondary;
font-weight: 700;
cursor: pointer;

&:hover {
text-decoration: underline;
Expand Down Expand Up @@ -202,11 +214,17 @@
&-dropdown {
overflow: hidden;
display: none;
position: relative;

.govuk-link:focus {
color: govuk-colour("black");
}

.govuk-width-container {
margin: 0;
width: 93vw;
}

.govuk-body-s:first-child {
font-weight: 700;
margin: govuk-spacing(4) 0 0;
Expand Down Expand Up @@ -240,6 +258,23 @@
}
}

&-spacer {
display: none;
height: 190px;

@include mq($until: tablet){
height: 280px;
}

@include mq($from: tablet, $until: desktop){
height: 202px;
}

&--active {
display: initial;
}
}

/* language selector */
&-language {
float: right;
Expand Down Expand Up @@ -282,6 +317,7 @@
border: none;
color: $idsk-header-text-secondary;
margin: 9px 0 9px 0;
cursor: pointer;

&:hover {
text-decoration: underline;
Expand Down Expand Up @@ -463,11 +499,11 @@
}

&-logo {
height: 40px;
height: $idsk-header-logo-height;
margin-right: govuk-spacing(3);

@include mq($until: desktop) {
height: 30px;
height: $idsk-header-logo-height--mobile;
}
}

Expand Down Expand Up @@ -1079,6 +1115,7 @@
background-color: transparent;
border: none;
padding: govuk-spacing(1) govuk-spacing(1) 2px govuk-spacing(1);
cursor: pointer;

&:focus,
&:focus-visible,
Expand Down
36 changes: 31 additions & 5 deletions src/idsk/components/header-web/header-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ HeaderWeb.prototype.init = function () {

// check for e-goverment button
var $eGovermentButtons = $module.querySelectorAll('.idsk-header-web__brand-gestor-button');
this.$eGovermentSpacer = $module.querySelector('.idsk-header-web__brand-spacer');
if ($eGovermentButtons.length > 0) {
// Handle $eGovermentButton click event
nodeListForEach($eGovermentButtons, function ($eGovermentButton) {
Expand All @@ -64,6 +65,7 @@ HeaderWeb.prototype.init = function () {
$menuItem.addEventListener('click', this.handleSubmenuClick.bind(this));
if($menuItem.parentElement.querySelector('.idsk-header-web__nav-submenu') || $menuItem.parentElement.querySelector('.idsk-header-web__nav-submenulite')){
$menuItem.parentElement.lastElementChild.addEventListener('keydown', this.menuTabbing.bind(this));
$menuItem.parentElement.addEventListener('keydown', this.menuEscPressed.bind(this));
}
}.bind(this))
}
Expand Down Expand Up @@ -129,7 +131,8 @@ HeaderWeb.prototype.handleBackTabbing = function (e) {
HeaderWeb.prototype.handleEgovermentClick = function (e) {
var $eGovermentButtons = this.$module.querySelectorAll('.idsk-header-web__brand-gestor-button');
var $eGovermentDropdown = this.$module.querySelector('.idsk-header-web__brand-dropdown');
toggleClass($eGovermentDropdown, 'idsk-header-web__brand-dropdown--active');
toggleClass($eGovermentDropdown, 'idsk-header-web__brand-dropdown--active');
toggleClass(this.$eGovermentSpacer, 'idsk-header-web__brand-spacer--active');
nodeListForEach($eGovermentButtons, function ($eGovermentButton) {
toggleClass($eGovermentButton, 'idsk-header-web__brand-gestor-button--active');
if($eGovermentButton.classList.contains('idsk-header-web__brand-gestor-button--active')){
Expand Down Expand Up @@ -183,23 +186,39 @@ HeaderWeb.prototype.handleSubmenuClick = function (e) {
return;
}

var submenuList = e.srcElement.parentElement.parentElement;
var $activeItem = submenuList.closest('.idsk-header-web__nav-list-item')
var $submenuList = e.srcElement.parentElement.parentElement;
var $activeItem = $submenuList.closest('.idsk-header-web__nav-list-item')
// shift + tab
if (e.shiftKey) {
if (document.activeElement === submenuList.firstElementChild.firstElementChild) {
if (document.activeElement === $submenuList.firstElementChild.firstElementChild) {
$activeItem.classList.remove('idsk-header-web__nav-list-item--active');
$activeItem.childNodes[1].setAttribute('aria-expanded', 'false');
$activeItem.childNodes[1].setAttribute('aria-label', $activeItem.childNodes[1].getAttribute('data-text-for-show'))
}
// tab
} else if (document.activeElement === submenuList.lastElementChild.lastElementChild) {
} else if (document.activeElement === $submenuList.lastElementChild.lastElementChild) {
$activeItem.classList.remove('idsk-header-web__nav-list-item--active');
$activeItem.childNodes[1].setAttribute('aria-expanded', 'false');
$activeItem.childNodes[1].setAttribute('aria-label', $activeItem.childNodes[1].getAttribute('data-text-for-show'))
}
}

/**
* Remove active class from menu when user leaves menu with esc
*/
HeaderWeb.prototype.menuEscPressed = function (e) {
if(e.key === "Escape") {
var $menuList = e.srcElement.parentElement.parentElement;
if($menuList.classList.contains('idsk-header-web__nav-submenulite-list') || $menuList.classList.contains('idsk-header-web__nav-submenu-list')){
$menuList = $menuList.closest('.idsk-header-web__nav-list')
}
var $activeItem = $menuList.querySelector('.idsk-header-web__nav-list-item--active')
$activeItem.classList.remove('idsk-header-web__nav-list-item--active');
$activeItem.childNodes[1].setAttribute('aria-expanded', 'false');
$activeItem.childNodes[1].setAttribute('aria-label', $activeItem.childNodes[1].getAttribute('data-text-for-show'))
}
}

/**
* handle click outside menu or "blur" the item link
*/
Expand All @@ -225,6 +244,13 @@ HeaderWeb.prototype.showMobileMenu = function (e) {
var $mobileMenu = this.$module.querySelector('.idsk-header-web__nav');
toggleClass($mobileMenu, 'idsk-header-web__nav--mobile');
toggleClass($menuButton, 'idsk-header-web__main-headline-menu-button--active');
if(!$menuButton.classList.contains('idsk-header-web__main-headline-menu-button--active')){
$menuButton.setAttribute('aria-expanded', 'false');
$menuButton.setAttribute('aria-label', $menuButton.getAttribute('data-text-for-show'))
}else{
$menuButton.setAttribute('aria-expanded', 'true');
$menuButton.setAttribute('aria-label', $menuButton.getAttribute('data-text-for-hide'))
}
var buttonIsActive = $menuButton.classList.contains('idsk-header-web__main-headline-menu-button--active');

$menuButton.childNodes[0].nodeValue = buttonIsActive ? closeText : this.menuBtnText;
Expand Down
4 changes: 4 additions & 0 deletions src/idsk/components/header-web/header-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ params:
type: string
required: false
description: Allows you to overwrite the idsk.sk logo
- name: logoAlt
type: string
required: false
description: Allows you to use alt text for logo
- name: title
type: string
required: true
Expand Down
60 changes: 34 additions & 26 deletions src/idsk/components/header-web/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,31 @@
</button>
{% endif %}
</span>

<div class="idsk-header-web__brand-dropdown">
<div class="govuk-width-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<h3 class="govuk-body-s">
Doména gov.sk je oficálna
</h3>
<p class="govuk-body-s">
Toto je oficiálna webová stránka orgánu verejnej moci Slovenskej republiky. Oficiálne stránky využívajú najmä doménu gov.sk. <a class="govuk-link" href="https://www.slovensko.sk/sk/agendy/agenda/_organy-verejnej-moci" target="_blank" title="odkazy na webové sídla orgánov verejnej moci">Odkazy na jednotlivé webové sídla orgánov verejnej moci nájdete na tomto odkaze</a>.
</p>
</div>
<div class="govuk-grid-column-one-half">
<h3 class="govuk-body-s">
Táto stránka je zabezpečená
</h3>
<p class="govuk-body-s">
Buďte pozorní a vždy sa uistite, že zdieľate informácie iba cez zabezpečenú webovú stránku verejnej správy SR. Zabezpečená stránka vždy začína https:// pred názvom domény webového sídla.
</p>
</div>
</div>
</div>
</div>
</div>
<div class="idsk-header-web__brand-spacer"></div>
{% endif %}

<div class="idsk-header-web__brand-language">
Expand All @@ -73,27 +97,6 @@
</div>
</div>
</div>

<div class="idsk-header-web__brand-dropdown">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<p class="govuk-body-s">
Doména gov.sk je oficálna
</p>
<p class="govuk-body-s">
Toto je oficiálna webová stránka orgánu verejnej moci Slovenskej republiky. Oficiálne stránky využívajú najmä doménu gov.sk. <a class="govuk-link" href="https://www.slovensko.sk/sk/agendy/agenda/_organy-verejnej-moci" target="_blank" title="odkazy na webové sídla orgánov verejnej moci">Odkazy na jednotlivé webové sídla orgánov verejnej moci nájdete na tomto odkaze</a>.
</p>
</div>
<div class="govuk-grid-column-one-half">
<p class="govuk-body-s">
Táto stránka je zabezpečená
</p>
<p class="govuk-body-s">
Buďte pozorní a vždy sa uistite, že zdieľate informácie iba cez zabezpečenú webovú stránku verejnej správy SR. Zabezpečená stránka vždy začína https:// pred názvom domény webového sídla.
</p>
</div>
</div>
</div>
</div>
</div>
{% endset %}
Expand Down Expand Up @@ -175,10 +178,12 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-full govuk-grid-column-one-third-from-desktop">
<div class="idsk-header-web__main-headline">
<a href="/" title="home page button">
<a href="/" title="Odkaz na úvodnú stránku">
{% if params.headerType == 'website' or params.headerType == 'projectWebsite' %}
{% if main.logoSrc %}
<img src="{{ main.logoSrc }}" alt="Logo poskytovateľa služby" class="idsk-header-web__main-headline-logo">
<img src="{{ main.logoSrc }}"
alt="{{ main.logoAlt if main.logoAlt else 'Ministerstvo investícií, regionálneho rozvoja a informatizácie Slovenskej republiky' }}"
class="idsk-header-web__main-headline-logo">
{% endif %}
{% if main.title %}
<h2 class="govuk-heading-m">{{ main.title }}</h2>
Expand All @@ -191,19 +196,22 @@
</a>

{% if params.navBar and params.headerType !== 'electronicService' %}
<button class="idsk-button idsk-header-web__main-headline-menu-button">
<button class="idsk-button idsk-header-web__main-headline-menu-button" aria-label="Rozbaliť menu" aria-expanded="false"
data-text-for-show="Rozbaliť menu" data-text-for-hide="Skryť menu">
{{ main.menuBtnText if main.menuBtnText else 'Menu' }}
<div class="idsk-header-web__menu-open"></div>
<div class="idsk-header-web__menu-close"></div>
</button>
{% elif params.headerType !== 'electronicService' %}
<button class="idsk-button idsk-header-web__main-headline-menu-button">
<button class="idsk-button idsk-header-web__main-headline-menu-button" aria-label="Rozbaliť menu" aria-expanded="false"
data-text-for-show="Rozbaliť menu" data-text-for-hide="Skryť menu">
{{ main.menuBtnText if main.menuBtnText else 'Hľadaj' }}
<div class="idsk-header-web__menu-open"></div>
<div class="idsk-header-web__menu-close"></div>
</button>
{% elif main.loginButton %}
<button class="idsk-button idsk-header-web__main-headline-menu-button idsk-header-web__main-headline-menu-button-service">
<button class="idsk-button idsk-header-web__main-headline-menu-button idsk-header-web__main-headline-menu-button-service"
aria-label="Rozbaliť menu" aria-expanded="false" data-text-for-show="Rozbaliť menu" data-text-for-hide="Skryť menu">
<img src="/assets/images/header-web/profile.svg" alt="Electronic service menu icon">
<div class="idsk-header-web__menu-close"></div>
</button>
Expand Down

0 comments on commit 9665943

Please sign in to comment.