0.0.11 • Published 6 months ago

react-connect-line v0.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

react-connect-line

You can match your react components by connecting the dots with lines.

Screenshot

Installation

npm install react-connect-line

Usage

import { useState, useEffect } from "react";
import { ConnectLine, ItemsProps } from 'react-connect-line';

function App() {
  const [items, setItems] = useState<ItemsProps[]>([]);
  const [isCorrectMatch, setIsCorrectMatch] = useState(false);

  useEffect(() => {
    const items = [
      {
        source: { text: "one" },
        target: { text: "1" },
      },
      {
        source: { text: "two" },
        target: { text: "2" },
      },
      {
        source: { text: "three" },
        target: { text: "3" },
      },
    ];

    setItems(items);
  }, []);

  console.log(isCorrectMatch);

  return (
    <ConnectLine
      items={items}
      setIsCorrectMatch={setIsCorrectMatch}
      containerSize={800}
      lineColor="orange"
      lineWidth={10}
      dotColor="orange"
      dotSize={46}
      fontSize={24}
    />
  );
}

export default App;

Props

PropDescriptionTypeDefault
itemsContents to connect with a lineItemsProps[]required
isLayoutUpAndDownWhether the source and target are placed top and bottombooleanfalse
setIsCorrectMatchA function to store information about whether the source and target are correctly pairedReact.Dispatch<React.SetStateAction>undefined
containerSizeSize of the ConnectLine component (height if the layout is top or bottom, width if the layout is on both sides)number100%
lineColorColor of the line connecting the dotsstringblack
lineWidthWidth of the line connecting the dotsnumber10
dotColorColor of the dotstringblack
dotSizeSize of the dot (width and height are the same)number46
textColorColor of the item's textstringblack
fontSizeSize of the item's textnumber50
imageSizeSize of the item's imagenumber300

Contributing

Contributions are always welcome!

License

MIT

0.0.10

6 months ago

0.0.11

6 months ago

0.0.9

7 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago