Skip to content

Commit

Permalink
Merge pull request #25 from tommaton/CPD-11644
Browse files Browse the repository at this point in the history
CPD-11644
  • Loading branch information
ashleynolan authored Feb 15, 2018
2 parents cbe5bd8 + 70018a9 commit 93379e8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

v0.19.0
------------------------------
*February 14, 2018*

### Changed
- Added class `is-navInView` to `nav` partial.
- Added toggling funcionality of class `is-navInView` to html element to prevent users scrolling page when navigation is in viev.
- Added tests for the toggling of class to the HTML element.

v0.18.0
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@justeat/f-header",
"description": "Fozzie Header – Header Component for Just Eat projects",
"version": "0.18.0",
"version": "0.19.0",
"main": "dist/js/index.js",
"files": [
"dist",
Expand Down
3 changes: 3 additions & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const setupHeader = () => {
if (navLabel) {
navLabel.classList.toggle('is-open');
}

document.documentElement.classList.toggle('is-navInView');

});
}
};
Expand Down
6 changes: 6 additions & 0 deletions src/scss/partials/_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ $nav-popover-padding : spacing(x2);
z-index 0s linear;
}

// removes scroll
.is-navInView {
@include media('<mid') {
overflow: hidden;
}
}

// Global site-wide navigation
.c-nav--global {
Expand Down
6 changes: 6 additions & 0 deletions test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`header adds \`is-navInView\` class to html element 1`] = `
"<html class=\\"is-navInView\\"><head></head><body>
<button data-nav-enhance=\\"\\" type=\\"button\\"></button>
</body></html>"
`;
exports[`header adds \`is-open\` class to nav label 1`] = `
"
<button data-nav-enhance=\\"\\" type=\\"button\\"></button>
Expand Down
15 changes: 15 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,19 @@ describe('header', () => {
expect(html).toMatchSnapshot();
});

it('adds `is-navInView` class to html element', () => {
// Arrange
TestUtils.setBodyHtml(`
<input data-nav-enhance />
`);
header();
const button = document.querySelector('button[data-nav-enhance]');

// Act
TestUtils.click(button);

// Assert
const html = document.documentElement.outerHTML;
expect(html).toMatchSnapshot();
});
});

0 comments on commit 93379e8

Please sign in to comment.