rasti 2.1.0-alpha.1 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,18 +1,40 @@
1
- # <a href="http://rasti.js.org"><img src="docs/logo.svg" height="80" alt="Rasti.js - JavaScript library for building user interfaces" aria-label="rasti.js.org" /></a>
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="docs/logo-dark.svg">
4
+ <img alt="Rasti.js" src="docs/logo.svg" height="120">
5
+ </picture>
6
+ </p>
2
7
 
3
- Rasti is a minimalistic JavaScript library for building user interfaces.
4
- It is designed to simplify the creation of complex dynamic applications by providing a declarative API for building reusable and composable UI components.
5
- Rasti is based on web standards, has a small footprint, and can be used directly in the browser without requiring any boilerplate or configuration.
8
+ <p align="center">
9
+ <b>Modern MVC for building user interfaces</b>
10
+ </p>
6
11
 
7
- The project is [hosted on GitHub](https://github.com/8tentaculos/rasti), and it's available for use under the [MIT](LICENSE.md) software license.
8
- You can report bugs and discuss features on the [GitHub issues page](https://github.com/8tentaculos/rasti/issues).
12
+ **Rasti** is a lightweight MVC library for building fast, reactive user interfaces. Inspired by **Backbone.js**, it retains a familiar API while removing non-essential features and introducing modern, declarative, and composable components to simplify complex UI development.
9
13
 
10
14
  [![Travis (.com)](https://img.shields.io/travis/com/8tentaculos/rasti?style=flat-square)](https://app.travis-ci.com/8tentaculos/rasti)
11
15
  [![npm version](https://img.shields.io/npm/v/rasti.svg?style=flat-square)](https://www.npmjs.com/package/rasti)
16
+ [![npm package minimized gzipped size](https://img.shields.io/bundlejs/size/rasti?style=flat-square)](https://unpkg.com/rasti/dist/rasti.min.js)
12
17
  [![npm downloads](https://img.shields.io/npm/dm/rasti.svg?style=flat-square)](https://www.npmjs.com/package/rasti)
13
- [![](https://data.jsdelivr.com/v1/package/npm/rasti/badge)](https://www.jsdelivr.com/package/npm/rasti)
14
-
15
- ## Getting started
18
+ [![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hm/rasti?style=flat-square)](https://www.jsdelivr.com/package/npm/rasti)
19
+
20
+ ## Key Features
21
+
22
+ - **Declarative Components** 🌟
23
+ Build dynamic UI components using intuitive template literals.
24
+ - **Event Delegation** 🎯
25
+ Simplify event handling with built-in delegation.
26
+ - **Model-View Binding** 🔗
27
+ Keep your UI and data in sync with ease.
28
+ - **Server-Side Rendering** 🌐
29
+ Render as plain text for server-side use or static builds.
30
+ - **Lightweight and Fast** ⚡
31
+ Minimal overhead with efficient rendering.
32
+ - **Legacy Compatibility** 🕰️
33
+ Seamlessly integrates into existing **Backbone.js** projects.
34
+ - **Standards-Based** 📐
35
+ Built on modern web standards, no tooling required.
36
+
37
+ ## Getting Started
16
38
 
17
39
  ### Using npm
18
40
 
@@ -40,24 +62,23 @@ import { Model, Component } from 'https://esm.run/rasti';
40
62
  const { Model, Component } = Rasti;
41
63
  ```
42
64
 
43
- The [rasti npm package](https://www.npmjs.com/package/rasti) includes precompiled production and development UMD builds in the dist folder. They can be used directly without a bundler and are thus compatible with many popular JavaScript module loaders and environments.
44
- The UMD builds make Rasti available as a `window.Rasti` global variable.
45
-
46
-
47
- ### A simple `Component`
65
+ ### Create a `Component`
48
66
 
49
67
  ```javascript
50
- // Create Timer component.
68
+ // Define a Timer component that displays the number of seconds from the model.
51
69
  const Timer = Component.create`
52
70
  <div>
53
71
  Seconds: <span>${({ model }) => model.seconds}</span>
54
72
  </div>
55
73
  `;
56
- // Create model to store seconds.
74
+
75
+ // Create a model to store the seconds.
57
76
  const model = new Model({ seconds: 0 });
58
- // Mount timer on body.
77
+
78
+ // Mount the Timer component to the body and pass the model as an option.
59
79
  Timer.mount({ model }, document.body);
60
- // Increment `model.seconds` every second.
80
+
81
+ // Increment the `seconds` property of the model every second.
61
82
  setInterval(() => model.seconds++, 1000);
62
83
  ```
63
84
 
@@ -66,49 +87,88 @@ setInterval(() => model.seconds++, 1000);
66
87
  ### Adding sub components
67
88
 
68
89
  ```javascript
69
- // Create Button component.
70
- const Button = Component.create`
71
- <button
72
- onClick="${{ '&' : function() { this.options.onClick() } }}"
73
- >
90
+ // Define the routes for the navigation menu.
91
+ const routes = [
92
+ { label: 'Home', href: '#' },
93
+ { label: 'Faq', href: '#faq' },
94
+ { label: 'Contact', href: '#contact' },
95
+ ];
96
+
97
+ // Create a Link component for navigation items.
98
+ const Link = Component.create`
99
+ <a href="${({ options }) => options.href}">
74
100
  ${({ options }) => options.label}
75
- </button>
101
+ </a>
76
102
  `;
77
- // Create Counter component.
78
- const Counter = Component.create`
79
- <div>
80
- ${({ model }) => Button.mount({ label : '-', onClick : () => model.count-- })}
81
- <span>${({ model }) => model.count}</span>
82
- ${({ model }) => Button.mount({ label : '+', onClick : () => model.count++ })}
83
- </div>
103
+
104
+ // Create a Navigation component that renders Link components for each route.
105
+ const Navigation = Component.create`
106
+ <nav>
107
+ ${({ options }) => options.routes.map(
108
+ ({ label, href }) => Link.mount({ label, href })
109
+ )}
110
+ </nav>
111
+ `;
112
+
113
+ // Create a Page component that includes the Navigation and displays the current route's label as the title.
114
+ const Page = Component.create`
115
+ <main>
116
+ <${Navigation} routes=${({ options }) => options.routes} />
117
+ <section>
118
+ <h1>
119
+ ${({ state, options }) => options.routes.find(
120
+ ({ href }) => href === (state.location || '#')
121
+ ).label}
122
+ </h1>
123
+ </section>
124
+ </main>
84
125
  `;
85
- // Create model to store count.
86
- const model = new Model({ count: 0 });
87
- // Mount counter on body.
88
- Counter.mount({ model }, document.body);
126
+
127
+ // Initialize a model to store the current location.
128
+ const model = new Model({ location: document.location.hash });
129
+
130
+ // Update the model's location state when the browser's history changes.
131
+ window.addEventListener('popstate', () => model.location = document.location.hash);
132
+
133
+ // Mount the Page component to the body, passing the routes and model as options.
134
+ Page.mount({ routes, model }, document.body);
89
135
  ```
90
136
 
91
- [Try it on CodePen](https://codepen.io/8tentaculos/pen/ZEZarEQ?editors=0010)
137
+ [Try it on CodePen](https://codepen.io/8tentaculos/pen/dyBMNbq?editors=0010)
138
+
139
+ ## Why Choose **Rasti**?
140
+
141
+ ### Why Choose Rasti?
142
+
143
+ - **Lightweight Applications**: Designed for streamlined apps, free from unnecessary overhead or tooling.
144
+ - **High-Performance Rendering**: Optimized for scenarios where speed matters, delivering fast updates and efficient rendering—ideal for large dynamic tables or datasets without needing virtual scrolling.
145
+ - **Seamless Legacy Integration**: Modernize your **Backbone.js** views progressively, enabling incremental improvements without a full rewrite.
146
+
92
147
 
93
148
  ## Example
94
149
 
95
- The rasti [GitHub repository](https://github.com/8tentaculos/rasti) includes, in the [example folder](https://github.com/8tentaculos/rasti/tree/master/example/todo), an example [TODO application](http://rasti.js.org/example/todo/index.html) that can be used as starter project.
150
+ The rasti [GitHub repository](https://github.com/8tentaculos/rasti) includes, in the [example folder](https://github.com/8tentaculos/rasti/tree/master/example/todo), an example [TODO application](https://rasti.js.org/example/todo/index.html) that can be used as starter project.
151
+
152
+ ## API Documentation
96
153
 
97
- ## API
154
+ For detailed information on how to use **Rasti**, refer to the [API documentation](/docs/api.md).
98
155
 
99
- Complete [API documentation](docs/api.md).
100
156
 
101
- ## Powered by Rasti
157
+ ## Powered by **Rasti**
102
158
 
103
- ### Crypto Babylon
159
+ ### [Crypto Babylon](https://cryptobabylon.net)
104
160
 
105
- [Crypto Babylon](https://cryptobabylon.net), a markets analytics platform, leverages the capabilities of Rasti.
106
- The Rasti rendering system is responsible for efficiently rendering a table containing over 300 rows. Additionally, it seamlessly updates the DOM in real-time, handling thousands of messages per second from multiple WebSocket connections.
161
+ A market analytics platform efficiently rendering over 300 dynamic rows, updated in real-time with thousands of messages per second via multiple WebSocket connections.
107
162
 
108
- ### jsPacman
163
+ ### [jsPacman](https://pacman.js.org)
109
164
 
110
- [jsPacman](https://pacman.js.org), a JavaScript DOM-based remake of the classic Ms. Pac-Man game, utilizes Rasti at a low level for its custom game engine.
165
+ A DOM-based remake of the classic Ms. Pac-Man game. **Rasti** powers its custom game engine.
111
166
 
112
167
  ## License
113
168
 
114
- [MIT](LICENSE.md)
169
+ **Rasti** is open-source and available under the [MIT License](LICENSE).
170
+
171
+ ## Contributing
172
+
173
+ Contributions are welcome! Share feature ideas or report bugs on our [GitHub Issues page](https://github.com/8tentaculos/rasti/issues).
174
+