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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jschofield/scroll-explain

v0.3.0

Published

Scroll-driven explanation web component built with Lit, uses code-highlight

Readme

@jschofield/scroll-explain

A scroll-driven code walkthrough web component built with Lit. Creates a two-column layout where prose explanations on the left drive line highlighting in a sticky code block on the right. Pairs with @jschofield/code-highlight.

Install

npm install @jschofield/scroll-explain @jschofield/code-highlight

Peer dependencies

This component requires the following peer dependency:

npm install lit

| Peer | Version | |---|---| | lit | ^3.0.0 |

Usage

<script type="module">
  import '@jschofield/scroll-explain';
  import '@jschofield/code-highlight';
</script>

<scroll-explain>
  <div slot="prose">
    <p>Here's how this function works:</p>

    <explain-section lines="1-3">
      <p>First, we set up the variables...</p>
    </explain-section>

    <explain-section lines="5-8">
      <p>Then we process each item in the loop...</p>
    </explain-section>

    <explain-section lines="10-12">
      <p>Finally, we return the result.</p>
    </explain-section>
  </div>

  <code-highlight lang="javascript" slot="code" line-numbers>
    <template>
      <script>
        const items = getData();
        const results = [];
        let count = 0;

        for (const item of items) {
          const processed = transform(item);
          results.push(processed);
          count++;
        }

        console.log(`Processed ${count} items`);
        return results;
      </script>
    </template>
  </code-highlight>
</scroll-explain>

Without a bundler

If you're not using a bundler, provide peer dependencies via an import map:

<script type="importmap">
{
  "imports": {
    "lit": "https://esm.run/lit",
    "lit/": "https://esm.run/lit/"
  }
}
</script>
<script type="module" src="https://esm.run/@jschofield/scroll-explain"></script>
<script type="module" src="https://esm.run/@jschofield/code-highlight"></script>

Slots

| Slot | Content | |---|---| | prose | Container with text and <explain-section> elements | | code | A <code-highlight> element with line-numbers |

<explain-section> attributes

| Attribute | Type | Default | Description | |---|---|---|---| | lines | string | "" | Line spec to highlight when this section is visible (e.g., "1-3,5,7-9") |

How it works

As the user scrolls, an IntersectionObserver detects which <explain-section> is visible and tells the <code-highlight> element to activate the corresponding lines. The code block smoothly scrolls to keep the active lines centered.

Responsive behavior

  • Desktop (>900px): Two-column grid. Code sticks to the right side.
  • Mobile (<900px): Code sticks to the top of the viewport. Prose scrolls below.

License

MIT