Last active
March 7, 2016 15:25
-
-
Save grapho/d3416c6d6101fff593e9 to your computer and use it in GitHub Desktop.
Component Grid
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: 'a Grid of Components', | |
actions: { | |
action1() { alert("action1 fired"); }, | |
action2() { alert("action2 fired"); }, | |
action3() { alert("action3 fired"); }, | |
action4() { alert("action4 fired"); }, | |
action5() { alert("action5 fired"); }, | |
action6() { alert("action6 fired"); }, | |
action7() { alert("action7 fired"); }, | |
action8() { alert("action8 fired"); } | |
} | |
}); |
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({ | |
classNames: ['component-grid'], | |
gridRows: Ember.computed('components.[]', 'rows', 'cells', { | |
get() { | |
let components = this.get('components'); | |
let totalRows = parseInt(this.get('rows')); | |
let totalCells = parseInt(this.get('cells')); | |
let rows = []; | |
for (let i = 0; i < totalRows; i++) { | |
let cells = []; | |
for (let j = 0; j < totalCells; j++) { | |
let idx = (totalCells * i) + j; | |
cells.push(idx); | |
} | |
rows.pushObject(Ember.Object.create({ | |
gridCells: components.objectsAt(cells) | |
})); | |
} | |
return rows; | |
} | |
}) | |
}); |
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({ | |
tagName: 'button', | |
classNames: ['foo-a'] | |
}); |
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({ | |
tagName: 'button', | |
classNames: ['foo-b'] | |
}); |
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 function array(params) { | |
return params; | |
} | |
export default Ember.Helper.helper(array); |
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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.component-grid { | |
display: table; | |
border-collapse: collapse; | |
} | |
.grid-row { | |
display: table-row; | |
} | |
.grid-cell { | |
display: table-cell | |
} | |
.foo-a { | |
display: block; | |
background-color: #666; | |
color: #fff; | |
width: 50px; | |
height: 50px; | |
} | |
.foo-b { | |
display: block; | |
background-color: #333; | |
color: #fff; | |
width: 50px; | |
height: 50px; | |
} |
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.6.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.3.1/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment