Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

LemonadeJS: Micro Reactive JavaScript Library

Create amazing web-based interfaces and framework-agnostic components with LemonadeJS

Micro Library

LemonadeJS is a super lightweight, reactive, vanilla JavaScript micro-library (7 KB). It helps integrate JavaScript (controllers) with HTML (view) through two-way data binding. It also integrates natively with jSuites to help you build amazing interfaces more quickly.

LemonadeJS enables the creation of reusable components without the need for a transpiler, Babel, or dozens of dependencies. It works seamlessly in any JavaScript development environment. With a fast learning curve, LemonadeJS keeps coding enjoyable and stays close to native JavaScript.

  • Build rich and user-friendly web interfaces and applications
  • Handle complex data inputs with ease
  • Enhance the software user experience
  • Create rich CRUD interfaces and beautiful UIs
  • Highly flexible and customizable
  • Lightweight and simple to use

Installation

NPM package

% npm install lemonadejs

Using from CDN

<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>

Create a LemonadeJS sample app

% npx @lemonadejs/create myApp<br>
% cd myApp<br>
% npm run start<br>

Running tests

% npm run test

Examples

Webpack

Build modern applications with lemonadeJS and node.

See this example on StackBlitz

import lemonade from "lemonadejs";
export default function App() {
 this.count = 1;
 return render => render`<div>
 <p>You clicked ${this.count} times</p>
 <button onclick="${()=>this.count++}">Click me</button>
 </div>`;
}

Browser

Simplicity to run in the browser without dependencies, servers, transpiler.

<html>
<body>
<div id="root"></div>
<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script>
function Hello() {
 return render => render`<h1>${this.title}</h1>`;
}
function App() {
 this.count = 1;
 return render => render`<div>
 <Hello title="some title" />
 <p>You clicked ${this.count} times</p>
 <button onclick="${()=>this.count++}">Click me</button>
 </div>`;
}
lemonade.render(App, document.getElementById('root'));
</script>
</body>
</html>

Creating a table from an array of objects

import lemonade from "lemonadejs";
export default function Component() {
 this.rows = [
 { title:'Google', description: 'The alpha search engine...' },
 { title:'Bing', description: 'The microsoft search engine...' },
 { title:'Duckduckgo', description: 'Privacy in the first place...' },
 ];
 // Custom components such as List should always be unique inside a real tag.
 return render => render`<table cellpadding="6">
 <thead><tr><th>Title</th><th>Description</th></th></thead>
 <tbody :loop="${this.rows}">
 <tr><td>{{self.title}}</td><td>{{self.description}}</td></tr>
 </tbody>
 </table>`;
}

The event object

<html>
<body>
<div id='root'></div>
<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script>
function Component() {
 const test = (e) => {
 console.log(e);
 e.preventDefault();
 }
 // The property call is added to the observable list when added to the DOM
 return render => render`<input type="button" value="Click test" onclick="${test}"/>`;
}
// Render the LemonadeJS element into the DOM
lemonade.render(Component, document.getElementById('root'));
</script>
</body>
</html>

Enable/disable HTML elements

<html>
<body>
<div id='root'></div>
<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script>
function App() {
 this.disabled = false;
 const toggle = () => {
 this.disabled = !this.disabled;
 }
 return render => render`<>
 <button onclick="${toggle}">Toggle</button>
 <input type="text" disabled="${this.disabled}" />
 </>`;
}
lemonade.render(App, document.getElementById('root'));
</script>
</body>
</html>

License

This software is free to use, and it is distributed under the MIT license.

Learning LemonadeJS

Documentation

Libraries

Examples

Other tools

About

LemonadeJS is a 7KB reactive JavaScript micro-library offering two-way data binding. It is dependency-free, does not require transpiling, and works with webpack or directly in the browser.

Topics

Resources

Stars

473 stars

Watchers

12 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /