# react-lineto

> Draw a line between two elements in React.

Latest version **3.3.0** (published 2021-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-lineto
pnpm add react-lineto
yarn add react-lineto
bun add react-lineto
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.0 |
| Published | 2021-10-15 |
| First published | 2017-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 484.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 232 |
| Author | Kevin DeLoach |
| Maintainers | kdeloach |

## Links

- npm: https://www.npmjs.com/package/react-lineto
- Repository: https://github.com/kdeloach/react-lineto
- Issues: https://github.com/kdeloach/react-lineto/issues
- npm.io page: https://npm.io/package/react-lineto

## Dependencies (2)

- [react](https://npm.io/package/react.md) 17.0.2
- [prop-types](https://npm.io/package/prop-types.md) 15.7.2

## Recent versions

- 3.3.0 (latest) — 2021-10-15
- 3.2.1 — 2021-06-01
- 3.2.0 — 2020-05-04
- 3.1.4 — 2020-03-30
- 3.1.3 — 2019-02-02
- 3.1.2 — 2018-05-17
- 3.1.1 — 2018-04-24
- 3.1.0 — 2018-04-16
- 3.0.0 — 2018-02-21
- 2.1.0 — 2018-02-21
- 2.0.0 — 2018-01-04
- 1.2.0 — 2017-03-04
- 1.1.1 — 2017-03-04
- 1.1.0 — 2017-03-04
- 1.0.1 — 2017-03-02
- … 1 more at https://npm.io/package/react-lineto/versions

## README

# react-lineto

Draw a line between two elements in React.

[![Build Status](https://app.travis-ci.com/kdeloach/react-lineto.svg?branch=master)](https://app.travis-ci.com/kdeloach/react-lineto)

## Getting Started

```
yarn install
yarn run demo
```

Browse to [localhost:4567](http://localhost:4567).

## Demo

![Demo](https://github.com/kdeloach/react-lineto/raw/master/preview.png)

## Components

* [LineTo](#lineto)
* [SteppedLineTo](#steppedlineto)
* [Line](#line)

### LineTo

Draw line between two DOM elements.

#### Example

```
import LineTo from 'react-lineto';

function render() {
    return (
        <div>
            <div className="A">Element A</div>
            <div className="B">Element B</div>
            <LineTo from="A" to="B" />
        </div>
    );
}
```
If using multiple instances of `<LineTo />` inside separate components, you must provide a unique key for each of the container divs.


#### Properties

| Name        | Type   | Description                                    | Example Values
| ----------- | ------ | ---------------------------------------------- | --------------
| borderColor | string | Border color                                   | `#f00`, `red`, etc.
| borderStyle | string | Border style                                   | `solid`, `dashed`, etc.
| borderWidth | number | Border width (px)                              |
| className   | string | Desired CSS className for the rendered element |
| delay       | number or bool | Force render after delay (ms)          | `0`, `1`, `100`, `true`
| fromAnchor  | string | Anchor for starting point (Format: "x y")      | `top right`, `bottom center`, `left`, `100% 0`
| from\*      | string | CSS class name of the first element            |
| toAnchor    | string | Anchor for ending point (Format: "x y")        | `top right`, `bottom center`, `left`, `100% 0`
| to\*        | string | CSS class name of the second element           |
| within      | string | CSS class name of the desired container        |
| zIndex      | number | Z-index offset                                 |

\* Required

### SteppedLineTo

Draw stepped line between two DOM elements.

#### Example

```
import { SteppedLineTo } from 'react-lineto';

function render() {
    return (
        <div>
            <div className="A">Element A</div>
            <div className="B">Element B</div>
            <SteppedLineTo from="A" to="B" orientation="v" />
        </div>
    );
}
```

#### Properties

| Name        | Type   | Description                                    | Example Values
| ----------- | ------ | ---------------------------------------------- | --------------
| borderColor | string | Border color                                   | `#f00`, `red`, etc.
| borderStyle | string | Border style                                   | `solid`, `dashed`, etc.
| borderWidth | number | Border width (px)                              |
| className   | string | Desired CSS className for the rendered element |
| delay       | number or bool | Force render after delay (ms)          | `0`, `1`, `100`, `true`
| fromAnchor  | string | Anchor for starting point (Format: "x y")      | `top right`, `bottom center`, `left`, `100% 0`
| from\*      | string | CSS class name of the first element            |
| orientation | enum   | "h" for horizonal, "v" for vertical            | `h` or `v`
| toAnchor    | string | Anchor for ending point (Format: "x y")        | `top right`, `bottom center`, `left`, `100% 0`
| to\*        | string | CSS class name of the second element           |
| within      | string | CSS class name of the desired container        |
| zIndex      | number | Z-index offset                                 |

\* Required

### Line

Draw line using pixel coordinates (relative to viewport).

#### Example

```
import { Line } from 'react-lineto';

function render() {
    return (
        <Line x0={0} y0={0} x1={10} y1={10} />
    );
}
```

#### Properties

| Name        | Type   | Description                                    | Example Values
| ----------- | ------ | ---------------------------------------------- | --------------
| borderColor | string | Border color                                   | `#f00`, `red`, etc.
| borderStyle | string | Border style                                   | `solid`, `dashed`, etc.
| borderWidth | number | Border width (px)                              |
| className   | string | Desired CSS className for the rendered element |
| within      | string | CSS class name of the desired container        |
| x0\*        | number | First X coordinate                             |
| x1\*        | number | Second X coordinate                            |
| y0\*        | number | First Y coordinate                             |
| y1\*        | number | Second Y coordinate                            |
| zIndex      | number | Z-index offset                                 |

\* Required

## Release Checklist

1. Bump version in `package.json`
1. Update `CHANGELOG.md`
1. Run `yarn build` or `./scripts/update`
1. Create version commit (ex. "2.0.0")
1. Create matching tag (ex. "2.0.0")
1. Push `master` branch and tags to origin
1. Verify Travis CI published NPM package

---
_Source: https://npm.io/package/react-lineto · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
