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

npk-ui

v1.2.4

Published

ui library for reusing my simple designs at work

Downloads

4

Readme

NPK-UI

Simple UI library for my work projects.

What this is

This is a simple UI library to quickly reuse some compnents that I use in my work projects.

What this is NOT

This library will probably not be directly useful to anyone outside of my organization. However, feel free to borrow any ideas, patterns, or anti-patterns that you see fit.

Installation

npm install --save npk-ui

or

yarn add npk-ui

This package also depends on react, prop-types, styled-components and react-router-dom. Make sure those are all installed!

Components

Dashboard

props

user

object {admin: boolean, name: string} | required

Used to display the user name in the sidebar and to determine if any routes should be hidden for non-admin users.

heading

string | defaults to empty string

Used to give a heading to the dashboard sidebar.

logo

string | defaults to null

Will be used as src attribute for a image in the sidebar. Omit if no image is wanted.

hideSidbar

boolean | defaults to false

If true, will hide the sidebar.

routes

array | required

An array of route objects that will be used to build up React Router Routes. Each route object can have the following properties:

path | string | required

The path the route should point to.

icon | React.node

An optional icon to render to the left of the route links on the sidebar.

linkText | string | required

The text to render for the link to the route.

component | React.Component | required

The component that the route should render.

link | boolean

If true, the sidebar will render a link for this route. If false, only a route will be created. This is useful for routes with parameters. You probably don't want a direct link to a parameterized route on your dashboard.

activeOnlyWhenExact | boolean

If true, the generated link will only highlight as active if the path is an exact match.

badgeCount | number

If given, a badge will be displayed to the right of the created link that shows a badge with the number provided.

anchor | boolean

If given, a simple anchor tag will be created that does NOT use the router. Useful for if you need to have link outside of the app in the nav.

exact | boolean

This determines if the exact attribute on the React Route Route gets set or not.

Simple Example

import { Dashboard } from 'npk-ui'
import logo from './my-image.png'

const routes = [
  {
    path: '/',
    icon: <i className="fa fa-lg fa-home" />,
    linkText: 'Home',
    component: SomeComponent,
    link: true,
    activeOnlyWhenExact: true,
  },
]

function App() {
  return (
    <BrowserRouter>
      <Dashboard
        user={{ admin: false, name: 'Luke Skywalker' }}
        routes={routes}
        heading="Basic Dashboard"
        logo={logo}
      />
    </BrowserRouter>
  )
}

Modal

A simple component using the new React 16 portal feature to display a modal over a transparent overlay.

Sample Usage

import { Modal } from 'npk-ui'

class App extends React.Component {
  state = {
    showModal: false,
  }

  handleClose = () => {
    this.setState({ showModal: false })
  }

  buttonClick = () => {
    this.setState({ showModal: true })
  }

  render() {
    return (
      <div>
        <h1>Main Content</h1>
        <button type="button" onClick={this.buttonClick}>
          Show Modal
        </button>
        {this.state.showModal && (
          <Modal
            handleClose={this.handleClose}
            closeIcon={<span>X</span>}
            heading="Modal Heading Text"
          >
            <h2>The contents of the modal go here.</h2>
          </Modal>
        )}
      </div>
    )
  }
}

props

handleClose

function(void) | required

A callback to notify when the close button has been clicked.

closeIcon

React.node

What to render for the close icon in the top right of the modal.

heading

string | defaults to empty string

The heading to render at the top of the modal.

children

React.node

This content will be rendered inside of the modal.

Examples

Examples can be found in the stories folder.

LICENSE

MIT