Giter VIP home page Giter VIP logo

component-library-starter's Introduction

Component Library Starter

This is a react component library starter kit for adding and using reusable react components. Built on React, Rollup, and Storybook.

To see demos and component documentation, view the storybook.

Setup


  • Clone this project
  • Make sure you rename your component library in package.json

Useage


Just import the react component t you with to use:

import React, { Component } from 'react';
import { MockComponent } from 'my-component-library';

class MyComponent extends Component {
  render() {
	  return (
		  <div>
			  <MockComponent />
		  </div>
	  );
  }
}

Adding Components


  • Add your new components to the src/lib directory.
  • Each component directory should contain, at minimum, these files:
    • The index.js that deals with exporting the component
    • The actual component file (MyComponent.js)
    • Your component’s .css file (in postcss)
    • Your components .story.js file for storybook demonstration
    • Your component’s .test.js file
    • Any other needed sub component files
    • The json file automatically generated by postcss (after a build)
  • Import/export your component to src/lib/index.js

PostCSS + CSS Modules


  • Why use PostCSS?
    • More javascript-y
    • NO MOAR NODE-SASS
    • Faster to compile
    • Better exposes classes and animations to our javascript
    • Is extensible
    • Much like react, only uses the features you want to use
  • Why use CSS modules?
    • Classnames and animation names are locally scoped (which is very useful for a component library that will be used in many projects)

Code Standards


  • Write tests, y’all
  • Make sure your component has PropTypes. These will be validated when the developer is in development environment and will also be used in storybook demos for documentation.
  • Use default props when appropriate
  • Write jsdocs for your component if you feel like it
  • Write tests, y’all

Development


As you develop, create a .story.js file for your component. You can view and test your component as you develop it by running npm run storybook and going to localhost:6006

Publish


Once finished, update the version of the package and npm publish

component-library-starter's People

Contributors

musicbender avatar

Watchers

James Cloos avatar  avatar

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.