New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dev-novel

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dev-novel

📓 Build an interactive JavaScript development page

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

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

Since the project is still private, you will need to clone and build dev-novel by yourself in order to use it in your project:

  • $ git clone git@github.com:algolia/dev-novel.git
  • $ cd dev-novel && yarn && yarn link

Then in your project you simply run:

  • $ yarn link dev-novel

You will also need to provide your own build system, we are not providing an minified/unified build for the moment. So use either webpack, rollup or browserify to start your dev environment.

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({
  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
const eventDisposers = []
registerDisposer(() => { eventDisposers.forEach(disposer => disposer()) })

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

TODO

  • Provide initializers/disposers per stories
  • Provide an UMD build for usage in the browser
  • Open source / publish to NPM?

FAQs

Package last updated on 14 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc