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

dev-novel

v0.0.6

Published

📓 Build an interactive JavaScript development page

Downloads

12

Readme

dev-novel

dev-novel is a clone of the well known storybook.js. It allows you to browse through example of a library. It's less complete than Storybook but works with every JS library, it's not linked to React components exclusively.

preview

Getting started

Installation

  • $ npm i -D dev-novel OR
  • $ yarn add -D dev-novel

You will need your own build system (like webpack or rollup) to process the javascript and serve the page for you. You need to serve an index.html with a body tag and voilà!

Usage

  1. First define your stories:
import { storiesOf } from 'dev-novel'

storiesOf('My first story')
  .add('Hello world', (container: HTMLDivElement) => {
    // create `<h1>Hello world</h1>`
    const title = document.createElement('h1')
    title.innerText = 'Hello world'

    // display it into the story result
    container.appendChild(title)
  })
  1. You can add initializers / disposers that runs before and after your story:

This can be useful when you need to provide globals for your story, for instance depending onto another library.

import { registerInitializer, registerDisposer, storiesOf } from 'dev-novel'

registerInitializer(() => {
  window._appState = {
    user: {
      firstName: 'Max',
      lastName: 'Tyler'
    }
  }
})

registerDisposer(() => {
  window._appState = undefined
  delete window._appState
})

storiesOf('User profile')
  .add('Display user fullname', (container: HTMLDivElement) => {
    const span = document.createElement('span')
    span.innerText = `${window._appState.user.firstName} ${window._appState.user.lastName}`

    container.appendChild(span)
  })
  1. Finally start dev-novel UI and open your page:
import { start, storiesOf } from 'dev-novel'

[...]

start({
  projectName: ?string // name of the project to display in header of sidebar
  projectLink: ?string // URL to link on the projectName
  openAllStories?: boolean // open all parent stories item in the menu by default
})

Use the ActionLogger

With actions, you can inspect events and log them directly into the page. This is pretty neat when you are manually testing your components.

import { action, registerDisposer, storiesOf } from 'dev-novel'

// remove all event listeners when switching to another story
let eventDisposers = []
registerDisposer(() => {
  eventDisposers.forEach(disposer => disposer())
  eventDisposers = []
})

storiesOf('Button')
  .add('click', container => {
    const handler = action('button-click')
    const button = document.createElement('button')
    button.innerText = 'Click me!'
    button.addEventListener('click', handler, false)

    // remove event listener after story ran
    const disposer = () => button.removeEventListener('click', handler, false)
    eventDisposers.push(disposer)

    // append button
    container.appendChild(button)
  })

preview-action-logger