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

@js-demo/demopage

v0.2.1

Published

React components for rendering component demos based on Markdown Documentation

Downloads

4

Readme

@js-demo/demopage

  • UI components for rendering demos and React Components via Markdown

Markdown to JSX Demo Page Builder Components

A React Component is provided by this library based on the [markdown-to-jsx]:(https://github.com/probablyup/markdown-to-jsx) library. The intent here is for the component README.md files to act as both documentation for usage of your components.

See additional documentation on usage below

Add as a project dev dependency:

yarn add @js-demo/demo-page --dev

Demo Setup

Create a folder named _demo (recommended) in your project:

|-my-javascript-project
  |-_demo
      |-index.html
      |-index.ts(x)
      |-webpack.config.js

Where:

  • index.html is the main html file for rendering your demo.
  • To work with the default provided webpack config, the contents of this file should include:
<body>
  <div id="container"></div>
  <script src="../demo.js"></script>
</body>
  • index.ts(x) code to pull in your components and actually run the demo. See below on usage of the Markdown processing components.

Then run yarn start-demo to start the local development server (part of @js-demo/core)

Markdown to JSX Demo Page Component

Expected Project Folder Structure

The demo components are based on assumption that a project will contain a primary README.md file, and then specific README.md files for each component exported by the library.

Example:

  |->my-react-project
    |->README.md  //main README, general project documentation
    |->src
      |->components
        |->ComponentA
          |->README.md
          |-> ... // other source files
        |->ComponentB
          |->README.md
          |-> ... // other source files

DemoApp

Given the structure above, you can setup your _demo/index.tsx to render a demo page with component navigation using the DemoPage component

This component will render a demo page for one or more components, given the following props:

  • components: a js module containing all of the components that should be included in the demo navigation.
  • srcFolder: path to folder containing sub-folders with README files for the components included in the components module. This is relative to the project root dir, not to the _demo folder.
  • readme: path to main project README. This is relative to the project root dir, not to the _demo folder.
  • title: name of the project being demoed (displayed as header on demo page)
import * as React from 'react';
import { render } from 'react-dom';
import { DemoApp } from '@js-demo/demopage';
import * as components from '../src/components';

const title = 'My Awesome React Component';
render(<DemoApp
  components={components}
  srcFolder={`src/components`}
  readme={'README.md'}
  title={title} />,
  document.getElementById('container')
);

ReduxDemoApp

Same usage as DemoApp, but for usage when a Redux store is required for one or more of the components included in the demo.