Skip to content

Commit 8555509

Browse files
committed
refactor: move llogic for handling the nav opening / closing out of styleguide.js
1 parent c76bd92 commit 8555509

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

packages/uikit-workshop/src/scripts/components/pl-header/pl-header.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,26 @@ class Header extends BaseComponent {
1212
constructor(self) {
1313
self = super(self);
1414
this.useShadow = false;
15+
this.toggleNav = this.toggleNav.bind(this);
1516
return self;
1617
}
1718

1819
_stateChanged(state) {}
1920

21+
toggleNav() {
22+
const navTarget = this.querySelector('.pl-js-nav-target');
23+
navTarget.classList.toggle('pl-is-active'); // @todo: refactor to have this add based on the component's state
24+
}
25+
2026
render() {
2127
return (
2228
<header class="pl-c-header" role="banner">
23-
<button class="pl-c-header__nav-toggle pl-js-nav-trigger">Menu</button>
29+
<button
30+
class="pl-c-header__nav-toggle pl-js-nav-trigger"
31+
onClick={this.toggleNav}
32+
>
33+
Menu
34+
</button>
2435
<nav
2536
class="pl-c-nav pl-js-nav-target pl-js-nav-container"
2637
role="navigation"

packages/uikit-workshop/src/scripts/components/styleguide.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ import { urlHandler, DataSaver, patternName } from '../utils';
5555
}
5656
});
5757

58-
// Nav menu button on small screens
59-
$('.pl-js-nav-trigger').on('click', function(e) {
60-
e.preventDefault();
61-
$('.pl-js-nav-target').toggleClass('pl-is-active');
62-
});
6358

6459
// Accordion dropdown
6560
$('.pl-js-acc-handle').on('click', function(e) {

0 commit comments

Comments
 (0)