-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the new navigation concept for Newshub #808
Conversation
assets/index.ts
Outdated
const pinButton = document.getElementById('pin-btn'); | ||
|
||
if (pinButton != null) { | ||
pinButton.onclick = handleNavExpanded; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use pinButton.addEventListener
it's a more idiomatic way to do this.
assets/index.ts
Outdated
handleNavExpanded(); | ||
} | ||
|
||
function handleNavExpanded() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming implies the function only runs on expansion, when in fact it also runs on collapsing. The name would be needed to be updated accordingly, but since that function is only used once - it doesn't make sesne to have it at all. Simply inline it in the event listener callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this function is not used only once...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right - I missed the second usage. Then only improve the name.
assets/index.ts
Outdated
} | ||
|
||
function handleNavExpanded() { | ||
if (element?.classList.contains('nav-block--pinned')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve readability by returning early if element is null and doing the logic afterwards
* add navigation * changes after review * fix lint * chages after review
NHUB-485
Checklist
lodash.get
with optional chaining for modified code segments