2.0.0 • Published 2 years ago

xuijs v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Xuijs

A javascript runtime library for creating reactive user interfaces.

features

Xuijs is a set of tools that makes it so easy to add reactivity to your UIs.

  • no vdom
  • very lightweight.
  • very fast.
  • unopinionated.
  • extendable to infinity.

usage

  1. download the package using npm.
$ npm i xuijs
  1. define the App.
import { Xui } from 'xuijs';

const App = new Xui();

App.init(document.body);
  1. define an element.
// index.js

import { XuiElement, Variable } from 'xuijs';

export class Ticker extends XuiElement {
  constructor(el) {
    super(el);

    this.ticks = new Variable(0);
    this.state = new Variable(false);
  }

  getTicks(ticks) {
    return `${ticks}`;
  }

  resetTicks() {
    this.ticks.value = 0;
  }

  getState(state) {
    return state ? 'stop' : 'start';
  }

  switchState() {
    if (this.state.value) {
      window.clearInterval(this.ticker);
    } else {
      this.ticker = window.setInterval(() => this.ticks.value++, 1000);
    }

    this.state.value = !this.state.value;
  }
}
  1. use the element.
<body>
  <div $init mount=":Ticker">
    <span $bind:.inner-text="ticks@getTicks">0</span>
    <div $init>
      <button $event:click="@switchState" $bind:.inner-text="state@getState">
        start
      </button>
      <button $event:click="@resetTicks">reset</button>
    </div>
  </div>
</body>
  1. bundle with your favourite bundeler.

docs

see docs/ folder for more details.

examples

see examples/ folder for example projects.

1.0.1

2 years ago

2.0.0

2 years ago

0.1.0

3 years ago

0.2.0

3 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

3 years ago