-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 17 create canvas #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
351bd82
feat: add react flow and create canvas
egenerse a5ff2de
feat: add canvas, styles, zoom, minimap
egenerse 0617bbc
feat: add button to call library method
egenerse 1fcb634
Merge branch 'main' into 17-create-canvas
egenerse 2d240f8
chore: use contant values for min-max zoom scale
egenerse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,54 @@ | ||
import { useState } from "react" | ||
import { | ||
ReactFlow, | ||
ReactFlowInstance, | ||
ReactFlowProvider, | ||
type Node, | ||
type Edge, | ||
Background, | ||
BackgroundVariant, | ||
Controls, | ||
MiniMap, | ||
} from "@xyflow/react" | ||
|
||
export function App() { | ||
const [count, setCount] = useState(0) | ||
import "@xyflow/react/dist/style.css" | ||
|
||
const initialNodes: Node[] = [ | ||
{ id: "1", position: { x: 0, y: 0 }, data: { label: "1" } }, | ||
{ id: "2", position: { x: 0, y: 100 }, data: { label: "2" } }, | ||
] | ||
const initialEdges: Edge[] = [{ id: "e1-2", source: "1", target: "2" }] | ||
|
||
interface AppProps { | ||
onReactFlowInit: (instance: ReactFlowInstance) => void | ||
} | ||
|
||
function App({ onReactFlowInit }: AppProps) { | ||
return ( | ||
<div> | ||
Library Count:{count} | ||
<button onClick={() => setCount(count + 1)}> | ||
Increment From Library | ||
</button> | ||
<div style={{ width: "100vw", height: "100vh" }}> | ||
<ReactFlow | ||
nodes={initialNodes} | ||
edges={initialEdges} | ||
onInit={onReactFlowInit} | ||
fitView | ||
minZoom={0.6} | ||
maxZoom={2} | ||
> | ||
<Background variant={BackgroundVariant.Lines} /> | ||
<MiniMap zoomable pannable /> | ||
<Controls /> | ||
</ReactFlow> | ||
</div> | ||
) | ||
} | ||
|
||
export function AppWithProvider({ | ||
onReactFlowInit, | ||
}: { | ||
onReactFlowInit: (instance: ReactFlowInstance) => void | ||
}) { | ||
return ( | ||
<ReactFlowProvider> | ||
<App onReactFlowInit={onReactFlowInit} /> | ||
</ReactFlowProvider> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.