Package Exports
- atomico
- atomico/css
- atomico/html
- atomico/jsx-runtime
- atomico/test-hooks
Readme
Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
import { c } from "atomico";
function myComponent({ message }) {
return <host>Hello, {message}</host>;
}
myComponent.props = { message: String };
customElements.define("my-component", c(myComponent));Links:
What is Atomico?
Atomico 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:
import { c, useProp } from "atomico";
function 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 },
};
customElements.define("my-component", c(myComponent));Where:
myComponent: 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.