Skip to content

Instantly share code, notes, and snippets.

View simonihmig's full-sized avatar

Simon Ihmig simonihmig

View GitHub Profile
@simonihmig
simonihmig / forms.md
Last active January 4, 2023 11:05
Headless Forms

WIP - Ember Headless Forms

Goals

  • focus on reusable behavior that every form should have
  • have no opinions on styling or app-specific use cases
  • have opinions on form best-practices and a11y
  • render as little as possible
    • render things for which we have strong opinions (e.g. an input should have an associated <label>)
import EmbeddedService from 'ember-embedded-snippet/services/embedded';
import BaseAdapter from 'ember-metrics/metrics-adapters/base';
import fetch from 'fetch';
import { inject as service } from '@ember/service';
export interface Config {
identificationCode: string;
apiUrlForHit?: string;
apiUrlForEvent?: string;
trackUrlBase?: string;
@simonihmig
simonihmig / inlelement-test.js
Last active October 1, 2021 08:46
Test moving content around with in-element without recreating it
test('switching the target moves existing content without new invocation - modifier', async function (assert) {
this.set('show', false);
let count = 0;
this.trackRender = () => count++;
await render(hbs`
<div id="p1"></div>
<div id="p2"></div>
{{#if this.show}}
{{#in-element this.dest insertBefore=null}}
<div id="content" {{did-insert this.trackRender}}>foo</div>
@simonihmig
simonihmig / machine.js
Last active August 22, 2021 12:54
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@simonihmig
simonihmig / controllers.application\.js
Created September 17, 2020 19:30
ember-undefined-demo
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
const Foo = Ember.Object.extend({
foo: 'bar'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
});
import Ember from 'ember';
Ember.onerror = function() {
console.error('This should never happen!');
};
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
@simonihmig
simonihmig / docker-compose.yml
Created December 28, 2017 00:07
Ember-CLI Docker setup
version: "3"
services:
# for development only
ember-cli:
build: docker/ember-cli
shm_size: 1G
command: /bin/bash -c "FASTBOOT_DISABLED=true ember server"
ports:
- 4200:4200
- 49152:49152
import Ember from 'ember';
export default class TestComponent extends Ember.Component {
};
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
logs: [],
cp: Ember.computed('foo.bar', function() {
this.get('logs').pushObject('CP has been called');
return this.get('foo.bar');