Last active
December 13, 2017 01:11
-
-
Save andybluntish/85c8562dbb6757ccb62230f5b857ca89 to your computer and use it in GitHub Desktop.
Accordion nav demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: '', | |
label: null | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'li', | |
classNames: ['accordion-item'], | |
classNameBindings: [ | |
'isSelected:accordion-item--active', | |
'isCurrent:accordion-item--current' | |
], | |
selected: null, | |
select: null, | |
isSelected: Ember.computed('selected', { | |
get() { | |
return this.get('selected') === this.get('elementId') | |
} | |
}), | |
isCurrent: Ember.computed('selected', { | |
get() { | |
return this.$('a.ember-view.active').length; | |
} | |
}), | |
didReceiveAttrs() { | |
// If there is no "selected" item, and this item has renderd a link-to for the | |
// current route, make this the selected item. | |
Ember.run.schedule('afterRender', this, function() { | |
if (!this.get('selected') && this.$('a.ember-view.active').length) { | |
this.get('select')(this.get('elementId')) | |
} | |
}) | |
}, | |
click() { | |
this.get('select')(this.get('elementId')) | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Accordion Nav Demo', | |
selectedNav: null, | |
actions: { | |
selectActiveNavigationItem() { | |
this.set('selectedNav', null) | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('contact-us'); | |
this.route('teaching-resources', function() { | |
this.route('k-2'); | |
this.route('3-4'); | |
this.route('5-6'); | |
this.route('big-books'); | |
this.route('book-notes'); | |
this.route('naplan'); | |
}); | |
this.route('manage'); | |
this.route('reading', function() { | |
this.route('re', function() { | |
this.route('preview-lessons'); | |
this.route('manage-lessons'); | |
this.route('reports', function() { | |
this.route('dashboard'); | |
this.route('time-on-task'); | |
this.route('reading'); | |
this.route('quizzes-completed'); | |
this.route('driving-tests'); | |
this.route('lexile-level-and-growth'); | |
this.route('spelling'); | |
this.route('stories-written'); | |
this.route('storylands'); | |
this.route('books-read'); | |
this.route('certificates-earned'); | |
}); | |
}); | |
this.route('rex', function() { | |
this.route('preview-lessons'); | |
this.route('manage-lessons'); | |
this.route('manage-assignments'); | |
this.route('reports', function() { | |
this.route('dashboard'); | |
this.route('time-on-task'); | |
this.route('comprehension'); | |
this.route('quizzes-completed'); | |
this.route('assessments-completed'); | |
this.route('lexile-level-and-growth'); | |
this.route('spelling'); | |
this.route('books-read'); | |
this.route('books-read-by-level'); | |
this.route('stadium'); | |
this.route('trophies-earned'); | |
}); | |
}); | |
}); | |
this.route('quick-links', function() { | |
this.route('research-reports'); | |
this.route('user-guides'); | |
this.route('subscription-order-form'); | |
this.route('tell-a-colleague'); | |
}); | |
}); | |
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
actions: { | |
didTransition() { | |
this.controller.send('selectActiveNavigationItem') | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
a { | |
display: block; | |
color: grey; | |
} | |
a.active { color: green; } | |
.accordion-menu { | |
} | |
.accordion-menu ol, | |
.accordion-menu ul { | |
margin: 0; | |
padding: 0; | |
list-style: 0; | |
} | |
.accordion-menu li { | |
list-style: none; | |
margin: 4px; | |
padding: 4px; | |
} | |
.accordion-group__label { | |
font-size: 100%; | |
margin: 12px 4px 4px; | |
} | |
.accordion-group__list { | |
} | |
.accordion-item { | |
border-bottom: 1px solid lightgrey; | |
} | |
.accordion-item--current { | |
border-bottom-color: green; | |
} | |
.accordion-item__label { | |
color: grey; | |
} | |
span.accordion-item__label { | |
display: block; | |
} | |
span.accordion-item__label:after { | |
content: '▶︎'; | |
position: absolute; | |
right: 25px; | |
} | |
.accordion-item--active > span.accordion-item__label:after { | |
content: '▼'; | |
} | |
.accordion-item--current > .accordion-item__label { | |
color: green; | |
} | |
.accordion-item__children { | |
display: none; | |
} | |
.accordion-item--active > .accordion-item__children { | |
display: block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default function destroyApp(application) { | |
Ember.run(application, 'destroy'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Resolver from '../../resolver'; | |
import config from '../../config/environment'; | |
const resolver = Resolver.create(); | |
resolver.namespace = { | |
modulePrefix: config.modulePrefix, | |
podModulePrefix: config.podModulePrefix | |
}; | |
export default resolver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import Application from '../../app'; | |
import config from '../../config/environment'; | |
const { run } = Ember; | |
const assign = Ember.assign || Ember.merge; | |
export default function startApp(attrs) { | |
let application; | |
let attributes = assign({rootElement: "#test-root"}, config.APP); | |
attributes = assign(attributes, attrs); // use defaults, but you can override; | |
run(() => { | |
application = Application.create(attributes); | |
application.setupForTesting(); | |
application.injectTestHelpers(); | |
}); | |
return application; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resolver from './helpers/resolver'; | |
import { | |
setResolver | |
} from 'ember-qunit'; | |
setResolver(resolver); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment