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

element-book

v23.1.1

Published

An [`element-vir`](https://npmjs.com/package/element-vir) drop-in element for building, testing, and demonstrating a collection of elements (or, in other words, a design system).

Downloads

1,005

Readme

element-book

An element-vir drop-in element for building, testing, and demonstrating a collection of elements (or, in other words, a design system).

Installation

npm i element-book

Terminology

  • Page: a group of pages and / or element examples. Pages can be infinitely nested.
  • Element Example: an individual element example with independent state, styles, title, etc.

Usage

  1. Define element-book pages with defineBookPage:

    import {defineBookPage} from '../data/book-entry/book-page/define-book-page.js';
    
    export const myPage = defineBookPage({
        /** Use `undefined` if your page is at the top level. */
        parent: undefined,
        title: 'My Page',
    });
  2. Inside of a page definition, define an element example:

    import {html} from 'element-vir';
    import {defineBookPage} from '../data/book-entry/book-page/define-book-page.js';
    
    export const myPage = defineBookPage({
        /** Use `undefined` if your page is at the top level. */
        parent: undefined,
        title: 'My Page',
        defineExamples({defineExample}) {
            defineExample({
                title: 'My Example',
                render() {
                    return html`
                        <p>Render your element here.</p>
                    `;
                },
            });
        },
    });
  3. Instantiate an instance of the element book app into your app and pass in all your pages:

    import {defineElementNoInputs, html} from 'element-vir';
    import {ElementBookApp} from '../ui/elements/element-book-app/element-book-app.element.js';
    import {myPage} from './define-page.example.js';
    
    export const MyApp = defineElementNoInputs({
        tagName: 'my-app',
        render() {
            return html`
                <${ElementBookApp.assign({
                    pages: [
                        myPage,
                    ],
                })}></${ElementBookApp}>
            `;
        },
    });

Why not Storybook?

Because Storybook is un-composable, impossible to debug, and full of behind-the-scenes *magic* that you can't backtrack without already understanding the inner workings of Storybook itself. With element-book, it's all just imports that you can directly follow with the TypeScript compiler.