- Notifications
You must be signed in to change notification settings - Fork0
➿ An extensible JSX-based virtual DOM library for lightweight use in a variety of environments.
License
superlucky84/lithent
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An extensible JSX-based virtual DOM library for lightweight use in a variety of environments.
- Manual
- Korean Manual
- Home Page - (This page is written in lithent.)
Lithent were developed to make it easy to insert Virtual DOM componentfragments into pages already drawn with SSR, and are intended to beused lightly in a variety of situations.
(lithent.mjs 14.25 kB │ gzip: 4.49 kB │ map: 59.74 kB)
(lithent.umd.js 10.39 kB │ gzip: 4.03 kB │ map: 58.16 kB)
- Thanks for the introduction
- Why Use Lithent
- Basic Guide
- Lithent Ssr Boilerplate
- How To Install
- Examples
- Related Projects
- Develop Guide
- Test
In a real-world development environment, you may want to use Virtual DOM lightly, with only the bare minimum of core functionality.
"Lithent" makes it easy to add, remove, and update virtual DOM to specific parts of a pre-drawn SSR page.
"Lithent" has implemented the bare minimum functionality needed to create and update virtual DOM in general (we only need to know 'render', 'mounter', 'updater', 'renewer', 'mountCallback', and 'updateCallback').
We provide code in the form of 'helpers' that extend the basic functionality, but using the helpers is only optional and users can extend and develop custom helpers for their own projects.
JavaScript users are used to using closures and love to develop with them.
"Lithent" provides a familiar approach to my JavaScript development, as it leverages the properties of higher-order functions and closures to define and recycle the state of a component.
Lithent-Ssr-Boilerplate
is a boilerplate designed for building server-side rendering (SSR) websites using theLithent UI library.
npx create-lithent-ssr@latest
pnpm add lithent
- UMD :https://cdn.jsdelivr.net/npm/lithent@1.18.5/dist/lithent.umd.js
- UMD-HELPER:https://cdn.jsdelivr.net/npm/lithent@1.18.5/helper/dist/lithentHelper.umd.js
- UMD-FTAGS:https://cdn.jsdelivr.net/npm/lithent@1.18.5/ftags/dist/lithentFTags.umd.js
- UMD-TAG:https://cdn.jsdelivr.net/npm/lithent@1.18.5/tag/dist/lithentTag.umd.js
- ESM :https://cdn.jsdelivr.net/npm/lithent@1.18.5/dist/lithent.mjs
- ESM-HELPER:https://cdn.jsdelivr.net/npm/lithent@1.18.5/helper/dist/lithentHelper.mjs
- ESM-FTAGS:https://cdn.jsdelivr.net/npm/lithent@1.18.5/ftags/dist/lithentFTags.mjs
- ESM-TAG:https://cdn.jsdelivr.net/npm/lithent@1.18.5/tag/dist/lithentTag.mjs
It's easier to use lithent with JSX or HTM.
- Lithent is built on top of JSX.
You don't need to use h functions or JSX, you can call functions to mark them up.When creating a component, usefMount
instead ofmount
.When creating a fragment, usefFragment
instead ofFragment
.
/* ESM */import{render,h}from'lithent';import{fTags,fFragment,fMount}from'lithent/ftags';const{ section, div, p, br, strong}=fTags;/* UMD<script src="https://cdn.jsdelivr.net/npm/lithent@1.18.5/dist/lithent.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/lithent@1.18.5/helper/dist/lithentHelper.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/lithent@1.18.5/ftags/dist/lithentFTags.umd.js"></script>const { render } = lithent;const { fTags, fMount, fFragment } = lithentFTags;const { section, div, p, br, strong } = fTags;*/constfTagComponent=fMount<{firstProp:number}>((_r,props,children)=>{return()=>fFragment('first inner',div({style:{border:'1px solid red'}},'second inner'),div('The props argument can be omitted.'),props.firstProp, ...children);});render(fTagComponent({firstProp:3},// The props argument can be omitted.div({style:{border:'1px solid green'}},`Fchildren1`),'Fchildren2',br()),document.getElementById('root'));
import{lTag}from'lithent/tag';constdestroy=render(lTag`<${Component} />`,document.getElementById('root'),document.getElementById('#insert-before-this-element'));
import{h,render,mount,Fragment}from'lithent';import{lTag}from'lithent/tag';import{state}from'lithent/helper';constComponent=mount((renew,_props)=>{constcount=state(0,renew);constchange=()=>{count.value+=1;};// Updaterreturn()=>lTag` <${Fragment}> <li>count:${count.value}</li> <button onClick=${change}>increase</button> <//> `;});// appendChild or insertBefore// The third argument is an optional value for insertBefore.constdestroy=render(lTag`<${Component} />`,document.getElementById('root'),document.getElementById('#insert-before-this-element'));
<scriptsrc="https://cdn.jsdelivr.net/npm/lithent@1.18.5/dist/lithent.umd.js"></script><!--script src="https://cdn.jsdelivr.net/npm/lithent@1.18.5/helper/dist/lithentHelper.umd.js"></script--><scriptsrc="https://cdn.jsdelivr.net/npm/lithent@1.18.5/tag/dist/lithentTag.umd.js"></script><!--script src="https://cdn.jsdelivr.net/npm/lithent@1.18.5/ftags/dist/lithentFTags.umd.js"></script--><divid="root"></div><script>const{ h, Fragment, render, mount}=lithent;const{ lTag}=lithentTag;// const { state } = lithentHelper;constComponent=mount(renew=>{count=0;constchange=()=>{count+=1;renew();};// Updaterreturn()=>lTag` <${Fragment}> <li>count:${count}</li> <button onClick=${change}>increase</button> <//> `;});// appendChild or insertBefore// The third argument is an optional value for insertBefore.constdestroy=render(lTag`<${Component} />`,document.getElementById('root'),document.getElementById('#insert-before-this-element'));</script>
- htm - makingHyperscriptTaggedMarkup possible
It's open source, so you can develop and contribute together.
npm install -g pnpm
git clone https://github.com/superlucky84/lithent.gitcd lithentpnpm install
pnpm build
pnpm dev // or pnpm dev:core
To fully test everything, including plugins like helper and ftags, a build is required.
pnpm installpnpm buildpnpmtest
About
➿ An extensible JSX-based virtual DOM library for lightweight use in a variety of environments.