All Projects → snaerth → Create React Component Folder

snaerth / Create React Component Folder

Licence: mit
Creates react component folder structure

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Create React Component Folder

react-circle-flags
🚀 A React component with a collection of 300+ minimal circular SVG country flags. Wrapper of HatScripts/circle-flags
Stars: ✭ 29 (-79.14%)
Mutual labels:  react-component, npm-package
React Router Util
Useful components and utilities for working with React Router
Stars: ✭ 320 (+130.22%)
Mutual labels:  npm-package, react-component
react-windows-ui
Build Windows fluent UI apps using ReactJS. Provides a set of accessible, reusable, and composable React components that make it super easy to create websites and apps.
Stars: ✭ 383 (+175.54%)
Mutual labels:  react-component, npm-package
React Sticky El
Stars: ✭ 179 (+28.78%)
Mutual labels:  npm-package, react-component
React Use Api
Async HTTP request data for axios. Designed for diverse UI states, SSR and data pre-caching.
Stars: ✭ 49 (-64.75%)
Mutual labels:  create-react-app, npm-package
modular
Scaffold a react monorepo and its component parts.
Stars: ✭ 13 (-90.65%)
Mutual labels:  create-react-app, scaffold
react-native-value-picker
Cross-Platform iOS(ish) style picker for react native.
Stars: ✭ 18 (-87.05%)
Mutual labels:  react-component, npm-package
React Bnb Gallery
Simple react-based photo gallery inspired by Airbnb image gallery.
Stars: ✭ 145 (+4.32%)
Mutual labels:  create-react-app, npm-package
Reactprimer
React component prototyping tool that generates fully connected class component code.
Stars: ✭ 743 (+434.53%)
Mutual labels:  create-react-app, react-component
React Extras
Useful components and utilities for working with React
Stars: ✭ 651 (+368.35%)
Mutual labels:  npm-package, react-component
Reactopt
A CLI React performance optimization tool that identifies potential unnecessary re-rendering
Stars: ✭ 1,975 (+1320.86%)
Mutual labels:  npm-package, react-component
React Ckeditor
CKEditor component for React with plugin and custom event listeners support
Stars: ✭ 124 (-10.79%)
Mutual labels:  npm-package, react-component
react-daterange-picker
A react date range picker to using @material-ui. Live Demo: https://flippingbitss.github.io/react-daterange-picker/
Stars: ✭ 85 (-38.85%)
Mutual labels:  react-component, npm-package
React Pro Sidebar
Customizable and responsive react sidebar library with dropdown menus and unlimited number of nested submenus
Stars: ✭ 359 (+158.27%)
Mutual labels:  npm-package, react-component
Cra Generate
Scaffold a React component.
Stars: ✭ 78 (-43.88%)
Mutual labels:  create-react-app, scaffold
Create React Microservice
🚀 Create highly scalable and universal React microservices/applications within seconds.
Stars: ✭ 138 (-0.72%)
Mutual labels:  create-react-app, scaffold
Multi Auth
Laravel Multi-Authentication Package
Stars: ✭ 131 (-5.76%)
Mutual labels:  scaffold
Cra Serverless
Serverless pre-rendering (SSR) for React SPA using AWS Lambda, S3, and CloudFront.
Stars: ✭ 137 (-1.44%)
Mutual labels:  create-react-app
Subway Shanghai
🚆上海地铁线路图PWA,支持离线使用,强烈建议安装Chrome浏览器使用。Subway Shanghai, offline first, it's strongly recommended to use by Chrome.
Stars: ✭ 130 (-6.47%)
Mutual labels:  create-react-app
React Responsive Carousel
React.js Responsive Carousel (with Swipe)
Stars: ✭ 1,962 (+1311.51%)
Mutual labels:  react-component

Create React Component folder

NPM version NPM downloads

About

Create React Component folder works on macOS, Windows, and Linux.
It creates React or React Native component folder structure with one command.
There is also support for Typescript, React Native, Less and Sass.

Quick Overview

$ npm install --save-dev create-react-component-folder
$ npx crcf myComponent

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

npx crcf myComponent

Tutorial

Read the artice on Medium

Installation

$ npm install --save-dev create-react-component-folder

Creating a single component

$ npx crcf myComponent
$ npx crcf components/myComponent

Output single

Creating multiple components

$ npx crcf components/header footer button navigation

Output multiple

Component folder structure

myComponent
├── index.js
├── myComponent.js
├── myComponent.css
├── myComponent.test.handlebars

With storybook enabled

myComponent
├── index.js
├── myComponent.js
├── myComponent.css
├── myComponent.test.handlebars
├── myComponent.stories.js

Setting default config

There is support for setting default config options, so you only have to set you desired config once. This makes creating your components even easier. All you have to do is follow one of these three options.

In your package.json, add a "crcf" property key with array of default config options

"stories" is to enable story book component

"spec" to have the file extensions

"crcf": [
  "scss",
  "proptypes",
  "stories",
  "spec"
]

Create a rc file named .crcfrc in the root of your project and insert a array of default config options in that file

[
  "scss",
  "proptypes",
  "stories"
]

Create a config file named .crcf.config.js in the root of your project and insert a array of default config options

[
  "scss",
  "proptypes"
  "stories"
]

So now all you have to do is type npx crcf componentName and you will get all your default options when you create a component or multiple components. Here below you can see all the options.

[
  "typescript",
  "scss",
  "less",
  "nocss",
  "notest",
  "reactnative",
  "createindex",
  "uppercase",
  "jsx",
  "proptypes",
  "stories",
  "nosemi",
  "singlequote",
  "cssmodules",
  "namedexports",
  "graphql",
  "stylesext",
  {
    "output": "base/directory/to/place/created/components"
  }
]

Creating index.js file for multiple component imports

$ npx crcf --createindex components/myComponent/

Output in index.js file for multiple component imports

Publishing templates

If the project you are working on always needs components structured differently, we've got you covered.

Publishing the templates allows you to have finer control over the generated components and content. Published templates use [https://handlebarsjs.com/] to generate the different components.

$ npx crcf publish-templates

The templates will be copied to a directory .crcf/templates relative to the directory you ran the script from.

Modifying templates

Templates are always passed a number of variables to help you generate templates when certain flags / config options have been enabled.

Variable Type Description
name string The generated name of the component
typescript boolean true when typescript is enabled
native boolean true when building react native components
proptypes boolean true when proptypes is enabled
export boolean true when namedexports is enabled

Tests and stories have extra variables (NOT available in functional or class component templates)

Variable Type Description
nameLowercase string The generated name of the component in lowercase so it can be interpolated in sentences.
uppercase boolean true when uppercase is enabled

Options

$ npx crcf create --help

  Usage: index [options]

  Options:

    -V, --version       output the version number
    --typescript        Creates Typescript component and files
    --nocss             No css file
    --notest            No test file
    --cssmodules        Creates css/less/scss file with .module extensions. Example
    --reactnative       Creates React Native components
    --createindex       Creates index.js file for multple component imports
    --graphql           Creates a index.graphql file
    --stylesext         Creates a Component.styles.(ts|js) file
    -f, --functional    Creates React stateless functional component
    -j, --jsx           Creates the component file with .jsx extension
    -l, --less          Adds .less file to component
    -s, --scss          Adds .scss file to component
    -p, --proptypes     Adds prop-types to component
    -u, --uppercase     Component files start on uppercase letter
    -h, --help          output usage information
    -sb, --stories      Add Storie file to component
    -ns, --nosemi       No semicolons
    -sq, --singlequote  Formats output files with single quotes
    -x, --namedexports  Creates files using named exports

Author

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].