Last active
July 20, 2016 08:03
-
-
Save phillipkregg/dffc679fb96434ba6698161ba7617d15 to your computer and use it in GitHub Desktop.
Actions Up - Capturing State
This file contains hidden or 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({ | |
currentlySelectedRestaurant: undefined, | |
actions: { | |
selectRestaurant: function(restaurant) { | |
// The 'sendAction' method is where the magic happens. | |
// A method called 'stateSetter' references a function | |
// that lives either on the controller or the route. | |
// This was setup when the component was instantiated in the | |
// fancy-restaurants.hbs file. | |
this.sendAction('stateSetter', restaurant); | |
this.set('currentlySelectedRestaurant', restaurant); | |
} | |
} | |
}); |
This file contains hidden or 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: 'Capturing State without using a Service' | |
}); |
This file contains hidden or 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 eq = (params) => params[0] === params[1]; | |
export default Ember.Helper.helper(eq); |
This file contains hidden or 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('fancy-restaurants'); | |
}); | |
export default Router; |
This file contains hidden or 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({ | |
// Properties Here | |
currentlySelectedRestaurant: 'Please Select a Restaurant', | |
model: function() { | |
return ['Taco Bell', 'McDonalds', 'Dennys'] | |
}, | |
actions: { | |
setupRestaurantState : function(restaurant) { | |
this.set('currentlySelectedRestaurant', restaurant); | |
}, | |
getComponentState: function() { | |
alert(this.get('currentlySelectedRestaurant')); | |
} | |
} | |
}); |
This file contains hidden or 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 hidden or 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 url(https://fonts.googleapis.com/css?family=Poppins); | |
body { | |
margin: 12px 16px; | |
font-family: 'Poppins'; | |
font-size: 16px; | |
color: #333; | |
background-color: #ffe9e9; | |
} | |
p { | |
font-size: 20px; | |
} | |
a { | |
padding: 10px 15px; | |
display: inline-block; | |
background: #000; | |
color: #FFF; | |
font-size: 1em; | |
text-decoration: none; | |
} | |
a.active { | |
background: #7a3131; | |
} | |
button { | |
color: white; | |
border: none; | |
background: none; | |
border-radius: 4px; | |
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); | |
background: #000; | |
height: 70px; | |
margin: 10px 0; | |
width: 100%; | |
font-size: 20px; | |
} | |
button:active { | |
background: rgba(0, 0, 0, 0.75); /* this is a green */ | |
} | |
.restaurant-list-container { | |
} | |
.restaurant-list-title { | |
border-bottom: 1px solid #ccc; | |
color: #aaa; | |
} | |
.restaurant-list-container ul { | |
padding: 0; | |
margin: 0; | |
list-style-type: none; | |
} | |
.restaurant-list-container ul li { | |
padding: 10px; | |
margin: 10px 0; | |
background: #7a3131; | |
border: 1px solid #000; | |
border-radius: 2px; | |
cursor: pointer; | |
transition: background 250ms; | |
color: #ffe9e9; | |
} | |
.restaurant-list-container ul li.selected { | |
background: #db6b6b; | |
color: #ffe9e9; | |
} | |
a.body-link { | |
display: inline; | |
background: none; | |
color: #7a3131; | |
font-size: 20px; | |
text-decoration: underline; | |
} | |
.restaurant-list-container ul li:active { | |
background: #db6b6b; | |
color: white; | |
} |
This file contains hidden or 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.10.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.6.0", | |
"ember-data": "2.6.1", | |
"ember-template-compiler": "2.6.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment