Giter Club home page Giter Club logo

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 hrachos avatar imtoo avatar jakubkottnauer avatar joshfarrant avatar lezuse avatar lupuszr avatar ondrejbartas avatar oscarbarrett avatar steida avatar tomaass avatar vaclavsir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-bluekit's Issues

BluekitEvent is not a constructor JS Error

Getting this error when I click on a button being rendered in Bluekit:

Uncaught TypeError: BluekitEvent is not a constructor
    at dispatchEvent (componentsIndex.js?81bb:8)
    at onClick (componentsIndex.js?81bb:23)
    at HTMLUnknownElement.callCallback (react-dom.development.js?cada:1299)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?cada:1338)
    at Object.invokeGuardedCallback (react-dom.development.js?cada:1195)
    at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js?cada:1209)
    at executeDispatch (react-dom.development.js?cada:1432)
    at Object.executeDispatchesInOrder (react-dom.development.js?cada:1454)
    at executeDispatchesAndRelease (react-dom.development.js?cada:1969)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js?cada:1980)

Here's the Button component that Bluekit is rendering:

import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import './Button.scss';

const Button = (props) => {
  const classes = classNames('btn', props.color, { disabled: props.isDisabled });
  return <button className={classes} onClick={props.onClick}>{props.text}</button>;
};

// https://reactjs.org/docs/typechecking-with-proptypes.html
Button.propTypes = {
  text: PropTypes.string.isRequired,
  onClick: PropTypes.func.isRequired,
  color: PropTypes.oneOf(['green', 'blue']),
  isDisabled: PropTypes.bool,
};

// Specifies the default values for props:
Button.defaultProps = {
  color: 'green',
  isDisabled: false,
};

export default Button;

And here's my package.json

{
  "dependencies": {
    "@rails/webpacker": "^3.0.2",
    "babel-preset-react": "^6.24.1",
    "classnames": "^2.2.5",
    "node-persist": "^2.1.0",
    "prop-types": "^15.6.0",
    "react": "^16.0.0",
    "react-bluekit": "^0.4.3",
    "react-dom": "^16.0.0",
    "react-redux": "^5.0.6",
    "react-router-dom": "^4.2.2",
    "redux": "^3.7.2"
  },
  "devDependencies": {
    "eslint": "4.9.0",
    "eslint-config-airbnb": "16.1.0",
    "eslint-plugin-import": "2.8.0",
    "eslint-plugin-jsx-a11y": "6.0.2",
    "eslint-plugin-react": "7.4.0",
    "webpack-dev-server": "^2.9.3"
  },
  "scripts": {
    "bluekit": "bluekit --baseDir ./app/webpack --paths . --exclude \"((?!.*/components/)|.*/components/container/).*\""
  }
}

Problems creating docker image for app with bluekit

Hi! I'm having a bit of an issue ever since I installed bluekit on my project. I create docker images of my project for deployment and my base image doesn't have git. Thus, the image creation fails on the npm install because of this. Do you have any ideas on how to get over this? I guess I could just install git on my base image, but I'm trying to keep it lean. I also see the react-docgen-typescript is a fork, so I wonder what's different from the original (which has an npm package). Anyways, just trying to get some info, but I understand you might not want to do anything about this. Thanks!

Support for Redux Connect

Hi,

I have a React/Redux app for which I use bluekit. When I use redux's connect() function I get the error below (you'll also find my component's code after the error).

I did some digging and it seems react-docgen doesn't like the fact that I have my component and the component that's produced by calling connect. I installed react-docgen and it seems that if I use the findAllComponentDefinitions resolver, everything works. Is this something that can be added to bluekit, maybe as a flag?

Error parsing component connected/RadioPlayer/RadioPlayer.js: Multiple exported component definitions found. Error: Multiple exported component definitions found.
    at Context.exportDeclaration (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/react-docgen/dist/resolver/findExportedComponentDefinition.js:116:13)
    at Context.invokeVisitorMethod (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path-visitor.js:344:49)
    at Visitor.PVp.visitWithoutReset (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path-visitor.js:196:32)
    at NodePath.each (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path.js:101:26)
    at visitChildren (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path-visitor.js:219:18)
    at Visitor.PVp.visitWithoutReset (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path-visitor.js:204:20)
    at visitChildren (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path-visitor.js:246:25)
    at Visitor.PVp.visitWithoutReset (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path-visitor.js:204:20)
    at Visitor.PVp.visit (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path-visitor.js:133:29)
    at Object.visit (/Users/jarzuaga/Documents/development/workspace/univision-fe-new/node_modules/ast-types/lib/path-visitor.js:101:55)

This is my component's code:

import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import * as actions from 'app/store/actions/player-actions';

import Styles from './RadioPlayer.scss';

/**
  * RadioPlayer widget
  * @param {Object} props component props
  * @returns {JSX}
 */
export const RadioPlayerComponent = ({ playing, streamURL }) => {
  return (
    <div className={Styles.player}>
      {playing && <iframe className={Styles.iframe} title="radio" src={streamURL} />}
    </div>
  );
};

/**
 * propTypes
 * @property {boolean} playing whether or not the radio stream is playing
 * @property {String} streamURL the full URL of the Abacast stream player
 */
RadioPlayerComponent.propTypes = {
  playing: PropTypes.bool.isRequired,
  streamURL: PropTypes.string.isRequired,
};

/**
 * map app state to local props
 * @param  {Object} player the player state from app store
 * @returns {Object} the props to inject to the component
 */
export const stateToProps = ({ player }) => ({
  streamURL: player.abacastUrl,
  playing: player.playPerformance,
});

export default connect(stateToProps, actions)(RadioPlayerComponent);

Uncaught Error: invalid keyPath

Still cannot get this to work in our stack. This is what I get in Chrome console when I launch the bluekit app:

Uncaught Error: invalid keyPath
invariant @ immutable.js:872
updateInDeepMap @ immutable.js:1976
updateInDeepMap @ immutable.js:1982
updateInDeepMap @ immutable.js:1982
updateInDeepMap @ immutable.js:1982
Map.updateIn @ immutable.js:1280
(anonymous function) @ immutable.js:4420
BitmapIndexedNode.iterate.HashArrayMapNode.iterate @ immutable.js:1739
BitmapIndexedNode.iterate.HashArrayMapNode.iterate @ immutable.js:1739
Map.__iterate @ immutable.js:1377
reduce @ immutable.js:4415
render @ Sidebar.react.js:67
render @ enhancer.js:132
_renderValidatedComponentWithoutOwnerOrContext @ ReactCompositeComponent.js:687
_renderValidatedComponent @ ReactCompositeComponent.js:707
performInitialMount @ ReactCompositeComponent.js:291
mountComponent @ ReactCompositeComponent.js:222
mountComponent @ ReactReconciler.js:39
mountChildren @ ReactMultiChild.js:203
_createInitialChildren @ ReactDOMComponent.js:628
mountComponent @ ReactDOMComponent.js:474
mountComponent @ ReactReconciler.js:39
mountChildren @ ReactMultiChild.js:203
_createInitialChildren @ ReactDOMComponent.js:628
mountComponent @ ReactDOMComponent.js:474
mountComponent @ ReactReconciler.js:39
mountChildren @ ReactMultiChild.js:203
_createInitialChildren @ ReactDOMComponent.js:628
mountComponent @ ReactDOMComponent.js:474
mountComponent @ ReactReconciler.js:39
performInitialMount @ ReactCompositeComponent.js:297
mountComponent @ ReactCompositeComponent.js:222
mountComponent @ ReactReconciler.js:39
performInitialMount @ ReactCompositeComponent.js:297
mountComponent @ ReactCompositeComponent.js:222
mountComponent @ ReactReconciler.js:39
performInitialMount @ ReactCompositeComponent.js:297
mountComponent @ ReactCompositeComponent.js:222
mountComponent @ ReactReconciler.js:39
performInitialMount @ ReactCompositeComponent.js:297
mountComponent @ ReactCompositeComponent.js:222
mountComponent @ ReactReconciler.js:39
performInitialMount @ ReactCompositeComponent.js:297
mountComponent @ ReactCompositeComponent.js:222
mountComponent @ ReactReconciler.js:39
mountComponentIntoNode @ ReactMount.js:103
perform @ Transaction.js:136
batchedMountComponentIntoNode @ ReactMount.js:124
perform @ Transaction.js:136
batchedUpdates @ ReactDefaultBatchingStrategy.js:63
batchedUpdates @ ReactUpdates.js:97
_renderNewRootComponent @ ReactMount.js:277
_renderSubtreeIntoContainer @ ReactMount.js:354
(anonymous function) @ app.js:61
(anonymous function) @ main.js:8340
(anonymous function) @ main.js:8341
__webpack_require__ @ bootstrap dcb2e9c…:555
fn @ bootstrap dcb2e9c…:86
(anonymous function) @ bootstrap dcb2e9c…:578
__webpack_require__ @ bootstrap dcb2e9c…:555
(anonymous function) @ bootstrap dcb2e9c…:578
(anonymous function) @ bootstrap dcb2e9c…:578

Will be happy to provide any more info if needed.

Problems Passing Enumerable Prop Types From Component Index File

I recently started using your Bluekit project with some other developers that I work with, and we really enjoy it! One thing that I had trouble setting up was a propsDefinition for enumerable properties. I am trying to replicate the button component that is on the bluekit demo, but I’m unsure how to pass the enumerable values in the component index file. At the moment, it looks like this:

component-index

And they are being rendered as input fields instead of a select dropdown:

rendered-button

I have tried just using an array, instead of an array inside a String, but that did not seem to work either. The componentIndex.js file for this project is ignored, so I was unable to see how you guys were doing this for this project. My button component is defined as follows:

button-component

Do you have any idea what I am missing with this? Please let me know if you need any more information, and thank you for the help!

PropTypes in React 15.5 Support

In React v 15.5.0, Facebook extracted PropTypes from the base React scope and placed them into their own package - prop-types

Upon changing my code to support the new loading, Bluekit is showing every property as "custom"

Handle multiple exports?

Seems one cannot export multiple components from a single module. Is this by design? For example, in TestModule.js:

import React from 'react'

export class ThingOne extends React.Component {
  render () {
    return (
      <div>Thing one here!</div>
    )
  }
}

export class ThingTwo extends React.Component {
  render () {
    return (
      <div>Thing two here!</div>
    )
  }
}

yields the error Error parsing component Test/Test.js: Multiple exported component definitions found. A single export works as expected.

Is there a pattern for multiple exports I should be aware of?

Thanks!

Tons of errors trying to run example...

Lovely project! However it appears the example is way out of date - did a fresh install using just the example folder, and failed to produce anything. See attached.
errors

Add the ability to exclude files/folders from the build

Another minor request :)

It would be nice to have the ability to exclude files/folders when I run Bluekit. Kind of like how you're automatically excluding __test__ but maybe make that more configurable on a Gulp task level.

Thank you!

Components index generator cannot handle Windows paths

Components index generator, when run under Windows, improperly determines component's name and import path, because it assumes that the path separator is a forward slash. This results in syntactically invalid code being generated, such as:

import ..\components\ABC from '..\components\ABC.js'

defaultProps JS Warning

Getting this warning in Google Chrome console when viewing BlueKit component in the browser:

Warning: Setting defaultProps as an instance property on Select is not supported and will be ignored. Instead, define defaultProps as a static property on Select.

Here's my package.json

{
  "dependencies": {
    "@rails/webpacker": "^3.0.2",
    "babel-preset-react": "^6.24.1",
    "classnames": "^2.2.5",
    "node-persist": "^2.1.0",
    "prop-types": "^15.6.0",
    "react": "^16.0.0",
    "react-bluekit": "^0.4.3",
    "react-dom": "^16.0.0",
    "react-redux": "^5.0.6",
    "react-router-dom": "^4.2.2",
    "redux": "^3.7.2"
  },
  "devDependencies": {
    "eslint": "4.9.0",
    "eslint-config-airbnb": "16.1.0",
    "eslint-plugin-import": "2.8.0",
    "eslint-plugin-jsx-a11y": "6.0.2",
    "eslint-plugin-react": "7.4.0",
    "webpack-dev-server": "^2.9.3"
  },
  "scripts": {
    "bluekit": "bluekit --baseDir ./app/webpack --paths . --exclude \"((?!.*/components/)|.*/components/container/).*\""
  }
}

PropTypes generated by Object.keys are wrapped with double quotes

If I have a component that has a PropType of oneOf, the array is generated using Object.keys ie:

const icons = {
  trash: '...',
  tag: '...',
  tagMerge: '...',
  ...
};

Icon.propTypes = {
  icon: PropTypes.oneOf(Object.keys(icons)),
  ...
};

In BlueKit each icon in the enum dropdown is wrapped with double quotes, which stops the preview from working:

screen capture on 2017-12-20 at 10-14-52

I can see in the componentsIndex.js that it's been generated with the quotes:

propsDefinition: {icon:{type:{name:"enum",value:[{value:"\"trash\"",computed:false},{value:"\"tag\"",computed:false},{value:"\"tagMerge\"",computed:false} ...

Please look into it, thanks!

webpack

feature request, ability to use with webpack?

or maybe even just ability to use with npm scripts.

Console Warnings in Bluekit Example

When I launch the Bluekit Example (and also with my app) I get the following console warnings. Should I be concern?

warning.js:36 Warning: Unknown prop 'styles' on <div> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop
    in div (created by PropsTable)
    in div (created by PropsTable)
    in div (created by PropsTable)
    in PropsTable (created by PropsSidebar)
    in div (created by PropsSidebar)
    in div (created by PropsSidebar)
    in PropsSidebar (created by Page)
    in div (created by Page)
    in div (created by StyleRoot)
    in StyleRoot (created by Page)
    in Page (created by Content)
    in div (created by Content)
    in Content (created by Page)
    in div (created by Page)
    in div (created by StyleRoot)
    in StyleRoot (created by Page)
    in Page (created by StateProvider)
    in StateProvider (created by App)
    in App printWarning @ warning.js:36
warning.js:36 Warning: Failed prop type: Invalid prop 'name' of type 'string' supplied to 'SourceCode', expected 'object'.
    in SourceCode (created by Preview)
    in Preview (created by Page)
    in div (created by Page)
    in div (created by StyleRoot)
    in StyleRoot (created by Page)
    in Page (created by Content)
    in div (created by Content)
    in Content (created by Page)
    in div (created by Page)
    in div (created by StyleRoot)
    in StyleRoot (created by Page)
    in Page (created by StateProvider)
    in StateProvider (created by App)
    in App printWarning @ warning.js:36

PropTypes.shape support is missing.

PropsTable.react.js:127
Uncaught TypeError: data.getIn is not a function
    at RadiumEnhancer.renderPropTableRow (http://localhost:8080/dist/example.js:64575:24)
    at http://localhost:8080/dist/example.js:43414:47
    at BitmapIndexedNode.iterate.HashArrayMapNode.iterate (http://localhost:8080/dist/example.js:42135:25)
    at Map.__iterate (http://localhost:8080/dist/example.js:41773:33)
    at http://localhost:8080/dist/example.js:41620:17
    at Map.withMutations (http://localhost:8080/dist/example.js:41751:8)
    at Array.map (native)
    at RadiumEnhancer.render (http://localhost:8080/dist/example.js:64549:26)
    at RadiumEnhancer.render (http://localhost:8080/dist/example.js:45627:66)
    at measureLifeCyclePerf (http://localhost:8080/dist/example.js:23563:13)

Please add browser support to readme

Would be handy to list supported browsers right on the readme, so folks will know whether they can use this when evaluating options. Some folks are unfortunately still stuck with users on older versions of IE11 (See #130).

Thanks!

Hide Certain Prop Variant

First of, awesome framework! We have chosen Bluekit to showcase our React components to all the developers that will be working on our app. Is there a way to hide certain prop variant from the UI? Let's say I have a propType htmlFor which either contains a string or not, and I would like to hide that from UI.

Thanks in advance :)

Cannot find module 'react-bluekit/lib/createBlueKit'

Not sure if it's a version issue with node/npm or package issue. I ran 'example' from the repo. Installed dependencies with yarn. But error occurred after I ran 'gulp'

> [email protected] gulp D:\projects\example
> gulp "watch"

module.js:471
    throw err;
    ^

Error: Cannot find module 'react-bluekit/lib/createBlueKit'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\projects\example\gulpfile.js:5:65)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Node/NPM versions

D:\projects\example>node --version
v6.10.0

D:\projects\example>npm --version
5.7.1

Set up default examples for components

I was thinking of using BlueKit as an interactive documentation tool for an internally-used library of components. However, many components look plain or completely blank until props/children are set, or the description isn't sufficient to describe how the component should work.

To this end, I think it would be useful if I could write examples in the JSDoc comments, with the first example being the default-display for the component within BlueKit. Something along the lines of:

/**
 * Renders a button.
 * 
 * @example Rounded corners
 * <Button style="rounded" onClick={ () => alert('clicked') }>
 *   Press me
 * </Button>
 *
 * @example No background
 * <Button style="ghost" onClick={ () => alert('clicked') }>
 *   Press me
 * </Button>
 */

That's a simple demonstration of what I mean, these examples would allow default children and props to be defined for the initial display of a component. The text after @example would be added to a select box, with the content up until the end or next @ tag being used to pre-populate the props/children.

Context doesn't seem to always work

So I'm trying to use react-bluekit with redux-form, which utilizes context to propagate a decorated component and it's props to children.

I've wrapped the whole <BlueKit/> component in a connected form and rendering the initial view works flawlessly. When going to any specific component via sidebar though, context seems to get lost and redux-form throws at

if (!context._reduxForm) {
   throw new Error('Field must be inside a component decorated with reduxForm()');
}

How comes?

Error running example

Getting:

ERROR in ./src/componentsIndex.js
Module not found: Error: Cannot resolve module 'react-bluekit/lib/libraries/BluekitEvent' in .../react-bluekit/example/src

In componentsIndex.js:
const BluekitEvent = require('react-bluekit/lib/libraries/BluekitEvent');

Adding the local module as a dependency gets rid of the error.

Sharing proptypes between components

I have some common proptypes that I want to maintain in a single place as a constant:

export default const PROPTYPE_THEME = PropTypes.oneOf([
    'default', 'primary', 'white', 'blue', 'purple', 'pink', 'orange', 'green', 'red'
]);

If I add more themes, I only need to edit this one file and not every component. However, I can no longer change it in BlueKit, because it's detected as a "custom" property. It would be handy if BlueKit could either:

  • Trace the variable back to its declaration (through imports) to see if it's a PropType declaration; or
  • Add a codeblock for modifying "custom" PropTypes.

Use other components as children

If I set propTypes.children to PropTypes.node.isRequired, I should be able to type a child component into the children* input. For example, let's say I have a TabStrip and TabPanel component that work together like this:

<TabStrip>
  <TabPanel link="Tab 1">
     ...tab content
  </TabPanel>
</TabStrip>

This is difficult to preview in BlueKit because <TabPanel> isn't accessible when entered into the children* input.

IE11: Object doesn't support property or method 'contains'

Getting this error when running the demo page with Internet Explorer 11 (demo page: http://bluekit.blueberry.io/demo). Click on any element in the sidebar to reproduce what you can see below:

screen shot 2017-11-28 at 3 06 25 pm

It's pointing to this line of code:

if (!area.contains(evt.target) && !pickerButton.contains(evt.target) && this.state.displayColorPicker) {

On the demo site my debugger claims both area and pickerButton are undefined, but in the app I'm developing on my own, both of these are defined, and pickerButton seems to be an SVG element, which may be the trouble. IE has supported Node.prototype.contains since IE 5: https://developer.mozilla.org/en-US/docs/Web/API/Node/contains#Browser_compatibility

Thanks in advance!

EDIT: Looks like it is related to pickerButton being an SVGElement. You can try this in your console on IE11 (while running the demo page linked to above): document.querySelector('svg').contains, which returns undefined. Try the same in Chrome and it returns the native contains function.

watch-bluekit exits immediately

I'm using gulp version 3.9.1.

Task:

gulp.task('default', ['build-bluekit', 'watch-bluekit']);

BlueKit config:

let componentDirs = fs.readdirSync('components').filter(function(file) {
  return fs.statSync(path.join('components', file)).isDirectory();
});

const pathsArray = componentDirs.map((dir) => `./${dir}`);
const baseDir = `${__dirname}/components`;

createBlueKit({
  baseDir: baseDir,
  paths: pathsArray,
  noSpecialReplacements: true
});

Output:

$ gulp                                                                                                                                                                                                         
[11:15:23] Requiring external module babel-register
[11:15:24] Using gulpfile gulpfile.babel.js
[11:15:24] Starting 'build-bluekit'...
Rebuilding BlueKit
BlueKit generated components index to file: components/componentsIndex.js
[11:15:25] Finished 'build-bluekit' after 79 ms
[11:15:25] Starting 'watch-bluekit'...
Watching BlueKit in and automatically rebuilding on paths:
components/Test/**/*.js
[11:15:25] Finished 'watch-bluekit' after 10 ms

Updating the task definition to include a callback param seems to fix the issue. i.e. at src/createBlueKit.js#L128:

gulpRuntime.task(watchCommandName, (callback) => {
  watch();
})

Can't navigate to specific component from 'All Components' page

Steps to reproduce

  1. Start in 'All components' view.
  2. Click on link to a specific component
  3. Note the error in the console.

The error I'm seeing is as follows:

Uncaught TypeError: BluekitEvent is not a constructor

which comes from this line.

Running latest version from npm (0.4.0-typescript05)

Let me know if you'd like any more info 👍

createBlueKit for component in defaultProps

BmFormControlLabel.defaultProps = {
    disabled: false,
    label: 'This is label text',
    name: '',
    control: <BmCheckbox color="primary"/> //In this place i get an error 'Unexpected token < SyntaxError: Unexpected token <'
};

Custom logo / theme

Great project!

My team and I are trying out Bluekit and we are really liking it so far.
I was wondering if there's a way we can personalize it more in terms of visuals, so things like:

  • The ability to pass our logo
  • Maybe pass a custom theme (colors, layout, fonts, etc)

Thanks!

Support for contextTypes

I'm using context to theme components in my library. Can support be added for modifying context props?

Add ability to annotate a component and have that comment display in interface as notes

I believe it would be useful to display a 'notes' section in the component interface which can be used to add relevant component usage notes to clarify details about component usage.

For example; let's say I write a simple Button component that takes an optional href prop which, if supplied, will render the same button as an <a> tag with the given href, rather than as a <button>. This information isn't immediately obvious to a new user looking at the list of props for this component for the first time. Currently information like this would have to be included in the project README, which is fine, but means the user needs to check elsewhere to find out all of the relevant information. I think there's room in BlueKit for this information.

I'd imagine this would be implemented so that we could annotate the component file with a comment, perhaps in a standardised format, which would then be displayed as notes alongside the component props in BlueKit.

Maybe something like...

import React, { PropTypes, Component } from 'react';

/** bluekit:notes
 * Button takes an optional 'href' prop which, if supplied, renders
 * an <a> tag, rather than a <button>.
 */

class Button extends Component {

// ...

image

What do you guys think about this?

Console warnings relating to PropsTable

I'm receiving the following errors when running the project:

Warning: Input: key is not a prop. Trying to access it will result in undefined being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://fb.me/react-special-props)

Warning: Using Maps as children is not yet fully supported. It is an experimental feature that might be removed. Convert it to a sequence / iterable of keyed ReactElements instead. Check the render method of PropsTable.

Neither seem to be causing any concrete issues, however I am seeing odd behaviour with the enum dropdowns.

Run via npm script

Can this be set up and run via an npm script instead of Gulp? Would be handy for those not using Gulp.

How do I upgrade react-docgen-typescript dependency for this package

I can see latest version of react-docgen-typescript is v1.0.2, but in this library I can see 0.0.1-m01 version being used which is not working for react functional components. Let me know if there is any plan to upgrade to latest version OR how will I do it for my current project

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.