Skip to content

Instantly share code, notes, and snippets.

View trueadm's full-sized avatar

Dominic Gannaway trueadm

View GitHub Profile
@trueadm
trueadm / gist:c3d6977b34ced80ae9b4
Last active August 29, 2015 14:14
DOM DSL Example #1
template() {
return [
div => [
header => [
h1 => ["Example " + this.title]
]
],
div => ["#main",
$if => [this.todos.length > 0,
div => [
@trueadm
trueadm / gist:898c8f7d7cf89d62f54a
Created February 5, 2015 15:12
DOM DSL Example #2
template() {
return [
["div",
["header"
["h1", "Example " + this.title]
]
],
['div#main',
$.if(this.todos.length > 0, [
['div',
@trueadm
trueadm / gist:1b0b90aad778b7a4333f
Created February 7, 2015 17:25
Potential Template Syntax
return Template`
<div id="grid">
${ $.for(each => items, as => item) }>
<div class="box-view">
<div class="box" id="${ text => 'box-' + item }">0</div>
</div>
${ $.endFor() }>
</div>
`;
@trueadm
trueadm / index.js
Last active August 29, 2015 14:17 — forked from axemclion/index.js
var urls = {
react: 'http://run.plnkr.co/plunks/Wwgjjpl9NHMO5Nd1TUyN/',
ember: 'https://dbmonster.firebaseapp.com/',
underscore: 'http://jashkenas.github.io/dbmonster/',
ractive: 'http://www.rich-harris.co.uk/ractive-dbmonster/',
paperclip: 'http://paperclip-dbmonster.herokuapp.com/',
t7_cito: 'http://t7js.com/dbmonster/',
t7_cito_precompiled: 'http://t7js.com/dbmonster/precompiled.html'
}
// calling create tree would do this
// only the attrs/children then are dynamic will by in the given nodes
// the nodes all should be monomorphic thus have the same properties (null if not used)
// we will clone these nodes
const precompiledNode1 = document.createElement('div');
const precompiledNode2 = document.createElement('div');
precompiledNode2.textContent = 'Node!';
precompiledNode2.className = 'foo';
var t1 = Inferno.createTemplate(function(key, children) {
return {
dom: null,
static: null,
tag: null,
key: key,
attrs: null,
children: children,
nextItem: null
}
@trueadm
trueadm / gist:680dad38e910c47c4b7126d17771ad2a
Created June 16, 2016 11:53
Chrome 53 Canary + Hardware performance flag
Enter this into your terminal (Mac users), ensure you have Chrome Canary in your Applications directory:
Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --enable-main-frame-before-activation
import { render, createView, html } from 'fusion';
const view = createView(({ name, age, location }) => html`
<div>
<header>About me</header>
<section class="about">
<div>My name: <span>${ name }</span></div>
<div>My age: <span>${ age }</span></div>
<div>My location: <span>${ location }</span></div>
</section>
function MyComponent() {
return (
<div>
<my-chart
onAttached={ chart => chart.start() }
onDetatched={ chart => chart.end() }
/>
</div>
)
}
import { render, UIComponent, ModelComponent } from 'fusion';
const state = {
people: [],
title: 'Hello world'
};
// you could alternatively do this?
const SideBarModel = ModelComponent({
name: 'sidebar',
deleteItem(state, id) {