JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API.
This version of Crab was written in TypeScript to include Types for your development
import { Component, defineComponents, render } from '@kocisov/crab'
export default class Header extends Component {
// or Polymer like => static get is()
static get componentName() {
return 'header-component'
}
state = {
id: 'Some string...',
}
changeState() {
this.setState({
id: uuid.v4(),
})
}
render() {
return `
<div class="flex-right">
Hello ${this.state.id}
</li>
`
}
}
defineComponents([Header, SmallButon], { crabug: true })
render(
`
<header-component onClick="changeState"></header-component>
`,
`
body {
margin: 0;
}
`,
document.getElementById('root'),
)
This version of Crab is compiling from ES2015+ to ES5 ready even without native-shim.
# yarn
yarn add @kocisov/crab
# npm
npm install --save @kocisov/crab
// webpack with babel
import { Component, defineComponents, render } from '@kocisov/crab'
// ...
render(
`
<view-layout></view-layout>
`,
document.getElementById('root'),
)
Work in progress at docs.