Last active
November 15, 2017 08:35
-
-
Save wojciechb/1d4e346f2c287c3caa89c4066f1caa9f to your computer and use it in GitHub Desktop.
measuring paradigm
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({ | |
classNames: ['ig-chart'], | |
}); |
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({ | |
opened: false, | |
expanded: false, | |
// private | |
widthInPx: null, | |
init(...args) { | |
this._super(...args); | |
Ember.run.next(this, this.calculate); | |
}, | |
calculate() { | |
this.set('widthInPx', this.$('.ig-flyout').width()); | |
}, | |
classes: Ember.computed( | |
'opened', | |
'expanded', | |
function() { | |
const { | |
opened, | |
expanded | |
} = this.getProperties('opened', 'expanded'); | |
let result = 'ig-flyout'; | |
if (expanded) { | |
result += ' ig-flyout--expanded'; | |
} else if (opened) { | |
result += ' ig-flyout--opened'; | |
} else { | |
result += ' ig-flyout--closed'; | |
} | |
return result; | |
} | |
), | |
actions: { | |
open() { | |
this.set('opened', true); | |
this.set('expanded', false); | |
Ember.run.next(this, this.calculate); | |
}, | |
expand() { | |
this.set('opened', false); | |
this.set('expanded', true); | |
Ember.run.next(this, this.calculate); | |
}, | |
hide() { | |
this.set('opened', false); | |
this.set('expanded', false); | |
Ember.run.next(this, this.calculate); | |
}, | |
resize() { | |
this.set('flyoutWidth', (Math.random() * 500).toFixed(2)); | |
} | |
}, | |
}); |
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({ | |
//public | |
widthInPx: null, | |
showChart: Ember.computed.gte('widthInPx', 200), | |
classNames: ['ig-market-view'], | |
}); |
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({ | |
// public, passed from workspace | |
workspaceWidthPx: null, | |
// panel width | |
panelWidthPc: null, | |
panelWidthInPx: Ember.computed( | |
'workspaceWidthPx', | |
'panelWidthPc', | |
function() { | |
const { | |
workspaceWidthPx, | |
panelWidthPc | |
} = this.getProperties( | |
'workspaceWidthPx', | |
'panelWidthPc'); | |
console.log(workspaceWidthPx, panelWidthPc); | |
return (workspaceWidthPx * | |
(panelWidthPc / 100.0)).toFixed(2); | |
} | |
), | |
inlineStyle: Ember.computed('panelWidthPc', function() { | |
return `width: ${this.get('panelWidthPc')}%`; | |
}), | |
}); |
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({ | |
containerStyle: Ember.computed('workspaceWidthPx', function() { | |
return `width: ${this.get('workspaceWidthPx')}px`; | |
}), | |
workspaceWidthPx: 500, | |
panelWidthPc: 60, | |
calculate() { | |
this.set('width', this.$().width()); | |
}, | |
actions: { | |
windowResize() { | |
// simulates window.resize on button click | |
this.set('workspaceWidthPx', (Math.random() * 500).toFixed(2)); | |
} | |
}, | |
}); |
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: 'Ember Twiddle' | |
}); |
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 { font-size: 11px; color: gray; font-family: Arial; } | |
strong { font-size: 14px; color: black; } | |
* { overflow: visible; white-space: nowrap;} | |
.ig-workspace { border: 2px solid black; } | |
.ig-panel { border: 1px solid orange; } | |
.ig-market-view { border: 1px solid yellow; } | |
.ig-chart { border: 1px solid violet; background-color: violet; } | |
.ig-chart-hidden-message { background-color: pink; } | |
.ig-flyout { border: 2px solid black; } | |
.ig-flyout--closed { width: 5% } | |
.ig-flyout--opened { width: 40% } | |
.ig-flyout--expanded { width: 90% } |
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