New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lucia

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lucia

Tiny library for tiny web apps.

  • 0.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25K
decreased by-26.94%
Maintainers
1
Weekly downloads
 
Created
Source

Lucia · Code Size NPM Version GitHub license PRs Welcome

Tiny library for tiny web apps (Currently heavily developed. Not recommended for production environments)

  • Declarative: Lucia provides a straightforward API to create declarative views, allowing predictible and easy development.
  • Directive: Lucia relies heavily on the concept of bringing development to the HTML, making it easier to visualize than interacting with the actual DOM through directive attributes.
  • Reactive: When the view is changed, the Virtual DOM will automatically react and will update and render the new view in realtime.
  • Lightweight: Lucia is extremely light (~3kb min+brotli) and performant as it does not VNode diff, renders directives only if necessary by skipping static notes, and relies only on selectors.
  • Data-Driven: Instead of using traditional direct DOM manipulation, Lucia provides an interface to change view data to mutate our loose Virtual DOM.

Installation

Lucia is currently only installable through a CDN and also supports UMD. Put this within your <head> tags in html.

<!-- development version, includes helpful console warnings -->
<script src="https://unpkg.com/lucia/dist/lucia.js"></script>
<!-- production version, optimized for size and speed -->
<script src="https://unpkg.com/lucia"></script>

Example

Below is an example of a clicker game in Lucia.

<div id="app">
  <button *on:click="increment()" *html="count"></button>
</div>
const ClickerGame = {
  count: localStorage.count || 0,
  increment() {
    localStorage.count = ++this.count;
  },
};

Lucia.createApp(ClickerGame).mount('#app');

Features

Declarative Rendering

At the core of Lucia is a system that enables us to declaratively render data to the DOM using the straightforward *html directive:

<div id="app">
  <p *html="message"></p>
  <p *html="message === 'Hello World!'"></p>
</div>
Lucia.createApp({
  message: 'Hello World!',
}).mount('#app');

Conditionals

It’s easy to toggle the presence of an element, too:

<div id="app">
  <button *if="!show">You can't see me</button>
  <button *if="show">You can see me</button>
</div>
Lucia.createApp({
  show: true,
}).mount('#app');

Event Handlers

To let users interact with your app, we can use the *on directive to attach event listeners that invoke methods on our Lucia instances:

<div id="app">
  <button *on:click="announce()" *html="message"></button>
</div>
Lucia.createApp({
  message: 'Hello world!',
  announce() {
    alert(this.message);
  },
}).mount('#app');

Attribute Binding

In addition to text interpolation, we can also bind element attributes using the *bind directive:

<div id="app">
  <h1 *bind:class="{ hello: show }">Classes are cool</h1>
  <h1 *bind:style="color">Styles are sassy</h1>
</div>
Lucia.createApp({
  show: true,
  // You can also reference data vs inputing an object in the directive itself
  color: { color: 'purple' },
}).mount('#app');

List Rendering

We can also use the *join directive to render a list of items based on an array. Note that performance will be affected if using array mutators.

<div id="app">
  <p *join="fruits by , "></p>
</div>
Lucia.createApp({
  fruits: ['apple', 'orange', 'banana'],
}).mount('#app');

Form Input Bindings

You can use the *model directive to create two-way data bindings on form input, textarea, and select elements.

<div id="app">
  <input *model="message" />
  <p *html="message"></p>
</div>
Lucia.createApp({
  message: 'Nothing submitted yet',
}).mount('#app');

License

Lucia is MIT licensed.

Keywords

FAQs

Package last updated on 05 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc