Skip to content

Instantly share code, notes, and snippets.

@k-fish
Last active February 16, 2019 17:49
Show Gist options
  • Save k-fish/93de4b39ca46cebb6abddd3de66d76a3 to your computer and use it in GitHub Desktop.
Save k-fish/93de4b39ca46cebb6abddd3de66d76a3 to your computer and use it in GitHub Desktop.
Example Ember Responsive
export default {
mobile: '(max-width: 480px)',
tablet: '(min-width: 481px) and (max-width: 768px)',
desktop: '(min-width: 769px) and (max-width: 1366px)'
};
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
export function initialize() {
const application = arguments[1] || arguments[0];
application.inject('controller', 'media', 'service:media');
application.inject('component', 'media', 'service:media');
application.inject('route', 'media', 'service:media');
application.inject('view', 'media', 'service:media');
}
export default {
name: 'responsive',
initialize
};
{{responsive-component}}
<div style="border: 1px solid black; border-radius: 5px; padding: 5px; text-align: center">
<h4>This is a responsive component</h4>
<div class="js-responsive-text" style="padding: 5px; border-radius: 5px; {{if media.isMobile 'background: #d9534f' 'background: #5cb85c'}}">This text is styled responsively for <strong>{{if media.isMobile 'mobile' 'desktop/tablet'}}</strong></div>
</div>
{
"version": "0.11.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3",
"skeleton-css": "https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css"
},
"addons": {
"ember-responsive": "2.0.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment