This file contains 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 {h, Component, uuid} from 'composi' | |
import {counters} from './counters' | |
import {Counter} from './counter' | |
import {counterSum} from './counterSum' | |
// Callback for adding counter | |
const addCounter = () => { | |
const counter = new Counter({ | |
root: '#counter', | |
state: {disabled: false, number: 1, id: uuid(true)}, |
This file contains 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 {h, Component} from 'composi' | |
class Clock extends Component { | |
constructor(props) { | |
super(props) | |
this.state = {time: new Date()}; | |
} | |
render() { | |
return ( |
This file contains 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 {h, Component} from 'composi' | |
class Clock extends Component { | |
constructor(props) { | |
super(props) | |
this.state = {time: Date.now()} | |
this.styles = { | |
'p > span': { | |
fontFamily: 'Courier, Monospace' | |
} |
This file contains 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 {h, Component} from 'composi' | |
class Toggle extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {isToggleOn: true}; | |
// This binding is necessary to make `this` work in the callback | |
this.handleClick = this.handleClick.bind(this); | |
} |
This file contains 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 {h, Component, injectElement} from 'composi' | |
function Welcome(props) { | |
return <h1>Hello, {props.name}.</h1> | |
} | |
const Button = (props) => <button>{dingo.label}</button> | |
function App() { | |
return ( | |
<div> |
This file contains 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 {h, Component, injectElement} from 'composi' | |
// Define hyperscript functions: | |
function Welcome(props) { | |
return h('h1', {}, `Hello, ${props.name}.`) | |
} | |
function App() { | |
return h( | |
'div', {}, [ |
This file contains 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 {h, Component} from 'composi' | |
const title = new Component({ | |
root: 'header', | |
state: 'World', | |
render: (message) => ( | |
<h1>Hello, {message}!</h1> | |
), | |
styles: { | |
padding: 20, |
This file contains 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 {h, Component} from 'composi' | |
const personData = { | |
name: { | |
first: 'Joe', | |
last: 'Bodoni' | |
}, | |
age: 26, | |
job: 'mechanic' | |
} | |
const person = new Component({ |
This file contains 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 {h, Component} from 'composi' | |
const fruits = [ | |
'Apples', 'Oranges', 'Bananas', 'Strawberries' | |
] | |
const list = new Component({ | |
root: 'section', | |
state: fruits, | |
// Use map on array of fruits: |
This file contains 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 {h, Component} from 'composi' | |
const fruits = [ | |
{ | |
name: 'Apples', | |
quanity: 6 | |
}, | |
{ | |
name: 'Oranges', |
OlderNewer