Last active
August 12, 2019 23:26
-
-
Save magistrula/7f0dfadcd277d1d1ef535beb10542ac7 to your computer and use it in GitHub Desktop.
LinkTo Active Styling
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({ | |
}); |
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 { BARS } from 'twiddle/routes/my-bar-route/my-bar-child-route'; | |
export default Ember.Controller.extend({ | |
bars: null, | |
init() { | |
this._super(...arguments); | |
this.setProperties({ bars: BARS }); | |
} | |
}); |
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 { timestamps } from 'twiddle/routes/my-bar-route/my-bar-child-route'; | |
export default Ember.Controller.extend({ | |
timestamps: null, | |
afterModelBeforeModelDiff: Ember.computed( | |
'timestamps.afterModel', | |
'timestamps.beforeModel', | |
function() { | |
return ( | |
this.get('timestamps.afterModel') - | |
this.get('timestamps.beforeModel') | |
); | |
} | |
), | |
init() { | |
this._super(...arguments); | |
this.set('timestamps', timestamps); | |
} | |
}); |
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 EmberRouter from '@ember/routing/router'; | |
import config from './config/environment'; | |
const Router = EmberRouter.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('my-foo-route'); | |
this.route('my-bar-route', function() { | |
this.route('my-bar-child-route', { path: ':bar_id' }); | |
}); | |
this.route('my-foo-related-route'); | |
}); | |
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({ | |
}); |
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'; | |
const BAR1 = { id: 'bar-1', name: 'Bar 1' }; | |
const BAR2 = { id: 'bar-2', name: 'Bar 2' }; | |
export const BARS = [BAR1, BAR2]; | |
export const timestamps = {}; | |
export default Ember.Route.extend({ | |
beforeModel(model) { | |
Ember.set(timestamps, 'beforeModel', Date.now()); | |
return new Ember.RSVP.Promise((resolve) => { | |
Ember.run.later(resolve, 100); | |
}); | |
}, | |
model(params) { | |
const id = params.bar_id; | |
return new Ember.RSVP.Promise((resolve) => { | |
const bar = BARS.findBy('id', id); | |
Ember.run.later(() => resolve(bar), 100); | |
}); | |
}, | |
afterModel(model) { | |
Ember.set(timestamps, 'afterModel', Date.now()); | |
} | |
}); |
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({ | |
}); |
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 { | |
text-decoration: none; | |
color: gray; | |
} | |
a.active { | |
color: dodgerblue; | |
} |
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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "2.12.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment