Giter Site home page Giter Site logo

pretty-proptypes's Introduction

The code for this package has been moved

To make a better unified dev loop, this package has been added to a monorepo for packages that work with extract-react-types. Future work will continue from there.

PrettyPropTypes

PrettyPropTypes is designed to display the output of extract-react-types. It is designed to read the output from extract-react-types, and display rich prop information for consumers.

Core usage pattern

<Props
  heading="My Cool Component"
  props={require('!!extract-react-types-loader!../MyCoolComponent')}
/>

This analyses prop type definitions, and default props. It creates descriptions from comments before the type definitions, and will render markdown syntax using react-markings.

Quick Tips

  • Using extract-react-types-loader is definitely the easiest way to get this information from your components, however you can prebuild this data with extract-react-types and read it from a file if you prefer.
  • When using extract-react-types, it currently looks only at the default export of a file, with the assumption that it is a react class component.

Customisation Props

Heading

Display a heading for the collection of props. Pass in an empty string if you want no heading, otherwise it defaults to "Props".

shouldCollapseProps

Set whether the prop shapes should be shown by default, or whether they should be hidden, and require being expanded.

Components

Accepts an object that allows you to override particular style components within our prop definition. The currently modifiable components are:

  • Indent
  • Outline
  • Required
  • Type
  • StringType
  • TypeMeta

Any that are not passed in will use the default component.

Overrides

The override prop allows you to override a specific prop's definition. If you want to keep the appearance aligned, we recommend using the Prop export from PrettyPropType.

An override is invoked with all the props passed to the Prop component internally, and renders the result. In the example below, we are changing the type field, and stopping the shape component from appearing, while leaving other parts of the component the same.

import Props, { Prop } from 'pretty-proptypes'

${<Props
  heading=""
  props={require('!!extract-react-types-loader!../../PropTypes/Select')}
  overrides={{
    components: (props) => <Prop {...props} shapeComponent={() => null} type="All Components Object" /> }}
/>}

While you can pass style components directly to Prop, we recommend passing style components in the top level Props, and letting them flow down.

pretty-proptypes's People

Contributors

noviny avatar blasz avatar macku avatar nathf avatar

Stargazers

Christopher Pappas avatar Ilya Zolotov avatar Raja Bellebon avatar Vinod Godti  avatar Ajay Narain Mathur avatar Lochlan Bunn avatar  avatar Jeroen Ransijn avatar Dominik Wilkowski avatar

Watchers

James Cloos avatar  avatar

pretty-proptypes's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.