Estrela - a JavaScript library for building reactive web components inspired by lit

Overview

Estrela

Full Reactive Web Components

Estrela is a JavaScript library for building reactive web components inspired by lit.

Just like Lit, Estrela is a boilerplate-killing component that provides reactive state, scoped styles, and a declarative template system that's tiny, fast and expressive. However, it allows you to choose either class or function based custom elements just like React.

For reactivity, Estrela extends RxJs observables to create the state of your component, so you will be able to subscribe and extend them with RxJs pipes.

Documentation

Head over to estrelajs.gitbook.io

Installation

To install:

# npm
npm install --save estrela

# yarn
yard add estrela

Example

Estrela takes advantage of web components. To define your custom element, you need to provide a class/function with a render function. Functional Elements will be called just once, so there's no need for hooks. You can just declare your variables and use them.

count.update(value => ++value), 1000); // Subscribe to value changes and do any kind of side effect you want. // e.g. update database on value changes. count.subscribe(console.log); // Return the template builder function. // The ":count" syntax is to bind the "count" prop on "app-counter". return () => html``; }; const Counter = () => { // Define a prop state. const count = prop (); // Return the template builder function. // Note: calling the state value getter function is optional. return () => html`
Count is ${count}
`; }; defineElement('app-counter', Counter); defineElement('app-root', App); // index.html ... ">
// main.ts
import { defineElement, html, prop, state } from 'estrela';

const App = () => {
  // Count value state. Initial value = 0.
  const count = state(0);

  // To get the current state value, just call it like a normal function.
  console.log(count());

  // Change its state by calling "next" or "update" methods.
  // The "update" receives a callback function with the current value
  // as parameter and expects the next value to be returned.
  setInterval(() => count.update(value => ++value), 1000);

  // Subscribe to value changes and do any kind of side effect you want.
  // e.g. update database on value changes.
  count.subscribe(console.log);

  // Return the template builder function.
  // The ":count" syntax is to bind the "count" prop on "app-counter".
  return () => html`<app-counter :count=${count}>app-counter>`;
};

const Counter = () => {
  // Define a prop state.
  const count = prop<number>();

  // Return the template builder function.
  // Note: calling the state value getter function is optional.
  return () => html`<div>Count is ${count}div>`;
};

defineElement('app-counter', Counter);
defineElement('app-root', App);

// index.html
...
<body>
  <app-root></app-root>
</body>

Check more examples on docs.

Contributing

Estrela is open source and we appreciate issue reports and pull requests.

Instructions coming soon...

You might also like...

Web app for adding EU Digital COVID Certificates to your wallet apps

Web app for adding EU Digital COVID Certificates to your wallet apps

Web app for adding EU Digital COVID Certificates to your wallet apps

Dec 31, 2022

A Sequelize web builder interface. To make your own sequelize schema

A Sequelize web builder interface. To make your own sequelize schema

Mar 9, 2022

Insider Unlocked is an ongoing web application

Insider Unlocked is an ongoing web application we have been co-developing for the past few months which aggregates stock trading data of US senators and presents it in a digestible manner for the average retail investor

Feb 13, 2022

A simple server application that allows you to perform Wake-on-LAN remotely with a web interface

WoL Helper A simple server application that allows you to perform Wake-on-LAN remotely with a web interface. Usage Install: npm install -g wol-helper

Jul 27, 2022

A Pauli Test simulation app made with Web Component and RxJS

A Pauli Test simulation app made with Web Component and RxJS

There was a discussion quite a while ago in Teknologi Umum about brain throughput or something. Basically it was about how long does your brain can maintain its performance. It was brought up because there was a discussion about typing speed and how someone can get high Words per Minute at the start but starts to slow down the longer they go.

Jun 8, 2022

A PHP Laravel web application that uses most of Laravel technologies to build that gym system

A PHP Laravel web application that uses most of Laravel technologies to build that gym system

A PHP Laravel web application that uses most of Laravel technologies to build that gym system.The System is based on rules. Admin, City Manager, Gym Manager. All Crud operations running using data tables.

Dec 29, 2022

This web application retrieves real live data from the SpaceX API

This web application retrieves real live data from the SpaceX API

This web application retrieves real live data from the SpaceX API. It provides commercial and scientific space travel services, by allowing users to book rockets and join selected space missions.

Aug 9, 2022

A platform detection library.

Platform.js v1.3.6 A platform detection library that works on nearly all JavaScript platforms. Disclaimer Platform.js is for informational purposes on

Dec 31, 2022

The perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on existing HTML.

List.js Perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on

Jan 1, 2023
Comments
  • List Render Bug: when using observables and selectors, there are edge cases where the list stops rendering to the DOM as expected.

    List Render Bug: when using observables and selectors, there are edge cases where the list stops rendering to the DOM as expected.

    Hi, I just found out about this marvelous framework, and I am really loving the look of it and can't wait for its future.

    I have spent a little bit of time playing around with observables and selectors to see what they are capable of, and have been extremely happy with them thus far. However, I have run into a small bug with the rendering of lists. It really only happens (as far as I can see) in one or two particular edge cases.

    Reproduction repo: https://github.com/JaymanMDev/estrela-issue-reproduction

    Reproduction steps:

    1. clone repository and start up development server as usual with vite.
    2. When you see the rendered DOM, a list of numbers will begin to show up on a 1 second interval.
    3. Right clicking one of the list items will remove it from the DOM.
    4. IMPORTANT: Ensure that you click on the first or second list items (before it ever exceeds that amount) in order to reproduce the edge case. No more items should show up if the reproduction worked.
    bug 
    opened by ghost 7
Owner
null
Building dynamic form in Angular with Fluent API

ngx-fluent-form Building dynamic form in Angular with Fluent API. Features Support using Fluent API and JSON. Type-safe form configuration.

HyperLifelll9 22 Dec 23, 2022
A-Frame components implementing multiple cameras

aframe-multi-camera multi-camera.mp4 Overview This repository contains components that can be used to create multi-camera scenes in A-Frame. Cameras c

Diarmid Mackenzie 14 Oct 10, 2022
Add weak event listeners from your components/classes based on WeakRefs

Add weak event listeners from your components/classes based on WeakRefs. This package handles the boilerplate for you, which isn't too much anyways but not particularly good looking.

Ashish Shubham 3 Feb 25, 2022
Custom HTML elements for generic components (dropdown, modal...) without style.

Headless elements The goal of this project is to create a library of Custom Elements to stop reinventing the wheel (starting by reinventing the wheel

Jonathan 21 Sep 17, 2022
A user script for the web that allows you to view and edit files in the Godot Web Editor

Godot-Web-File-Manager This is a user script for the web that allows you to view and edit files in the Godot Web Editor. You can even use this to enab

Roujel Williams 4 Jan 31, 2022
JavaScript Survey and Form Library

SurveyJS is a JavaScript Survey and Form Library. SurveyJS is a modern way to add surveys and forms to your website. It has versions for Angular, jQue

SurveyJS 3.5k Jan 1, 2023
Extensive math expression evaluator library for JavaScript and Node.js

?? Homepage Fcaljs is an extensive math expression evaluator library for JavaScript and Node.js. Using fcal, you can perform basic arithmetic, percent

Santhosh Kumar 93 Dec 19, 2022
This library was designed to be used in SPA framework wrappers for the FingerprintJS Pro Javascript Agent

Framework-agnostic SPA service wrapper. Use it to build a FingerprintJS Pro wrapper for your favorite framework.

FingerprintJS 12 Sep 3, 2022
ChelseaJS - a Javascript library for creative, generative Coding

ChelseaJS is a Javascript library for creative, generative Coding. It's simple and intuitive syntax makes it easy for everyone (including non-coders)

Prakrisht Dahiya 26 Oct 6, 2022
Bookmarklet to remove sticky elements and restore scrolling to web pages!

Bookmarklet to remove sticky elements and restore scrolling to web pages!

Tim Martin 648 Dec 29, 2022