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

@qodunpob/component-demo-ui

v1.0.0

Published

A tiny UI library for creating a single page application to demonstrate a component

Downloads

1

Readme

component-demo-ui

If you are seeking for a simple solution to demonstrate a single React-component working, this might be what you need.


The tiny UI library provides several of components for creating a single page application with a preview of your component, a description of its props, additional sections and a link to GitHub. An example of what a demo page might look like can be found in the demo folder, use the following command to run:

npm start

Installation

npm install --save @qodunpob/component-demo-ui

Usage

Styles

First of all you need to import global styles for the magic to work

import '@qodunpob/component-demo-ui/dist/assets/styles/styles.css'

This will import the Lato font from Google Fonts, add global styles for component containers, and also initialize color variables that you can change if desired

:root {
  --component-demo-ui-border-color: #ccc;
  --component-demo-ui-input-border-color: #00aaff;
  --component-demo-ui-input-focus-border-color: #ff00aa;
}

Components

The following is a list of components that this library provides.

Preview

You'll probably want to put this component at the top of the page. It displays the h1 level header and your component in action, so it requires specifying the title and passing the child element.

Props

| Name | Necessity | Type | Description | | ------------------ | ---------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | title | required | string | H1 page title, probably the name of the component | | children | required | ReactElement | Component itself | | className | optional | string | Custom css class | | caption | optional | string | Text block between title and component | | description | optional | string | Text block at the end of Preview component (after Inspector) | | controls | optional | ControlDefinition[] | Setting up controls that allow a visitor to change the value of a component's properties.There are 3 types of controls available:- text- checkbox- select | | showInspector | optional | boolean | Inspector display indicator | | inspectorTitle | optional | string | Inspector window title (if it's displayed) |

Ref

The Preview component provides an interface for interaction (PreviewRef):

export interface PreviewRef {
  inspect: (data: any) => void
}

You can pass any data to the inspect method to display it in the Inspect component.

GitHubLink

Simply displays a link to your component's GitHub repository in a corner style on the page. An important feature is that the GitHub icon used is background independent, and even if it is initially oriented towards a light page background, you can always recolor it.

Props

| Name | Necessity | Type | Description | | ------------- | ---------- | -------- | ------------------------------------------ | | url | required | string | Link to your component's GitHub repository | | className | optional | string | Custom css class |

Section

Component for declaring a section on pages with an h2-level heading and any content.

Props

| Name | Necessity | Type | Description | | ------------- | ---------- | ----------- | ---------------- | | title | required | string | H2 section title | | children | optional | ReactNode | Section content | | className | optional | string | Custom css class |

PropList

Represents props as a list of terms and their descriptions.

Props

| Name | Necessity | Type | Description | | ------------- | ---------- | --------------------------------------------------------------- | ----------------------- | | items | required | PropDefinition[] | List of described props | | className | optional | string | Custom css class |

Caution: The PropList component itself is not a section and does not have page container styles, so it should be placed inside a section as a child element.

You can see the direct use of all the components described above in the demo.

Contributing

Feel free to add proposals or report bugs in issues. Your PRs are welcome!

To run the demo, as noted above, use the command:

npm start

To build the library locally, use the command:

npm run lib:build

Don't forget to check your changes with tests and linters:

npm test
npm run lint
npm run lint:fix
npm run format

The project uses standard-with-typescript configuration for eslint, with added React-specific rules.

License

MIT.