All Projects â†’ rescriptbr â†’ react-flow

rescriptbr / react-flow

Licence: MIT license
ReScript bindings for React Flow 🚀

Programming Languages

ReScript
86 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to react-flow

ancestor
💀 UI primitives for ReScript and React
Stars: ✭ 144 (+323.53%)
Mutual labels:  rescript-bindings, rescript-react
rescript-ink
ReScript bindings for Ink
Stars: ✭ 52 (+52.94%)
Mutual labels:  rescript-bindings, rescript-react
comece-aqui
🚀 Quer aprender ReScript? Comece aqui
Stars: ✭ 214 (+529.41%)
Mutual labels:  rescript-bindings, rescript-react
reform
📋 Reasonably making forms sound good
Stars: ✭ 345 (+914.71%)
Mutual labels:  rescript-react
paper
ReScript bindings for react-native-paper
Stars: ✭ 14 (-58.82%)
Mutual labels:  rescript-react
vite-plugin-rescript
Integrate ReScript with Vite seamlessly
Stars: ✭ 56 (+64.71%)
Mutual labels:  rescript-react
app-template-rescript-react
Adding ReScript with rescript-react on top of @snowpack/app-template-react
Stars: ✭ 44 (+29.41%)
Mutual labels:  rescript-react
kuwala
Kuwala is the no-code data platform for BI analysts and engineers enabling you to build powerful analytics workflows. We are set out to bring state-of-the-art data engineering tools you love, such as Airbyte, dbt, or Great Expectations together in one intuitive interface built with React Flow. In addition we provide third-party data into data sc…
Stars: ✭ 474 (+1294.12%)
Mutual labels:  react-flow
prismaliser
Visualise your Prisma schema!
Stars: ✭ 230 (+576.47%)
Mutual labels:  react-flow
rescript-react-boilerplate
An opinionated app shell for ReScript & React progressive web apps
Stars: ✭ 62 (+82.35%)
Mutual labels:  rescript-react
rescript-date
📆 Date manipulation in ReScript.
Stars: ✭ 101 (+197.06%)
Mutual labels:  rescript-react
template
ReScript React Native template
Stars: ✭ 17 (-50%)
Mutual labels:  rescript-react


ReScript React Flow

React Flow bindings for ReScript.

Installation

  1. Install @rescriptbr/react-flow using npm:
npm install --save @rescriptbr/react-flow

or yarn:

yarn add @rescriptbr/react-flow
  1. Add @rescriptbr/react-flow as dependency to your bsconfig.json:
{
  "name": "your-project",
  "bs-dependencies": ["@rescriptbr/react-flow"]
}

Examples

Check the code below for fast basic examples:

Creating a simple Node

 ReactFlow.Types.Node(
    ReactFlow.Node.makeNode(
      ~id="1",
      ~position={x: 250, y: 0},
      ~data=ReactFlow.Node.toData({"label": React.string("test")}),
      ~type_="input",
      (),
    ),
  ),

Creating a simple Edge

ReactFlow.Types.Edge(
    ReactFlow.Edge.makeEdge(
      ~id="e1-2",
      ~source="1",
      ~target="2",
      ~label="this is an edge label",
      ~data=ReactFlow.Edge.toData("some other data"),
      (),
    ),
  ),

Creating elements array

let elements = [
  ReactFlow.Types.Edge(
    ReactFlow.Edge.makeEdge(
      ~id="e1-2",
      ~source="1",
      ~target="2",
      ~label="this is an edge label",
      ~data=ReactFlow.Edge.toData("some other data"),
      (),
    ),
  ),
  ReactFlow.Types.Node(
    ReactFlow.Node.makeNode(
      ~id="1",
      ~position={x: 250, y: 0},
      ~data=ReactFlow.Node.toData({"label": React.string("test")}),
      ~type_="input",
      (),
    ),
  ),
]

Rendering React Flow

@react.component
let make = () => {
  let (elems, setElems) = React.useState(() => elements)
  let onElementsRemove = elementsToRemove => {
    setElems(elems => ReactFlow.Utils.removeElements(elementsToRemove, elems))
  }

  let onConnect = newEdgeParams => {
    setElems(elems => ReactFlow.Utils.addEdge(newEdgeParams, elems))
  }

  <div className="App" style={ReactDOM.Style.make(~height="800px", ~width="1200px", ())}>
    <ReactFlow
      elements={elems->ReactFlow.Utils.elementsToRaw}
      onElementsRemove
      onConnect
      onLoad
      snapToGrid=true
      snapGrid=(15, 15)>
      <ReactFlow.Controls />
      <ReactFlow.Background variant=#lines color="#aaa" gap={16} />
      <ReactFlow.MiniMap
        nodeColor={n => {
          switch ReactFlow.Node.type_Get(n) {
          | Some("input") => "#0041d0"
          | Some("output") => "#ff0072"
          | Some("default") => "#1a192b"
          | _ => "#eee"
          }
        }}
        nodeStrokeColor={_ => "#fff"}
        nodeBorderRadius={2}
      />
    </ReactFlow>
  </div>
}

Please look at the example folder for more advanced implementations.

Contributing

If you'd like to contribute, you can follow the instructions below to get things working locally.

Getting Started

  1. After cloning the repo, install the dependencies
yarn install
  1. Build:
yarn re:build
  1. If you're running the example, in other terminal run:
yarn start
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].