Check the full documentation for Wompo at wompo.dev.
Creating a custom Counter component is very easy with Wompo, and works exactly like React!
import { defineWompo, html } from 'wompo';
export default function CounterComponent({ styles: s }) {
const [count, setCount] = useState(0);
const inc = () => setCount(count + 1);
return html`<button class=${s.button} @click=${inc}>
Current value: ${count}
</button>`;
}
CounterComponent.css = `
.button {
border-radius: 10px;
background-color: #573ef6;
color: #fff;
padding: 10px 20px;
border: none;
}
`
defineWompo(CounterComponent);
Then, you can simply render it in you HTML:
<counter-component></counter-component>
<!-- Will render: <button>Current value: 0!</button> -->
Wompo supports JSX. If you use it with Typescript, write this in your tsconfig.json
file:
"jsx": "react-jsx",
"jsxImportSource": "wompo",