Skip to content
/ lego Public

๐Ÿš€ Low-Tech Web-Components Made Lightweight & Future-Proof.

License

Notifications You must be signed in to change notification settings

Polight/lego

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Lego is a fast & native web-components library

LEGO: Modern Buildless Web-Components

Native Web-Components?

Yes, you write native HTML, CSS and JS and create a native web-components W3C compliant.

It's stable and predictable.

If you have ever played with Web-Component-like frameworks (not to name Vue, React, Svelteโ€ฆ), you may know how debugging gets tricky and requires extra tooling.

Because LEGO is native, your browser developper toobar is all you need.

  • debugger works as expected,
  • step-by-step debugging,
  • element inspector,
  • the console with the live JS in the contextโ€ฆ

It's all just normal!

Buildless

Because buildless is becoming a thing, we can know give it a name that speaks to all.

What does LEGO actually look like?

/bricks/lean-welcome.html:

<template>
  <h1>Welcome to LEGO</h1>
  <p>The lean way to make web-components <slot></slot></p>
</template>

Later you can use it anywhere in your HTML:

<lean-welcome>powerful and easy</lean-welcome>

Will read in your HTML:

Welcome to LEGO
The lean way to make web-components powerful and easy

Of course there's so much more you can do. The documentation will guide you ๐Ÿ““

Pretty neat!

Getting Started in 3 minutes

You can just hop in and experiment your first HTML Element.

Follow this Getting Started guide for installing and writing your first component.

Once you're done with it you can write more components the same way and play with daily usage guide for passing advanced arguments, writing conditions and loops, dynamic styling, connecting to APIsโ€ฆ

What Can You Actually Do With It?

You can create a simple reusable web-components for your HTML website or build a full fledge app with it. It's as light as powerful, fully driven by the web-browsers standards.

Various applications are running Lego in production for years now.

Because of the standards and the zero dependency you can rely on it for the long term.

Your site/app will still running and remain editable in 10+ years, and as long as web browsers will exist.

How Does LEGO Work?

LEGO (Lightweight Embedded Gluten-free Objects) is a base class that you extend and provide you with methods to use โ™ป๏ธ reactive and ๐Ÿก native web-components that are easy to digest ๐ŸŒฑ for your browser.

A small CLI in NodeJS come along to build ๐Ÿš€ your component. There's no Vite nor other 3rd parties, it's just an interpreter of ยฑ180 lines of readable code.

What is LEGO Behind?

  • ๐Ÿ‘™ Minimalist: 74 61 lines of readable code in its core (non-optimised, uncompressed, no cheating)
  • ๐ŸŒฑ Zero dependency: it uses Petit-Dom which is stable and embedded, so no bad suprise in the future
  • โ™ป๏ธ Reactive: updating the state recalculate the Virtual Dom when needed
  • ๐Ÿš€ fast: using virtual dom through a thin layer makes it close to bare-metal
  • ๐Ÿ’ง Simple: that's Vanilla, there isn't much to know, it's a raw class to extend; no magic โœจ
  • ๐Ÿชถ 3 directives to enhance HTML: :if for conditions, :for for loops, @myfuncname to call an action
  • ๐Ÿก Native: LEGO components are actual native web-components, you benefit from all the today's and tomorrow's possibilites (slot, Shadow DOM, โ€ฆ).

Lego is not (and will never be):

  • ๐Ÿฏ A full bloated frontend framework with routing. Others do it well.
  • ๐Ÿ— A website builder with SSR or similar complexities.
  • ๐Ÿ” An HTML replacement that locks you into a specific technology.

Next Steps, Demo and Doc

๐Ÿงช View the demo and their source.

๐Ÿ“• Read the full documentation at https://lego.js.org

๐Ÿ’ญ Lego is inspired from the native Web-Component spec and Riot.

๐Ÿ”ง Customizing and contributing is just much lighter with simplicity, source that are easy to read, to hack and to maintain.

๐ŸŽˆ You can read the core code that is only 61 LOC resulting that Lego is as light as 3Kb for the full bundle!