1.0.0 • Published 4 years ago

react-cdv v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

react-cdv

react-cdv stands for react-component-documentation-viewer, it allows user to create documentation for their components and view them directly with custom configurations in their projects.

Props

Namerequiredtypedefaultdescription
configtrueobjectThe config that controls the components and documentation
urlfalsestring'doc'The url that will be used to browse the components

Config

The documentation will be rendered based on the configuration provided, here are the fields that can be configured.

Namerequiredtypedefaultdescription
componentstruearrayA list of components with configuration

components

Namerequiredtypedefaultdescription
componenttruefunction | classThe component that will be rendered
namefalsestringThe given component's nameThe name of the component
descriptionfalsestring'No description'The description of the component
propsfalsearray[]A list of props that will be applied to the component with documentation

props

Namerequiredtypedefaultdescription
nametruestringThe name of the prop
valuetruestringThe value of the prop
requiredfalsebooleanfalseWhether this prop is required by the component or not
defaultfalseanyThe default value of the prop
typefalsestring'any'The type of the prop
docfalsestring''The documentation of this prop

Example

Here is a screenshot of the example: Example Screenshot

The above documentation can be generated by the following config:

{
  component: Modal,
  description: "Wrapped the Modal component from React Bootstrap",
  props: [
    {
      name: "header",
      value: "",
      default: "",
      doc: "The header of the Modal, header will not be displayed if this is not given",
      type: "string"
    },
    {
      name: "body",
      value: "Hello World",
      required: true,
      doc: "Body of the modal",
      type: "string"
    },
    {
      name: "footer",
      value: "",
      default: "",
      doc: "The footer of the Modal, footer will not be displayed if this is not given",
      type: "string"
    },
  ]
}

To run examples use npm start and go to http://localhost:8080 in your browser, see examples folder for more information

TODO

v1.0.0
  • Add example
  • Prevent name duplications
  • ~Improve add config using functions~ (Push to v1.1.0)
  • Change all bootstrap elements to React Bootstrap
  • Implement the search feature of the sidebar
  • Proper warning and error display
  • ~Figure out a way when user deleted required props and error is thrown~ (This only happens in react development mode)