- Prefer composition over mixins
- Prefer immutablity
- Avoid using events as they create side-effects
- Lifecycle methods should always be a single function. e.g.
button.beforeMount(cxt)
- Declarative API with everything declared the same way in the same place
- Avoid the need for deku-specific plugins, it should make composition easy
- Avoid magic and complex APIs. Functions should just be functions with no side-effects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
type: 'element', | |
tagName: 'div', | |
attributes: { class: 'foo' }, | |
children: [{ | |
type: 'element', | |
tagName: 'span', | |
attributes: {}, | |
children: [] | |
}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from "tron"; | |
class MyThing extends Component { | |
initialState(){ | |
return { open: false } | |
} | |
mounted(parent, el) { | |
console.log("omg I'm in the dom") | |
} | |
onClick(event) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.u-enableKerning { | |
text-rendering: optimizeLegibility; | |
font-feature-settings: "kern" 1; | |
font-kerning: normal; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function update (data) { | |
var request = new XMLHttpRequest(); | |
request.open('POST', '/whatevers', true); | |
request.send(data); | |
} | |
var View = ripple(template) | |
.use(events); | |
// Might need different change events for each field |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function(){ | |
/** | |
* Require the module at `name`. | |
* | |
* @param {String} name | |
* @return {Object} exports | |
* @api public | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var main = document.querySelector('#main-nav'); | |
parent.addEventListener('click', function(e){ | |
if(e.target.matches('.toggleNav')) { | |
e.preventDefault(); | |
main.classList.toggle('in'); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Form = require('form'); | |
function PersonalDetails(el, model) { | |
this.el = el; | |
this.model = model; | |
this.form = new Form(el); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Stream of dots from the integrations browser | |
*/ | |
var dots = new IntegrationStream({ | |
el: document.querySelector('.js-integration-stream') | |
}); | |
/** | |
* Create a stream | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.initConfig({ | |
foo: {} | |
}); | |
require('./plugin')(grunt); | |
// It would be even easier if grunt had a 'use' method | |
// grunt.use(plugin).use(another); |