Giter Site home page Giter Site logo

daz2345 / plop-react-ts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raphaelblehoue/plop-react

0.0 1.0 1.0 125 KB

A plop generator for creating React components in accordance with SG guidelines

License: MIT License

JavaScript 86.24% HTML 13.76%

plop-react-ts's Introduction

plop-react-ts

A plop generator for creating React components with specific structure. It allows to create 2 kind of React components:

  • React Component: Simple component with the following folder structure:
    • <Component name>.{jsx|tsx}
    • <Component name>.{scss|css}
    • <Component name>.test.{jsx|tsx}
    • index.{jsx|tsx}
  • React Container (or View): Component with the boilerplate for mapping application state to component's props by using Redux (mapStateToProps & mapDispatchToProps).
    • <Component name>.container.{jsx|tsx}
    • <Component name>.{jsx|tsx}
    • <Component name>.{scss|css}
    • <Component name>.test.{jsx|tsx}
    • index.{jsx|tsx}

For each one of these 2 kind of component, you can choose:

  • which React component to use: PureComponent Class, Component Class and Stateless Function
  • to use ReactI18n or not (multilingualism)
  • to use Storybook or not (Component Explorer)

See Examples

Get Started

Installation

  1. Add Plop to your project
$ npm install --save-dev plop
  1. Add Plop-react to your project
$ npm install --save-dev @sgfastit/plop-react
  1. Create a plopfile.js at the root of your project
module.exports = function (plop) {
	// Load plop react here
  plop.load('plop-react');

  // You can load other plop module or define your own plop generators or helpers, here
};
  1. Add script inside your package.json, for running plop generator
"plops":"plop --plopfile plopfile.js"
  1. Now you can use it, by running
yarn plops

yarn plop-react

Configuration

Default confguration

By default, Plop-react has default configurations:

{
  componentsPath: './source/components',    		// default location for components
  containersPath: './source/containers',    		// default location for containers
  defaultComponentName: 'Button',           		// default name for component
  defaultContainerName: 'Icon',             		// default name for containers
  defaultComponentType: 'PureComponent Class',  	// use PureComponent Class by default
  useTypescript: true,                   		// create Typescript files
  useReactI18nByDefault: true,              		// use ReactI18n by default
  useReduxByDefault: false,				// use Redux files by default  
  useScssByDefault: true,				// use SCSS files by default
};

How to overwrite default configuration

You can overwrite the whole default configuration (or only some properties) by yours when you load plop-react inside your plop-file.js.

module.exports = function(plop) {
  // Load plop react here and overwrite default configuration
  plop.load('plop-react', {
    componentsPath: './src/components',
    containersPath: './src/views',
    defaultComponentName: 'Component',
    defaultComponentType: 'PureComponent Class',
    useTypescriptByDefault: false,
  });
};

plop-react-ts's People

Contributors

msalettes avatar daz2345 avatar

Watchers

James Cloos avatar

Forkers

lastoftype

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.