Code Monkey home page Code Monkey logo

web's Introduction

xyflow-header xyflow-header-dark

GitHub License MIT npm downloads npm downloads

Powerful open source libraries for building node-based UIs with React or Svelte. Ready out-of-the-box and infinitely customizable.

React Flow · Svelte Flow · React Flow Pro · Discord


The xyflow mono repo

The xyflow repository is the home of four packages:

We just moved repositories from the @wbkd org to this one. React Flow v11 will remain on the v11 branch. When we have a stable v12, the package name of React Flow will change from reactflow to @xyflow/react.

Commercial usage

Are you using React Flow or Svelte Flow for a personal project? Great! No sponsorship needed, you can support us by reporting any bugs you find, sending us screenshots of your projects, and starring us on Github 🌟

Are you using React Flow or Svelte Flow at your organization and making money from it? Awesome! We rely on your support to keep our libraries developed and maintained under an MIT License, just how we like it. For React Flow you can do that on the React Flow Pro website and for both of our libraries you can do it through Github Sponsors.

Getting started

The best way to get started is to check out the React Flow or Svelte Flow learn section. However if you want to get a sneak peek of how to install and use the libraries you can see it here:

React Flow basic usage

Installation

npm install reactflow

Basic usage

import { useCallback } from 'react';
import ReactFlow, {
MiniMap,
Controls,
Background,
useNodesState,
useEdgesState,
addEdge,
} from 'reactflow';

import 'reactflow/dist/style.css';

const initialNodes = [
{ id: '1', position: { x: 0, y: 0 }, data: { label: '1' } },
{ id: '2', position: { x: 0, y: 100 }, data: { label: '2' } },
];

const initialEdges = [{ id: 'e1-2', source: '1', target: '2' }];

function Flow() {
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);

const onConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), [setEdges]);

return (
  <ReactFlow
    nodes={nodes}
    edges={edges}
    onNodesChange={onNodesChange}
    onEdgesChange={onEdgesChange}
    onConnect={onConnect}
  >
    <MiniMap />
    <Controls />
    <Background />
  </ReactFlow>
);
}

export default Flow;
Svelte Flow basic usage

Installation

npm install @xyflow/svelte

Basic usage

<script lang="ts">
import { writable } from 'svelte/store';
import {
  SvelteFlow,
  Controls,
  Background,
  BackgroundVariant,
  MiniMap,
} from '@xyflow/svelte';

import '@xyflow/svelte/dist/style.css'

const nodes = writable([
  {
    id: '1',
    type: 'input',
    data: { label: 'Input Node' },
    position: { x: 0, y: 0 }
  },
  {
    id: '2',
    type: 'custom',
    data: { label: 'Node' },
    position: { x: 0, y: 150 }
  }
]);

const edges = writable([
  {
    id: '1-2',
    type: 'default',
    source: '1',
    target: '2',
    label: 'Edge Text'
  }
]);
</script>

<SvelteFlow
{nodes}
{edges}
fitView
on:nodeclick={(event) => console.log('on node click', event)}
>
<Controls />
<Background variant={BackgroundVariant.Dots} />
<MiniMap />
</SvelteFlow>

The xyflow team

React Flow and Svelte Flow are maintained by the team behind xyflow. If you need help or want to talk to us about a collaboration, reach out through our contact form or by joining our Discord Server.

License

React Flow and Svelte Flow are MIT licensed.

web's People

Contributors

1bye avatar akrv7591 avatar andrewraycode avatar andreyvolfman avatar bcakmakoglu avatar bradgearon avatar carpye avatar charlie059 avatar chrtze avatar conniepaula avatar elbakerino avatar hayleigh-dot-dev avatar imalfect avatar insolite avatar johnrobbjr avatar kaiyuanma avatar lovetox avatar mavcook avatar maxholmberg96 avatar moklick avatar mvarendorff avatar olegpolin avatar peterkogo avatar sishir2001 avatar theoisdumb avatar turbobot-temp avatar vladstudio avatar zaks276 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

web's Issues

Docs: fix dev warnings

  • Hydration errors

I think these can be fixed by removing the <Link /> component within a <ContentGridItem /> that has a route prop (for example in LibraryCards).

Screen Shot 2023-08-10 at 14 37 00
  • Next Image Warnings

Not sure what's the best way to configure the Next image components in the showcase slider.

Screen Shot 2023-08-10 at 14 36 41

📝 Clarify dagre layouting example.

The current dagre example initialises the layouting graph just once and will not work if new nodes are added or removed.

We should either clarify this limitation of the example (and suggest how one may overcome it) or update the example to work on dynamic graphs.

Example: connection line (react/svelte)

Make it a bit more interesting by showing three handles at the bottom (green/orange/red) - depending where you start the edge, the connection line should be green, orange or red.

📝 Restructure "Guides" sidebar to group things by category.

By having the API docs be purely reference material, it can be hard for users to discover slightly buried things like the NodeProps type that tells you what props are passed to a custom node.

To keep the API docs a strict reference, we think it would be useful to rethink the current "Guides" sidebar on the docs to group things based on their category or concept and then also link out to relevant API reference too.

Instead of:

  • Guides
    • Custom Nodes
    • Sub Flows
    • Layouting
    • ...

We could have

  • Nodes
    • Creating custom nodes
    • Custom node props
    • ...
  • Layouting
    • Sub flows
    • ...
  • Troubleshooting
    • Removing attribution
    • Migrating to ...

Write up Repo documentation

Before publishing it, we should add some more context and information to the repo and explain what you can do with it.

  • readme
    • intro image (ask facu for dark mode)
    • overview on what the repo contains and how its structured
    • installation and turborepo
    • how to run individual apps
    • staging and production urls
    • xyflow pro ad
    • contact us
  • contributing
    • git workflow (also for ourselves)
  • license
    • MIT
  • ethical standards / code of conduct
    • same as in react-flow repo or just reference to it?
  • issue template?
    • this will most often be used for issues in the docs
  • changelog?
    • not sure how we'll do it for the individual apps
  • sponsor button?
    • can we add a link to xyflow pro?

document new CSS variables

with the new release, we are introducing CSS variables as another option to customize the default styling of xyflow. We should document the available variables somehow:

--edge-stroke-default: #b1b1b7;
  --edge-stroke-width-default: 1;
  --edge-stroke-selected-default: #555;

  --connectionline-stroke-default: #b1b1b7;
  --connectionline-stroke-width-default: 1;

  --attribution-background-color-default: rgba(255, 255, 255, 0.5);

  --minimap-background-color-default: #fff;

  --background-pattern-dot-color-default: #91919a;
  --background-pattern-line-color-default: #eee;
  --background-pattern-cross-color-default: #e2e2e2;
  --node-color-default: inherit;
  --node-border-default: 1px solid #1a192b;
  --node-background-color-default: #fff;
  --node-group-background-color-default: rgba(240, 240, 240, 0.25);
  --node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, 0.08);
  --node-boxshadow-selected-default: 0 0 0 0.5px #1a192b;

  --handle-background-color-default: #1a192b;
  --handle-border-color-default: #fff;

  --selection-background-color-default: rgba(0, 89, 220, 0.08);
  --selection-border-default: 1px dotted rgba(0, 89, 220, 0.8);

  --controls-button-background-color-default: #fefefe;
  --controls-button-background-color-hover-default: #f4f4f4;
  --controls-button-color-default: inherit;
  --controls-button-color-hover-default: inherit;
  --controls-button-border-color-default: #eee;
  --controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, 0.08);

Unable to use <Text> component from xy-ui in Case Study markdown file

When adding a component inside of a case study markdown file, an error is thrown. Maybe because it's inside of the component?

See commit (this code throws the below error): bf8b12a

Server Error
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

This error happened while generating the page. Any console logs will be displayed in the terminal window.

Trying to make this change to make the answer text in the Case Studies more easily scannable, referencing style of interviews like this one

🐛 Make blog post previews more accessible.

Image

Our blog post previews are the classic "buttons that work like links". I found this really surprising when, for example, cmd+clicking one of these cards didn't open a new tab but instead navigated the current tab.

I think it would be better if the whole card were an anchor rather than the Read more (which incidentally cmd+clicking on will still navigate the current page).

Page: Case Studies

  • Add content for the other case studies
  • make the OneSignal screenshot better (refer to the Doubleloop screenshot)
  • change drop shadow behind image to the nice gradient border in Facu's design
  • Make this linked from the Pro page
  • Add closing element above footer on overview page (check Facu's designs)
  • Improve readability with font style changes (reference other newspaper interview websites, how they style the questions vs. answers (waiting for #56)
  • change button to pro variation at the bottom of case study page

⚗️ Experiment generating JSON containing public type info from a TS module.

With the current React Flow docs site, we hand-maintain an object that contains the type information for things like interfaces and functions and then use that to render an API reference. It'd be much nicer if we could derive that object as JSON by just parsing the modules we care about documenting.

This kills two birds with one stone because it'll encourage us to better document the source code!


I did some initial experimentation with TSDoc, which seemed ideal because it even had a built-in JSON export option. Unfortunately it seems entirely geared up to work at the level of "packages" rather than on individual modules, and I fear that may just be overkill.

Ideally we have a local utility package that let's us do xy-export-types react/types/edges and we get just the types in that module back as JSON. Unfortunately that means the path forward looks like...

Using the typescript compiler API

The good news is you can import typescript as a package and start calling the compiler, walking the AST, etc straight from any ol' script: https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API

The bad news is the compiler API is basically undocumented and quite complicated.

Here's the todo list in order-ish of complexity:

  • Scan a single file and export any public interfaces.
  • Export any public non-function consts.
  • Export any public functions.
  • Export any public types including union types.
  • Squash multiple source files into a single JSON output.

As a first-pass I'd like to end up with output like this:

[ { "kind": "interface"
  , "name": "EdgeLabelOptions"
  , "docs": "..."
  , "fields": 
    [ { "name": "label", "type", "string | ReactNode", "optional": true }
    , ...
    ]
  }
]

On a second go round I'd like a better representation for referenced types, so we can generate links and all that.


This issue is frustrating because there are a couple of tools out there but they seemed far more geared towards generating entirely automated docs sites, but we have Opinions about how to show off our API reference that make these unsuitable.

Opening this so I can keep track of what I'm up to and abandon it if it's eating too much time.

Restructure API docs

I'm not super happy with how our current API reference is organised; although it surfaces all the important information quickly it does so in a seemingly unstructured way. I want to use this issue to collect some references of other package and API docs and see if we can come up with something clearer.

Component docs:

Hook docs:

API docs:

These ones are not so relevant to us (we're not documenting a HTTP API) but I still find the way they present information interesting.

Replace hardcoded urls with env variables

urls linking to pro platform and svelte examples are currently hardcoded. To have an encapsulated staging and production environment we should link these urls should be set in vercel for each environment seperately

Page: Blog post

  • Implement design
    • Warning/notice components
    • Widescreen images and code snippets.
    • Image captions

Desktop

Feat: search

We need to find a way to define a separate index for React Flow and Svelte Flow, so that you only get Svelte related results when you are under /svelte-flow.

Ideas to solve this:

  • create a docsearch for the current staging domain and see if that's configurable somehow
  • create our own index with algolia
  • check out other search frameworks / services

Add Socials to footer

Mastodon, Bluesky, Twitter, and Discord links should be in the footer
Contact should also be there!

Docs: Add section about initial node size

It's confusing that width and height can be passed as node options but they don't have any effect. The recommended way of passing an initial size to a node is to set the style option. Maybe we can document that somewhere?

Finalize content of React Flow / Svelte Flow landing pages

  • Svelte: Replace "latest release" in stats section with current version
  • Svelte: Come up with closing element before footer (maybe the same as bottom of a Case Study page?)
  • React: Come up with closing element before footer (maybe the same as bottom of a Case Study page?)
  • Add flows inside boxes in features section @moklick
  • use Facu's node design thing for preview of Getting Started guide image in pre-footer section

Examples are not beginner friendly

Describe the Bug

The demo code on https://reactflow.dev/docs/examples/overview/ does not run correctly on the latest version because of the missing width and height

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Initialize project with npm init react-app <app_name>
  2. Copy the code for App.js and initial-elements.js from https://reactflow.dev/docs/examples/overview/
  3. npm start

Expected behavior

What's shown in the feature overview

Screenshots or Videos

image
The app worked after adding the height
image

Platform

  • OS: Linux
  • Browser: Chrome/Firefox
  • Version: Chrome 103.0.5060.53 , Firefox 103.0.2

Additional context

No response

Wire up contact forms

Investigate which service is suitable for us and connect our contact forms (general + enterprise) to it.

Feat: Svelte examples viewer

Currently we can't display svelte examples on our website. We wanted to use sandpack / codesandbox but for some reasons it doesn't work.

I opened an issue in the sandpack repo codesandbox/sandpack#961 and one in the codesandbox-client repo codesandbox/codesandbox-client#7750 . My hope is that by updating their internal Svelte transpiling pipeline the issues just go away, but that's not for sure. For now I would like to wait for another one or two weeks and see if there is any progress with those issues. On Discord they told me that someone will look into it.

If there are any other ideas besides embedding a Stackblitz iframe, here is the place to collect those ideas.

Download Image example resulting image is cropped

Description

I want to implement full diagram PNG export.
The documentation contains an example using html-to-image library about downloading the diagram as PNG:

Unfortunately, the image downloaded from the example is cropped on large diagrams. This should not happen judging by the comment:

// we calculate a transform for the nodes so that all nodes are visible

In addition the image is very pixelated.

Setting pixelRatio: 4 seems to fix the pixelation, but I was unable to stop the image cropping.

Expected behavior

The documentation should contain an example on downloading full diagram as PNG that:

  • Is high quality
  • Does not crop the image
2023-09-03.20-04-21.mp4

Page: About

  • Make the timeline UI into just a paragraph of text (maybe with an image above it?)
  • Find / create a new image for our footer that includes the whole team
  • Create high-fidelity image to use at top of about page to replace current draft image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.