An open API service indexing awesome lists of open source software.

https://github.com/qwreey/compactive-js

Web-COMponent based COMPACT reACTIVE library
https://github.com/qwreey/compactive-js

Last synced: 4 months ago
JSON representation

Web-COMponent based COMPACT reACTIVE library

Awesome Lists containing this project

README

          

# Web-**COMP**onent based **COMPACT** re**ACTIVE** library

## WHY??

Many reactive libraries require downloading at least 16kB. compactive uses the Web-Component to minimize the size, and hit 1.7kB (!!!)

## Example

```html

class MY_Switch extends BaseElement {
static { Init(this,_=>_
.tag("my-switch")
.content(html`
<button -ref="btn"><slot></slot></button>
`)
.style(css`
button.activate {
background-color: red;
}
`)
.attr("activate")
)}
constructor() {
super()
this.btn.onclick = () => { this.activate = !this.activate }
}
activateAttr(val) {
if (val) this.btn.classList.add("activate")
else this.btn.classList.remove("activate")
}
}

Hello world

```