0.4.1 • Published 7 years ago

react-connect-the-dots v0.4.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

react-connect-the-dots

NPM version NPM downloads Build Status codecov Dependency Status

Positions an component connector between two components. Wrap a from and to component, give them a pair name, and customise the line as you see fit. Explicitly a client side only solution.

Installation

npm install react-connect-the-dots

Usage

<Dot />

You can wrap components in a Dot to draw a connector between them. Each connector pair should only have two Dots, if you try to add more an exception will be thrown.

Dots can be nested! Only the deepest Dot needs a function as children.

import Dot from 'react-connect-the-dots';

const CustomComponent = ({ getRef }) => (
  <div ref={getRef}>hello</div>
);

const App = () => (
  <div className="relative-position-container">

    <Dot pair="a-b" connector={(props) => <div className="sweet-line" {...props} />}>
      {(ref) => <CustomComponent className="position-top-left" getRef={ref} />}
    </Dot>

    <Dot pair="b-c" connector={(props) => <div className="sweet-line thicc" {...props} />}>
      <Dot pair="a-b">
        {(ref) => <CustomComponent className="position-bottom-left" getRef={ref} />}
      </Dot>
    </Dot>

    <Dot pair="b-c">
      {(ref) => <CustomComponent className="position-bottom-right" getRef={ref} />}
    </Dot>
  </div>
);
proptyperequireddescription
pairstringyesThe name that each dot pair will share.
connector(props) => NodenoThe connector to be drawn between dots. This can be on all, one, or none for a Dot pair.
children(ref) => Node or Dotyes

React Story Book

To run the component in various modes, run the following command then go to http://localhost:6006/.

npm start

Testing

npm test
0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago