Skip to content

Instantly share code, notes, and snippets.

View jkarsrud's full-sized avatar

Jesper Haug Karsrud jkarsrud

View GitHub Profile
@jkarsrud
jkarsrud / machine.js
Created October 23, 2020 15:04
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jkarsrud
jkarsrud / machine.js
Last active May 22, 2020 11:01
Generated by XState Viz: https://xstate.js.org/viz
const now = new Date();
const vehicles = [
{ availableFrom: now },
{ availableFrom: now.setMinutes(now.getMinutes() + 5) },
{ availableFrom: null }
];
const VehicleTypeMachine = Machine({
id: 'VehicleType',
initial: 'unknown',
@jkarsrud
jkarsrud / controllers.application.js
Last active March 10, 2021 15:10
Leaflet multiple markers on map
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
lat: 59.9200,
long: 10.7450,
zoom: 13,
markers: [
{ name: 'Grünerløkka', coords: [59.9239, 10.7578] },
{ name: 'Majorstua', coords: [59.9268, 10.7162] }
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
test(event) {
console.log("event", event);
}
}
});
@jkarsrud
jkarsrud / components.animation-component.js
Last active October 30, 2018 10:56
Guides source PR 200 component example
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['animated','sliding-elem'],
didInsertElement() {
this._super(...arguments);
this.animationHandler = () => {
this.element.classList.remove('sliding-elem');
@jkarsrud
jkarsrud / components.window-events.js
Last active October 4, 2018 08:00
Window Events Component Example
import Ember from 'ember';
export default Ember.Component.extend({
tagName: '',
resizeCount: 0,
didInsertElement() {
window.addEventListener('resize', () => {
this.set('resizeCount', this.resizeCount + 1);
console.log('resizing');
});
@jkarsrud
jkarsrud / components.my-component.js
Created September 28, 2018 10:14
Class on component
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['foo'],
didInsertElement() {
this.set('allOfTheClasses', this.element.classList);
},
});
@jkarsrud
jkarsrud / controllers.application.js
Created September 25, 2018 13:47
Indeterminate checkboxes
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
indeterminate: false,
actions: {
toggleIndeterminate() {
this.toggleProperty('indeterminate');
}
}
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@jkarsrud
jkarsrud / components.analyze-dispatch.js
Last active September 6, 2018 19:32
Trigger function not in actions hash
import Ember from 'ember';
export default Ember.Component.extend({
});