Skip to content
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

Improve presentation of navigation at mobile #16

Merged
merged 5 commits into from
Mar 7, 2017

Conversation

djmattyg007
Copy link
Contributor

  • Add button to show/hide menu items
  • Ensure navigation fills the width of the viewport by moving it out of
    the main container element

@djmattyg007
Copy link
Contributor Author

I didn't realise there were tests for this. I'll take a look soon.

- Add button to show/hide menu items
- Ensure navigation fills the width of the viewport by moving it out of
  the main container element
@djmattyg007
Copy link
Contributor Author

I've rebased my branch on top of your rebased branch, and fixed the test that I broke.

@djmattyg007
Copy link
Contributor Author

I've pushed up another commit that should resolve the line length issue. I find it odd that the line length test failed on python2 but not python3.

@Thor77
Copy link
Owner

Thor77 commented Feb 27, 2017

Thanks for your contribution, will start reviewing it asap :)

I find it odd that the line length test failed on python2 but not python3.

For each commit Travis creates 4 builds: Three are just running unit-tests for each supported python-version (2.7, 3.5 and 3.6) and one is running style-tests (running py2.7 because it's already available in travis containers and therefore doesn't need to be downloaded => faster build times)

@@ -35,7 +35,8 @@ def test_debug(output):
logger.setLevel(logging.INFO)
soup = BeautifulSoup(open(output_path), 'html.parser')
# check debug-label presence
assert soup.find('nav').find(id='main-nav').find('span').text == 'debug mode'
debug_element = soup.find('nav').find('div', id='main-nav').find('span')
Copy link
Owner

@Thor77 Thor77 Feb 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could've just split the line with a backslash (\) before the== but you can keep it this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think there was a neat place to split the line using a backslash. Any positioning would have made the code far less readable than just keeping it all on one line IMO.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, would've looked like this with splitting by backslash:

assert soup.find('nav').find(id='main-nav').find('span').text \
    == 'debug mode'

Don't think that's far less readable.

@@ -49,5 +59,23 @@
{% endfor %}
<small>Generated by <a href="https://github.com/Thor77/TeamspeakStats" rel="noopener">TeamspeakStats</a> at {{ creation_time|frmttime }}</small>
</div>

<script type="text/javascript">
document.addEventListener('click', function(event) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please attach the event-listener just to the button and not to the whole document.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using event delegation: https://davidwalsh.name/event-delegate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's what the default bootstrap javascript would do if it was to be used, just with jQuery instead of vanilla javascript.

Copy link
Owner

@Thor77 Thor77 Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, okey. Thanks for linking this article, but can you at least add it just to the nav-object instead of the whole document?

Copy link
Owner

@Thor77 Thor77 Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about it for a while now and I don't think we should use event delegation here, as we only need one eventlistener and are not dynamically modifying the DOM. Therefore we don't use any of the benefits of event-delegation.

</nav>
<div id="main-nav" class="collapse navbar-collapse">
<ul class="navbar-nav mr-auto">
<li class="hidden-md-down"><a href="" class="navbar-brand">{{ title }}</a></li>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you're adding navbar-brand for a second time here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One is used for mobile and tablet, the other is used for desktop. The new navbar markup means it's much easier to do this than to try and only have one navbar-brand element.

var toggleTarget = document.getElementById(toggler.dataset.target);

if (toggleTarget.classList.contains('collapse')) {
toggleTarget.classList.remove('collapse');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, please don't mess with the collapse-class here. You can check the current collapse-state via the aria-expanded-attribute, can't you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a good answer to this, as there's nothing to stop the presence of the collapse class and the value of the aria-expanded attribute from getting out of sync. I'm happy to test whichever one you prefer, but it is easier to test for the presence of the classname IMO.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to just rely on aria-expanded, because adding/removing classes just for saving a state seems kinda wrong to me.

@djmattyg007
Copy link
Contributor Author

I should get to these updates over the weekend.

@djmattyg007
Copy link
Contributor Author

I've just pushed the requested updates.

@Thor77 Thor77 merged commit 9777f77 into Thor77:bootstrap4 Mar 7, 2017
@Thor77
Copy link
Owner

Thor77 commented Mar 7, 2017

Thanks for your contribution! 👍

@djmattyg007 djmattyg007 deleted the bootstrap4 branch March 8, 2017 21:40
Thor77 pushed a commit that referenced this pull request Mar 9, 2017
* add button to show/hide menu items
* ensure navigation fills the width of the viewport by moving it out of the main container element
Thor77 pushed a commit that referenced this pull request Aug 23, 2017
* add button to show/hide menu items
* ensure navigation fills the width of the viewport by moving it out of the main container element
Thor77 pushed a commit that referenced this pull request Sep 8, 2017
* add button to show/hide menu items
* ensure navigation fills the width of the viewport by moving it out of the main container element
Thor77 pushed a commit that referenced this pull request Jan 19, 2018
* add button to show/hide menu items
* ensure navigation fills the width of the viewport by moving it out of the main container element
Thor77 pushed a commit that referenced this pull request Jun 30, 2018
* add button to show/hide menu items
* ensure navigation fills the width of the viewport by moving it out of the main container element
Thor77 pushed a commit that referenced this pull request Mar 10, 2019
* add button to show/hide menu items
* ensure navigation fills the width of the viewport by moving it out of the main container element
Thor77 pushed a commit that referenced this pull request Mar 10, 2019
* add button to show/hide menu items
* ensure navigation fills the width of the viewport by moving it out of the main container element
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants