JSFiddle - React, Tailwind, and code Playground

by rich_harris

HTML

<script src="http://cdn.ractivejs.org/edge/ractive.js"></script>
<main></main>

<script id='template' type='text/ractive'>
    <container on-log='log'>
        <ticker interval='1000' on-tick='log'/>
    </container>
</script>

CSS

body {
    font-family: 'Helvetica Neue', arial, sans-serif;
    font-weight: 200;
    color: #353535;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 200;
}

JavaScript

Ractive.components.container = Ractive.extend({
    template: '{{>content}}'
});

Ractive.components.ticker = Ractive.extend({
    init: function () {
        var interval = setInterval( function () {
            this.fire( 'tick' );
        }.bind( this ), this.get( 'interval' ) );
        
        this.on( 'teardown', function () {
            clearInterval( interval );
        });
    }
});

var ractive = new Ractive({
    el: 'main',
    template: '#template',
    data: {}
});
        
ractive.on( 'log', function () {
    console.log( 'ticked' );
});