Coder Social home page Coder Social logo

pauliescanlon / gatsby-plugin-prop-shop Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 1.0 1.19 MB

A Gatsby plugin that provides an holistic view of all defined PropTypes ๐Ÿš

Home Page: https://gatsby-plugin-prop-shop.netlify.com/prop-shop/

JavaScript 100.00%
gatsbyjs gatsby-plugins gatsby

gatsby-plugin-prop-shop's Introduction

prop-shop-og-image image

gatsby-plugin-prop-shop

gatsby-plugin-prop-shop provides an holistic view of all defined PropTypes or type definitions in your Gatsby project.

Oh, and there must be at least one .js file in your project containing propTypes or one .tsx file containing an interface or type

๐Ÿ‘๏ธ Preview

๐Ÿš€ Getting started

Install

npm install @pauliescanlon/gatsby-plugin-prop-shop --save

Install peer dependencies

npm install gatsby-source-filesystem prop-types --save

If you see any errors relating to Gatsby or React check the peerDependencies versions here

Setup

// gatsby-config.js
module.exports = {
  ...
  plugins: [
    {
      resolve: `@pauliescanlon/gatsby-plugin-prop-shop`,
      options: {
        source: [`src/pages`, `src/images`, `src/components`],
      },
    },
  ]
  ...
}

gatsby-plugin-prop-shop will find all PropTypes for files named in the source array.

Options

Option Type Required Default Description
source array or string yes null Where to find .js files with PropTypes
debug boolean no false Logs to console paths to the .js named in source

Run it!

You can now run either gatsby develop or gatsby build / serve and then navigate to the /prop-shop page

 ---------------------------------
  http://localhost:8000/prop-shop
 ---------------------------------

Psst!

If you're using gatsby-plugin-prop-shop in a theme you might need to be more explicit with where the source directories can be found eg;

// gatsby-config.js
module.exports = {
  ...
  plugins: [
    {
      resolve: `@pauliescanlon/gatsby-plugin-prop-shop`,
      options: {
        source: [`${__dirname}/src/components`],
      },
    },
  ]
  ...
}

or perhaps you need to jump out a level

// gatsby-config.js
module.exports = {
  ...
  plugins: [
    {
      resolve: `@pauliescanlon/gatsby-plugin-prop-shop`,
      options: {
        source: [path.resolve(`${process.cwd()}/../components/src`)],
      },
    },
  ]
  ...
}

If you haven't used PropTypes before here's a bit of an example.

...
import PropTypes from 'prop-types'

export const Say = ({ words }) => <div>{words}</div>

Say.propTypes = {
  /** Some words that the component must say  */
  words: PropTypes.string.isRequired
}

If you're using TypeScript your interface or type might look like this.

...
interface IProps {
  /** Some words that the component must say  */
  words: string;
}

export const Say: React.FunctionComponent<IProps> = ({ words }) => (
  <div>{words}</div>
)

If you're using gatsby-plugin-prop-shop in your project i'd love to hear from you @pauliescanlon

ko-fi

gatsby-plugin-prop-shop's People

Contributors

pauliescanlon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

thedemodev

gatsby-plugin-prop-shop's Issues

Add sorting to table headers

Currently the tables just sort the data by whatver comes back form react-docgen but it would be good to allow users to sort on each of the table headers

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.