0.0.1 • Published 3 years ago

react-lineto-ts v0.0.1

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

react-lineto-ts

Draw a line between two elements in React.

Getting Started

yarn
yarn dev

Browse to localhost:3000.

Components

LineTo

Draw line between two DOM elements.

Example

import LineTo from 'react-lineto-ts';

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

NameTypeDescriptionExample Values
borderColorstringBorder color#f00, red, etc.
borderStylestringBorder stylesolid, dashed, etc.
borderWidthnumberBorder width (px)
classNamestringDesired CSS className for the rendered element
fromAnchorstringAnchor for starting point (Format: "x y")top right, bottom center, left, 100% 0
from*stringCSS class name of the first element
toAnchorstringAnchor for ending point (Format: "x y")top right, bottom center, left, 100% 0
to*stringCSS class name of the second element
zIndexnumberZ-index offset

* Required

SteppedLineTo

Draw stepped line between two DOM elements.

Example

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

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

NameTypeDescriptionExample Values
borderColorstringBorder color#f00, red, etc.
borderStylestringBorder stylesolid, dashed, etc.
borderWidthnumberBorder width (px)
classNamestringDesired CSS className for the rendered element
fromAnchorstringAnchor for starting point (Format: "x y")top right, bottom center, left, 100% 0
from*stringCSS class name of the first element
orientationenum"h" for horizontal, "v" for verticalh or v
toAnchorstringAnchor for ending point (Format: "x y")top right, bottom center, left, 100% 0
to*stringCSS class name of the second element
zIndexnumberZ-index offset

* Required

Line

Draw line using pixel coordinates (relative to viewport).

Example

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

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

Properties

NameTypeDescriptionExample Values
borderColorstringBorder color#f00, red, etc.
borderStylestringBorder stylesolid, dashed, etc.
borderWidthnumberBorder width (px)
classNamestringDesired CSS className for the rendered element
x0*numberFirst X coordinate
x1*numberSecond X coordinate
y0*numberFirst Y coordinate
y1*numberSecond Y coordinate
zIndexnumberZ-index offset

* Required