Skip to content

Instantly share code, notes, and snippets.

View lifeart's full-sized avatar
🐹
Working from home

Alex Kanunnikov lifeart

🐹
Working from home
View GitHub Profile
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Input with handler example';
@tracked text;
handleInput(event) {
event.preventDefault();
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Input with handler example';
@tracked text;
handleInput(event) {
event.preventDefault();
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@service('store') store;
constructor() {
super(...arguments);
this.setup();
@lifeart
lifeart / controllers.application\.js
Last active August 6, 2020 14:52 — forked from sukima/controllers.application\.js
tracking polyfill autotrack
import Controller from '@ember/controller';
import EmberObject, { action, computed as emberComputed } from '@ember/object';
let currentAutoTrack;
function trackedData(key, initializer) {
let values = new WeakMap();
let autoTrackingData = new WeakMap();
let hasInitializer = typeof initializer === 'function';
@lifeart
lifeart / 1-summary.md
Created July 2, 2020 19:41 — forked from lukemelia/1-summary.md
Simple component theming with broccoli.js

My team and I have been working on a new internal component library to share across a few Ember apps. The library is an Ember addon in a private github repo. So far, so good. The off-the-beaten-path part of our requirements is that the components need to be themeable. Specifically, we support a color and a "light" or "dark" aesthetic.

We want a great developer experience for creating and updating these components, so we used ember-freestyle as a devDependency of the library to create a living style guide. We added some UI to allow theme switching and even a checkbox to switch themes every second (thanks ember-concurrency!).

The thing that gave us the biggest challenge was figuring out how to author and apply the styles that were necessarily dynamic. Specifically, the css rules that used the dynamic color.

We decided to organize our styles like so:

app/styles/components/
import Ember from 'ember';
const A = Ember.A;
const O = Ember.Object.create.bind(Ember.Object);
const getCpO = function(data) {
return Ember.Object.extend({
childKey: Ember.computed('children.[]', function(){
return (this.get('children')||A()).map(e=>e.toString()).join('-');
})
@lifeart
lifeart / 0 README.md
Created February 18, 2018 11:24 — forked from caseywatts/0 README.md
d3 & c3 npm shim to es6 module for Ember

app.import() works with node_modules now! As of Ember 2.15. Previously it only worked with bower_components and vendor.

Docs for app.import are here: https://ember-cli.com/managing-dependencies#standard-non-amd-asset

This method (vendor-shim) wraps the global export into an es6 module (but the global one is still present). It doesn't use an es6 interface even if the library offers one, but that's okay for my use case.

Things could still be easier, see this thread for the current state of that.