Skip to content

Instantly share code, notes, and snippets.

View zeppelin's full-sized avatar
🐹

Gabor Babicz zeppelin

🐹
View GitHub Profile
@zeppelin
zeppelin / conventional-test-selectors.ts
Created April 17, 2019 19:48
Conventional test selectors
test('createTestSelector', function(assert) {
// Base namespace could be, for example, the component's name
let base = createTestSelector('namespace');
// Element that appears only once on the screen at a time
assert.equal(base('single'), '[data-test-namespace="single"]');
// List of elements, targeting all items
assert.equal(base('multiple', null), '[data-test-namespace^="multiple:"]');
import EmberObject from '@ember/object';
class SubclassWithEmberInit extends EmberObject {
someProp = 'value';
init() {
super.init(...arguments);
console.log(this.someProp); // undefined
// `this.someProp` will be available after initialization,
// just not from the `init` method...
@zeppelin
zeppelin / controllers.application.js
Created March 20, 2018 10:35
cp-validations-default-value
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
m: ['a', 'b', 'c', 'd', 'e', 'f']
});
@zeppelin
zeppelin / controllers.application.js
Created August 22, 2017 12:59
Pickle Rick preventDefault demo
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
handleClick(name, e) {
alert(name);
e.preventDefault();
}
}
});
.defaultButton {
@extend .btn;
@extend .btn-default;
}
new MutationObserver(function() {
var slotA = {
count: 0,
color: null,
element: null
};
var slotB = {
count: 0,
color: null,
@zeppelin
zeppelin / 1-readme.md
Last active August 29, 2015 14:17
Ember ES2015 Modules

Ember ES2015 Modules

The purpose of this document is to demonstrate how methods and classes could be imported inside an Ember CLI project, instead of accessing them on the Ember namespace.

For example, instead of doing this:

import Ember from 'ember';

export default Ember.Component.extend({
@zeppelin
zeppelin / index-route.js
Created December 16, 2014 10:29
Replace root URL with the localized root
import Ember from 'ember';
var Route = Ember.Route;
export default Route.extend({
redirect() {
this.replaceWith('root'); // Replace URL: / -> /en-US
}
});
@zeppelin
zeppelin / router.js
Created October 4, 2014 17:44
Including locale in the URL in Ember.js
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.resource('select-country');
this.resource('root', { path: config.locale }, function() {