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

styled-system-props-table

v0.1.6

Published

Props table generator with styled-system decorator

Downloads

5

Readme

Styled System props table

This is a props table generator for documenting a React component's props using Styled System. The library can be extended to suit your own implementation of styled-system but the idea is to output a table of props to document components with wide, highly repetitive props footprints by analyzing their propTypes and defaultProps settings and applying rich documentation to the table. This has several advantages over the Storybook Docs add-on's props table generator:

  • Richer documenation, including links to Styled System documenation, so any component consumer can easily understand it.
  • Inline references to your custom theme. Your library consumers can easily tell which values are available on your theme.
  • Props are sorted by interpolation function so it's easy to quickly scan which prop categories are being used.
  • Extending prop descriptions is done in the component itself using JSX, rather than reading code hints from the source file at compile time.

This component is recommned for use with Storybook, but compatible with any jsx-compatible format.

Install

yarn add styled-system-props-table

Simple Example

Only one prop is required component which takes a React component.

import { StyledSystemPropsTable } from 'sytled-system-props-table'
import Card from '../path/to/components/Card'

<StyledSystemPropsTable component={Card} />

Less-Simple Example

You can intercept and decorate individual prop rows as well, however all props should have reasonable data attached to them by default. The example below will populate a column for the variant prop on the Card column.

import { StyledSystemPropsTable, PropRow } from 'sytled-system-props-table'
import Card from 'path-to-components/Card'
import theme from './path/to/your-styled-system-theme'

const transformProps = (name = '', properties = {}) => {
  if (name === 'variant') return {
    ...properties,
    description: <ul>
      <li><strong>EMPTY</strong> Empty placeholder card</li>
      <li><strong>PRODUCT</strong> applies rouned corner and displays a ProductImage</li>
      <li>SHARP_TOP_CORNER</li>
      ...
    </ul>
  }
}

<StyledSystemPropsTable 
  component={Card} 
  theme={theme}
  transformProps={transformProps}
/>

Other data you can modify this way include

description: prop description

type: Overrides the type from propTypes assignmemnt

themeKey: If theme is passed, available theme properties relevant to the prop will appear in the Theme Values column

required

sortWeight: make the prop appear higher or lower in the output table. Highest appears first. Default is 0

DEMO

Demo here

Extending

This library exports props-table as well as styled-system-props-table. The difference is that styled-system-props-table includes a props-table wrapped with a large library of prop transformers mapped to the styled-system API. However, if you are using another interface you wrap your own props-table with your own transformers.

<PropsTable transformProps={[yourOwnStyledSystem, otherDecorators]} component={...}/>

Customization

TODO

Caveats

at the moment you must call in parse-prop-types at the root of your React project. This is necessary because under the hood, this library depends on it to preserve proptype metadata.