npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jsimple/dom-render

v0.1.2

Published

## Get started To install the library enter the following command:

Downloads

4

Readme

@jsimple/dom-render

Get started

To install the library enter the following command:

npm install @jsimple/dom-render

Example

<!-- HTML file-->
<div data-define="app-component">
  <button id="btn" type="button" $click="setIsOpen(!isOpen())">open</button>
  <div $display="isOpen()">lorem ipsum</div>
</div>
// Javascript file
import $ from "@jsimple/core";
import { DOMRender } from "@jsimple/dom-render";

function AppComponent() {
  const [isOpen, setIsOpen] = $.signal(false);
  return {isOpen, setIsOpen}
}

run([AppComponent])

or without the run function:

// Javascript file
import $ from "@jsimple/core";
import { DOMRender } from "@jsimple/dom-render";

const [isOpen, setIsOpen] = $.signal(false);
DOMRender({isOpen, setIsOpen}, $.select("#app"))

API

DOMRender()

This packages consists of a tree walker that adds effects to rerender the dom.

The DOMRender function takes two arguments:

  • a context object consisting of the variables and functions that are called in the dom.
  • a mount element to identify which part should be scanned. To avoid walking multiple times the same tree if there are multiple DOMRender function running, you must add a data-define attribute to your mount element. It will stop a higher DOMRender tree walker and let the new one take over.

run()

The run function takes an array of component functions and applies DOMRender() to each of the functions by auto-selecting the mount element by deriving it from the function name.

<div data-define="my-fancy-component">
  <div data-define="my-second-fancy-component"></div>
</div>
<div data-define="my-third-fancy-component"></div>
import $ from "@jsimple/core";
import { DOMRender } from "@jsimple/dom-render";

function MyFancyComponent() {
  ...
  return {...}
}
function MySecondFancyComponent() {
  ...
  return {...}
}
function MyThirdFancyComponent() {
  return {...}
}

run([MyFancyComponent, MySecondFancyComponent, MyThirdFancyComponent])

If you plan to minify your code you'll have to set the esbuild option keepNames to true as the code needs the real function name to infer the component to be walked.

Events

you can use $click, $mouseover, $mouseout, $change, $keydown to add event listeners to your elements.

$display

defines the display style of an element.