Skip to content

Commit

Permalink
Merge pull request #185 from rtablada/feature-customize-home-route
Browse files Browse the repository at this point in the history
Make dat homeRoute customizable!!!
  • Loading branch information
mike-north committed Jul 17, 2015
2 parents c5ebb7e + ef642bb commit ccd1fbf
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions addon/components/md-navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import computed from 'ember-new-computed';
export default Ember.Component.extend({
tagName: 'nav',
layout: layout,
homeRoute: 'index',

didInsertElement() {
this._super(...arguments);
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/md-navbar.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class='nav-wrapper'>
<div class='container'>
{{#link-to 'index' class='brand-logo'}}{{name}}{{/link-to}}
{{#link-to homeRoute class='brand-logo'}}{{name}}{{/link-to}}
<ul class='right hide-on-med-and-down'>
{{yield}}
</ul>
Expand Down
5 changes: 5 additions & 0 deletions tests/dummy/app/templates/navbar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
<h4 class="col s12 header">Navbar with mobile collapse button</h4>
{{example-snippet snippet='navbar-basic' class='navbar-example'}}
</div>

<div class="section">
<h4 class="col s12 header">Navbar with custom homeRoute defined</h4>
{{example-snippet snippet='navbar-custom-home' class='navbar-custom-home'}}
</div>
</div>
10 changes: 10 additions & 0 deletions tests/dummy/app/templates/snippets/navbar-custom-home.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{#md-navbar name='Example' class='indigo' homeRoute='navbar'}}
<!-- A workaround to get the "active" class
to apply to the active <li> automatically -->
{{#link-to 'navbar' tagName='li'}}
{{link-to 'Navbar' 'navbar'}}
{{/link-to}}
{{#link-to 'tabs' tagName='li'}}
{{link-to 'Tabs' 'tabs'}}
{{/link-to}}
{{/md-navbar}}
17 changes: 17 additions & 0 deletions tests/integration/navbar-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,20 @@ test('SideNav', assert => {

});
});

test('Navbar Custom Home Route', assert => {
visit('/navbar');

window.QUnit.stop();

andThen(() => {
click('.navbar-custom-home a.brand-logo');
});

andThen(() => {
assert.equal('/navbar', currentURL(), 'Navbar can have a custom home route');

window.QUnit.start();
});
});

0 comments on commit ccd1fbf

Please sign in to comment.