Coder Social home page Coder Social logo

cogitovsmachina / react-bluekit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blueberryapps/react-bluekit

0.0 1.0 0.0 1.89 MB

Automatically generating a component library from your React components (ES5, ES6, Typescript)

Home Page: http://bluekit.blueberry.io

License: MIT License

JavaScript 98.73% HTML 0.76% Shell 0.51%

react-bluekit's Introduction

React BlueKit CircleCI Dependency Status

BlueKit usage

BlueKit automatically generates a library from your React components with editable props and live preview.

Point BlueKit to folders with your React components and it will generate a library for you. You'll be able to browse through the components, tweak their props, and see the changes live. Furthermore, any changes that you make to your components' code will be reflected in the library.

DEMO here: http://bluekit.blueberry.io

Install

$ npm install --save react-bluekit

You can use BlueKit via npm script or gulp

Npm script

"scripts": {
  "bluekit": "bluekit --baseDir ./components --paths . --exclude \"./(Layout|StyledComponent).tsx\""
}

Gulpfile configuration

import createBlueKit from 'react-bluekit/lib/createBlueKit';

createBlueKit({
  // your directory where components are located
  baseDir: `${__dirname}/src/browser`,
  // relative paths from base dir where to look for components
  paths: ['./components/', './auth'],
  // relative paths from base dir of files or directories you want to exclude from indexing
  exclude: ['./components/Foo'],
  // set to true when providing simple components such as `export default function MyComponent() { <div>Hello</div> }`
  noSpecialReplacements: true
});

This will provide you with two gulp tasks: build-bluekit and watch-bluekit, which perform static analysis of your components.

You can setup the build of BlueKit on application start and then watch components for changes by editing the default task to:

// from gulp.task('default', ['server']); to:
gulp.task('default', ['build-bluekit', 'server', 'watch-bluekit']);

Do not forget to add it to build process (for example on stage or production):

gulp.task('build', ['build-bluekit', 'build-webpack']);
// make sure that component build is before webpack

It will be built when needed.

Add it to your project

Look at the example directory, you only need to add:

import BlueKit from 'react-bluekit';
import componentsIndex from '../componentsIndex';
import React, { Component } from 'react';

export default class PageWithBlueKit extends Component {
  render() {
    return (
      <BlueKit
        componentsIndex={componentsIndex}

        // display inline (not full page)
        inline

        // this name is used for bluekit local storage as namespace
        // it is optional
        name="MyProjectName"
      />
    );
  }
}

You can also pass children to BlueKit, which will be displayed above the search field (e.g. for themes or other stuff).

To add jsdoc descriptions see example example_components/Checkbox.react.js.

Typescript support

Bluekit automatically finds .tsx files and uses react-docgen-typescript parser for it.

BlueKit development

npm install
cd ./example
npm install
gulp
open http://localhost:3000

This will start the development server and then you can play with components in BlueKit.

Gulp tasks

# generate svg icons from src/icons directory
gulp svg-icon

# run unit tests
gulp ava

# run eslint
gulp eslint

Additional info

BlueKit automatically hides props that don’t affect the component’s look.

If you get some kind of weird error and BlueKit doesn't load at all, try to reset localStorage by running localStorage.clear();.

Made with love by

react-bluekit's People

Contributors

apfelfabrik avatar coryhouse avatar georg77 avatar goldhand avatar honzabrecka avatar imtoo avatar jakubkottnauer avatar joshfarrant avatar lezuse avatar lupuszr avatar ondrejbartas avatar oscarbarrett avatar steida avatar tomaass avatar vaclavsir avatar

Watchers

 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.