Package Exports
- atomico
- atomico/html
Readme
Español - English
Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
import { h, c } from "atomico";
const MyComponent = () => <host>mi primer webcomponent con atomico</host>;
const HTMLMyComponent = c(MyComponent);
customElements.define("my-web-component", HTMLMyComponent);Links:
- What is Atomico?
- Api
- Guides
- Resources
What is Atomico?
Atómico is a modern syntax micro-library created by Matias Trujillo alias @UpperCod, which simplifies the creation of webcomponents by replacing the need to use classes and contexts by functions and scope to support logic, attributes, properties, methods and events, example:
const MyComponent = () => {
const [count, setCount] = useProp("count");
const increment = () => setCount(count + 1);
return <host increment={increment}>count: {count}</host>;
};
MyComponent.props = {
count: { type: Number, value: 0 },
};Where:
MyWebComponent: Function that represents the webcomponent.const [count, setCount] = useProp("count"): Hook function similar to useState, but with the difference that useProp reflects the property status of the component.const increment = () => setCount(count + 1);: Function that increases the state.<host increment={increment}>: Virtual-dom represented the incremental method.MyComponent.props.count: Object, defines the behavior of thecountproperty.type: Number: Declare count as typenumber.value: 0: Declares that the initial state ofcountis0.