Skip to content
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

Example 1 - With local storage #14

Draft
wants to merge 300 commits into
base: with-create-next-app
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
f59f8fb
Move blocksContainerWidth to settings
Vadorequest Feb 4, 2021
8b074c1
Misc doc
Vadorequest Feb 4, 2021
d23f0fd
Remove previewText (too hard to style)
Vadorequest Feb 4, 2021
26cb7d7
Add default width/height as node data
Vadorequest Feb 4, 2021
9d204a4
Configure QuestionNode.tsx
Vadorequest Feb 4, 2021
e667230
Use reactSelect but behaves randomly
Vadorequest Feb 4, 2021
4aebfe9
Add ChakraUI lib (breaks most of the existing design)
Vadorequest Feb 5, 2021
73e4327
Leave select for later, awaiting feedback on issues
Vadorequest Feb 5, 2021
291745d
Misc
Vadorequest Feb 5, 2021
72386e6
Improve TS types
Vadorequest Feb 5, 2021
6345d90
Rename node to nodeProps to avoid confusion
Vadorequest Feb 5, 2021
dfbce14
Forward onClick event to foreignObject
Vadorequest Feb 5, 2021
0337707
Use settings + refactoring
Vadorequest Feb 5, 2021
b5075b2
Refactoring
Vadorequest Feb 5, 2021
6a72d4e
Allow to create new nodes using + component between nodes
Vadorequest Feb 5, 2021
4f93628
Add BlockPickerMenu component to pick the component to add
Vadorequest Feb 5, 2021
da90f9c
Remove Drag and Drop feature (DnD) - Too complicated and not good eno…
Vadorequest Feb 5, 2021
6256ca9
Use different components for blocks and nodes
Vadorequest Feb 5, 2021
6368acf
Refactoring
Vadorequest Feb 5, 2021
693490e
Add ability to renomve nodes
Vadorequest Feb 5, 2021
918a46d
Add ports to InformationNode.tsx
Vadorequest Feb 5, 2021
b4eee23
Misc todo
Vadorequest Feb 5, 2021
f4aa886
Allow creating a node from a port through blockPickerMenu
Vadorequest Feb 5, 2021
30a020b
Refactoring into a dedicated BasePort.tsx component
Vadorequest Feb 5, 2021
fee3d4c
Try creating the node on the left when selecting the left port but fa…
Vadorequest Feb 5, 2021
0da859b
Increase size of ports + use custom setting "radius" to define port's…
Vadorequest Feb 8, 2021
9d781a0
Add BaseEdgeData type
Vadorequest Feb 8, 2021
e5d00f0
Upgrade reaflow
Vadorequest Feb 8, 2021
f2e2031
Add utility to create a new node and connect it through its port
Vadorequest Feb 8, 2021
0497a5c
Add "filterNodeInArray" utility + update selected nodes when a node i…
Vadorequest Feb 8, 2021
9cc8561
Fix node creation when there is 1/0 node left
Vadorequest Feb 8, 2021
6f0442b
Fix blockPickerMenu display when there are less than 2 nodes left
Vadorequest Feb 8, 2021
0caa491
Make canvas direction a setting
Vadorequest Feb 8, 2021
2827992
Upsert nodes while connecting ports correctly
Vadorequest Feb 8, 2021
3b0dab2
Add canvasRefState.ts
Vadorequest Feb 8, 2021
8a28388
Remove canvasRefState.ts
Vadorequest Feb 8, 2021
1e98df1
Forward onClick event to QuestionNode.tsx
Vadorequest Feb 8, 2021
de06533
Add "removeAndUpsertNodesThroughPorts" utility, now links ports corre…
Vadorequest Feb 8, 2021
8ed7077
Misc
Vadorequest Feb 8, 2021
03f9a53
Misc
Vadorequest Feb 9, 2021
b1533b1
Add undo/redo feature
Vadorequest Feb 9, 2021
68142c4
Infinite history
Vadorequest Feb 9, 2021
c1c1231
Add node actions bar
Vadorequest Feb 9, 2021
277ebc9
Add BasePortData
Vadorequest Feb 9, 2021
d718694
Add draggedEdgeFromPortState
Vadorequest Feb 9, 2021
a300616
Use draggedEdgeFromPortState + use drag events on all ports to know w…
Vadorequest Feb 9, 2021
2bcf0c5
Improve display of BlockPickerMenu.tsx
Vadorequest Feb 9, 2021
a0bdc42
Display block picker close to the spot the edge was dropped
Vadorequest Feb 9, 2021
7e983c2
Use settings instead of unnamed constants + create node/edge when sel…
Vadorequest Feb 9, 2021
97288ea
Misc
Vadorequest Feb 9, 2021
b5b0cb6
Improve UX by not toggling dumbly but keep track of where the BlockPi…
Vadorequest Feb 9, 2021
097ab82
Use animate.css to run an animation when the blockpickermenu updates
Vadorequest Feb 9, 2021
e3d8545
Massive refactor, added BaseNode to handle common render logic for al…
Vadorequest Feb 9, 2021
e273a9a
Misc
Vadorequest Feb 9, 2021
380116d
Documentation
Vadorequest Feb 9, 2021
2d8ba34
Apply pointer-events properly
Vadorequest Feb 9, 2021
52d6ab6
Clear up selected nodes and block picker upon canvas click
Vadorequest Feb 9, 2021
6d04032
Fix hiding menu when clicking on canvas, don't hide if an edge was dr…
Vadorequest Feb 9, 2021
23e88e7
Doc
Vadorequest Feb 9, 2021
b6d2ab2
Fix React Select and ChakraUI Select display (they needed to use "dis…
Vadorequest Feb 10, 2021
9569a94
Misc doc
Vadorequest Feb 10, 2021
fffc36f
Refactoring to get initial edges/nodes from the page (like we'd do in…
Vadorequest Feb 10, 2021
825b34a
Improve documentation
Vadorequest Feb 10, 2021
879b5e7
More doc
Vadorequest Feb 10, 2021
11e42a2
More doc (components all documented)
Vadorequest Feb 10, 2021
147312e
More doc
Vadorequest Feb 10, 2021
e977d86
Remove wdyr because it's not compatible with Emotion 11 and automatic…
Vadorequest Feb 10, 2021
a734609
Update README.md
Vadorequest Feb 10, 2021
a85434d
Update README.md
Vadorequest Feb 10, 2021
b66d8e6
Add documentation about ELK
Vadorequest Feb 10, 2021
f80dc29
Open BlockPickerMenu close to the edge (when adding through edge) + r…
Vadorequest Feb 10, 2021
991472e
Make the EditorContainer.tsx render on the server too (doesn't seem t…
Vadorequest Feb 10, 2021
bd48250
Fix another warning (was running setState outside of useEffect)
Vadorequest Feb 10, 2021
8786dd2
Don't render the canvas on the server (not compatible with server, ha…
Vadorequest Feb 10, 2021
cf9bb01
Use LS to get/set graph data and automatically load them upon page load
Vadorequest Feb 10, 2021
b452f1c
Update README.md
Vadorequest Feb 10, 2021
a86e5e0
Use useSetRecoilState to store the last created node in the recoil sh…
Vadorequest Feb 10, 2021
dc98f3d
Forward lastCreatedNode to all Node components
Vadorequest Feb 11, 2021
227f949
Refactor init to avoid creating new nodes needlessly (only as fallback)
Vadorequest Feb 11, 2021
14e9c49
Use setLastUpdatedNode from component (doesn't work from non-component)
Vadorequest Feb 11, 2021
517a2dc
Add clear all button
Vadorequest Feb 11, 2021
1deb4f6
Disable autofocus for now
Vadorequest Feb 11, 2021
a80daa2
Add RecoilExternalStateUtils.tsx component, which allows to use the R…
Vadorequest Feb 11, 2021
4f1fa1e
Add more ELK doc links
Vadorequest Feb 11, 2021
3d5f8fa
Add doc about RecoilExternalStatePortal
Vadorequest Feb 11, 2021
0b32f50
Misc doc
Vadorequest Feb 11, 2021
3cbe7f8
Improve TS types
Vadorequest Feb 12, 2021
88bc2ad
Add isSelected but not yet implemented
Vadorequest Feb 12, 2021
4677db9
Hide delete-action "X" until it gets implemented
Vadorequest Feb 12, 2021
a3b4195
Upgrade to reaflow 3.0.13
Vadorequest Feb 12, 2021
bc4794b
Attempt to use fixed nodes but doesn't seem to work
Vadorequest Feb 12, 2021
b55dc9e
Add forms TS helpers
Vadorequest Feb 12, 2021
cf9bf66
Make TS types more generic + forward the current "node" from the Node…
Vadorequest Feb 12, 2021
93cb617
Fix more TS types
Vadorequest Feb 12, 2021
c4c9714
Update doc and implementation of patchCurrentNode
Vadorequest Feb 12, 2021
b4c0954
Improve TS types for QuestionNode.tsx
Vadorequest Feb 12, 2021
3ca088a
Debounce updates to textarea input updates, to avoid lag
Vadorequest Feb 12, 2021
bba29cb
Fix patch algorithm
Vadorequest Feb 12, 2021
9fa5dd8
Use react-debounce-input, works so much better
Vadorequest Feb 14, 2021
1c2386a
Automatically hide the block picker menu once a block has been picked
Vadorequest Feb 16, 2021
08fc34a
Add StartNode.tsx component and create it by default
Vadorequest Feb 16, 2021
75cc165
Ensures the start node is always present
Vadorequest Feb 16, 2021
6538265
Fix question node creation
Vadorequest Feb 16, 2021
cb68409
Save text on QuestionNode
Vadorequest Feb 16, 2021
cb5f282
Make the canvas fit the page upon loading
Vadorequest Feb 16, 2021
8e7174e
Update types
Vadorequest Feb 16, 2021
3a82763
Add onSelectedChoiceTypeChange
Vadorequest Feb 16, 2021
2590fa5
Refactoring settings with TS types
Vadorequest Feb 16, 2021
6d48daa
Add "link:reaflow" command to quickly link local packages to reaflow …
Vadorequest Feb 16, 2021
eaa8359
Saves the selected choice in the node's data and display it (removed …
Vadorequest Feb 16, 2021
74f404d
Remove business logic about having the BlockPickerMenu.tsx displayed …
Vadorequest Feb 16, 2021
cc1a6aa
Update doc about BlockPickerMenu.tsx
Vadorequest Feb 16, 2021
e27a733
Replace PortData by BasePortData wherever we should use our own abstr…
Vadorequest Feb 16, 2021
921b481
Improve implementation of addNodeAndEdgeThroughPorts, now handles cre…
Vadorequest Feb 16, 2021
afca009
Add recoil selectors for nodes/edges states
Vadorequest Feb 16, 2021
d765b29
Add canvasDatasetSelector, to ensure better dataset integrity when mu…
Vadorequest Feb 16, 2021
fb182e6
Refactor using setCanvasDataset whenever better for dataset integrity
Vadorequest Feb 16, 2021
69c2584
Fix undo/redo
Vadorequest Feb 16, 2021
cd6db70
Add IfBlock component
Vadorequest Feb 16, 2021
c3e423e
Fix fromPort when using a different port than the first one
Vadorequest Feb 16, 2021
d324ef6
Use CENTER because it doesn't change anything and other values aren't…
Vadorequest Feb 16, 2021
2fdf010
Make all output ports used by IfNode display differently to distingui…
Vadorequest Feb 16, 2021
0276070
Reset label (don't override)
Vadorequest Feb 16, 2021
f409b7a
Keep example of how to add labels on edges
Vadorequest Feb 17, 2021
7dd9256
Clearing the undo/redo history to avoid allowing the editor to "undo"…
Vadorequest Feb 17, 2021
9343b09
Add BasePortProps + resolve current port in BasePort component (utility)
Vadorequest Feb 17, 2021
d960c7d
Avoid needless re-renders by only updating the input height if it's d…
Vadorequest Feb 17, 2021
df606e9
Refactoring of persistCanvasDataset.ts
Vadorequest Feb 17, 2021
30eb9f6
Protect against infinite loop rendering
Vadorequest Feb 17, 2021
4470422
Refactoring about how to provide the initial data to the Recoil state…
Vadorequest Feb 17, 2021
fbe0d42
Add dummy code for use getStaticProps + use DisplayOnBrowserMount to …
Vadorequest Feb 17, 2021
b0ee04e
Use selectors instead of atoms to make sure our sanity checks are app…
Vadorequest Feb 17, 2021
3f45862
Remove forgotten stuff about why-did-you-render
Vadorequest Feb 17, 2021
8fe53ae
Store initialCanvasDataset in "window" from Next.js page and read it …
Vadorequest Feb 17, 2021
10f140b
Misc doc
Vadorequest Feb 18, 2021
dbb88a3
Reset to allow clearing history even if the option is used several ti…
Vadorequest Feb 18, 2021
fa3a1be
Misc (more logical)
Vadorequest Feb 18, 2021
ca962ec
Misc
Vadorequest Feb 18, 2021
6db5e94
Ensure the app don't crash when trying to render nodes that have been…
Vadorequest Feb 19, 2021
d96bd79
Improve DX
Vadorequest Feb 19, 2021
474772b
Implement isSelected (doesn't do anything, yet)
Vadorequest Feb 19, 2021
c347e32
Refactor selectedNodesState.ts, storing node ids instead of whole nodes
Vadorequest Feb 19, 2021
4033d16
Fixed click on element randomly broke selection because it was wrongl…
Vadorequest Feb 19, 2021
de70c30
Visually display selected nodes
Vadorequest Feb 19, 2021
4b76aa1
use dash
Vadorequest Feb 19, 2021
e0a9d1e
misc
Vadorequest Feb 19, 2021
5226d31
Massive refactor of NodeRouter.tsx, moved all node business logic to …
Vadorequest Feb 19, 2021
2288f25
Simplify stuff
Vadorequest Feb 19, 2021
734018e
Misc doc
Vadorequest Feb 19, 2021
7535463
Misc debug
Vadorequest Feb 19, 2021
51216b0
Use selectedNodesSelector
Vadorequest Feb 19, 2021
3223c8e
Misc debug
Vadorequest Feb 19, 2021
2ebf4d5
Improve BaseEdge.tsx and add utility variables
Vadorequest Feb 19, 2021
03b4537
Forwards onNodeEnter and onNodeLeave to <foreignObject> + simplify on…
Vadorequest Feb 19, 2021
c3f26e9
Allow node selection (not visible)
Vadorequest Feb 19, 2021
de51b5b
Hack to increase distance between nodes
Vadorequest Feb 19, 2021
9ebea70
Display edge selection
Vadorequest Feb 19, 2021
aab0a6d
Unselect selected edges when clicking on canvas
Vadorequest Feb 19, 2021
85cc6d4
Use settings
Vadorequest Feb 19, 2021
f30a382
Display the <AddBlockPicker> component only if the edge is selected
Vadorequest Feb 19, 2021
be85e98
Allow to remove an edge
Vadorequest Feb 19, 2021
5aa2847
Use dirty hack to display several edge actions (add + remove) when an…
Vadorequest Feb 19, 2021
48d13f9
Misc
Vadorequest Feb 19, 2021
68c8a7f
Misc doc
Vadorequest Feb 19, 2021
5d2762e
Having fun with FA icons
Vadorequest Feb 19, 2021
ef9a201
Having fun with Chakra
Vadorequest Feb 19, 2021
0905e6a
Having fun with Chakra colors
Vadorequest Feb 19, 2021
528a935
Add createEdge helper
Vadorequest Feb 19, 2021
c21e363
Refactor addNodeThroughPorts + add utilities
Vadorequest Feb 19, 2021
69314f9
Improve onNodeLink implementation (link through ports)
Vadorequest Feb 19, 2021
bb5f2f5
Allow connecting nodes through port linking
Vadorequest Feb 19, 2021
047854d
Avoid fatal error when linking outside of port
Vadorequest Feb 19, 2021
5e842bd
Fix bad imports
Vadorequest Feb 19, 2021
827aac8
mouseEnteredState skeleton + logging
Vadorequest Feb 20, 2021
8a9aa8e
Add canvasUtilsContext.tsx and hook
Vadorequest Feb 20, 2021
a5f4e15
Aborting attempt to rewrite our onPortDragEnd implementation
Vadorequest Feb 20, 2021
b465347
Improve doc + ts type
Vadorequest Feb 20, 2021
df2a992
Highlight ports during edge dragging
Vadorequest Feb 20, 2021
8c3bc3d
Refactor business logic into shouldBeHighlighted
Vadorequest Feb 20, 2021
67af0af
Refactoring
Vadorequest Feb 20, 2021
0a6f237
Improve canConnectToDestinationPort algorithm
Vadorequest Feb 22, 2021
acd57ad
Ensures the destination port can be linked to the fromPort before doi…
Vadorequest Feb 22, 2021
4769b29
Fix import
Vadorequest Feb 22, 2021
2ed7f0f
Refactor usage of lastCreatedNode, use it per-node instead of using i…
Vadorequest Feb 22, 2021
c3d8b44
Refactor LastCreated to store the timestamp of creation + apply autof…
Vadorequest Feb 22, 2021
08b335b
Fix SpecializedNodeProps TS type
Vadorequest Feb 22, 2021
d34bf51
Allow node deletion
Vadorequest Feb 22, 2021
7a2edfc
Fix hasDuplicates and refactor it into hasDuplicatedObjects
Vadorequest Feb 22, 2021
b617a7c
Implement cloning of a node
Vadorequest Feb 22, 2021
c8c7575
Increase canvas width x3
Vadorequest Feb 22, 2021
7882a4a
Disallow clone/delete for "Start" node
Vadorequest Feb 22, 2021
9127564
Add visual indicator when a node isn't reachable
Vadorequest Feb 22, 2021
18ca980
Remove dead code (unused) + doc
Vadorequest Feb 22, 2021
a7c17bc
Refactoring settings
Vadorequest Feb 22, 2021
39d500f
Misc doc
Vadorequest Feb 22, 2021
2bf08a8
Add Zoom utilities and buttons (doesn't work awesomely good, though)
Vadorequest Feb 22, 2021
08a7054
Run onDragStartInternal (which doesn't seem to change anything, but i…
Vadorequest Feb 22, 2021
528723d
Display cursor X/Y on the bottom left
Vadorequest Feb 22, 2021
5a3181e
Refactoring isYoungerThan
Vadorequest Feb 23, 2021
fec2a99
Disable autofocus for now
Vadorequest Feb 23, 2021
e48a908
Add lastCreated in SpecializedNodeProps + highlight last created node…
Vadorequest Feb 23, 2021
12299ea
Misc doc + remove pulse animation
Vadorequest Feb 23, 2021
758efe0
Implement blockPickerMenuSelector + patch changes made to the blockPi…
Vadorequest Feb 23, 2021
cf84990
Refactoring of BlockPickerMenu (re-use common business logic) + Avoid…
Vadorequest Feb 23, 2021
063f28f
Automatically hide the BlockPickerMenu when clicking on the canvas, i…
Vadorequest Feb 23, 2021
884e632
Fix fromPort when clicking on the 2nd EAST port of the IF node
Vadorequest Feb 23, 2021
7524892
Automatically select the last created node (and unselect all other no…
Vadorequest Feb 23, 2021
01d3643
Make "node" take full size of its parent, minus the margins (left/rig…
Vadorequest Feb 23, 2021
287141b
Misc TODO
Vadorequest Feb 24, 2021
71e7740
Remove useless CSS
Vadorequest Feb 24, 2021
8489a57
Improve README.md
Vadorequest Feb 25, 2021
272a236
Add onKeyDown mock
Vadorequest Feb 25, 2021
b35564e
Removed AddBlockPicker.tsx unused component
Vadorequest Feb 26, 2021
9e77d06
Clicking on port now displays the BlockPickerMenu close by (instead o…
Vadorequest Feb 27, 2021
354521b
Add VariableNameInput component
Vadorequest Feb 27, 2021
62398cf
Save the variable name in the node
Vadorequest Feb 27, 2021
41c3706
Make VariableNameInput generic (but didn't help much)
Vadorequest Feb 27, 2021
1d41bdb
Misc doc
Vadorequest Feb 27, 2021
a47836b
Change Question default size
Vadorequest Feb 27, 2021
9ecc2ee
Make question node's height increase when single-quick-reply is selected
Vadorequest Feb 27, 2021
cb22020
Refactoring to re-calculate the height of the node automatically usin…
Vadorequest Feb 27, 2021
31a8dfc
Adapt InformationNode.tsx
Vadorequest Feb 27, 2021
c2dbca9
Misc doc
Vadorequest Feb 27, 2021
cfa0eb4
Display question choice variables and allow edits (name + value)
Vadorequest Feb 27, 2021
63cc042
Renaming variable + doc
Vadorequest Feb 27, 2021
6d7a3eb
Renaming variable
Vadorequest Feb 27, 2021
4609df5
Fix react warning + debounce inputs
Vadorequest Feb 27, 2021
64eb884
Misc
Vadorequest Feb 27, 2021
7e1bd25
Misc refacto variable
Vadorequest Feb 28, 2021
aa384e3
Refactoring (fix) TS types - https://stackoverflow.com/questions/6639…
Vadorequest Feb 28, 2021
5c3a88c
Add SelectVariable.tsx component
Vadorequest Feb 28, 2021
d6bd04c
Add variablesState.ts which resolves variables that can be used from …
Vadorequest Feb 28, 2021
9190dd3
Better TS types for SelectVariable.tsx component + optimization
Vadorequest Feb 28, 2021
46245eb
Less worse TS types
Vadorequest Feb 28, 2021
fd8a125
Simplify
Vadorequest Feb 28, 2021
b7a672c
Add SelectComparisonOperator
Vadorequest Feb 28, 2021
aff14df
Fix initialization of variablesSelector
Vadorequest Feb 28, 2021
91a3d22
Add type/choices to Variable + improve guard
Vadorequest Feb 28, 2021
60befdc
Add SelectExpectedValue component + refactoring
Vadorequest Feb 28, 2021
eb73f5c
Documentation
Vadorequest Feb 28, 2021
70d7fd3
Misc doc
Vadorequest Feb 28, 2021
7a4947a
Added Recoil DevTools (#8)
Vadorequest Mar 2, 2021
2b998f2
Add variants
Vadorequest Mar 8, 2021
d68f62f
Hide recoil devtools by default
Vadorequest Mar 8, 2021
288e9d0
Extract footer as component
Vadorequest Mar 8, 2021
c6819f7
Extract footer as component
Vadorequest Mar 8, 2021
a70f3c4
Use Chakra components
Vadorequest Mar 8, 2021
b5fbceb
Add skeleton UI for Nav/Footer
Vadorequest Mar 8, 2021
52e05d0
Update Nav/Footer to reflect what the demo really does
Vadorequest Mar 8, 2021
cc2ed11
Remove variants (don't want to maintain old branches)
Vadorequest Mar 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ yarn-error.log*

# vercel
.vercel

# WebStorm
.idea
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2019 Unly

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

85 changes: 60 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,76 @@
# TypeScript Next.js example
# POC Next.js + Reaflow

This is a really simple project that shows the usage of Next.js with TypeScript.
> This project is a POC of [Reaflow](https://github.com/reaviz/reaflow) used with the Next.js framework. It is hosted on Vercel.

## Deploy your own
It is a single-page application (using a static page) that aims at showing an **advanced use-case with Reaflow**.

## Online demo

[Demo](https://poc-nextjs-reaflow.vercel.app/) (automatically updated from the `master` branch).

![image](https://user-images.githubusercontent.com/3807458/109431687-08bf1680-7a08-11eb-98bd-31fa91e21680.png)

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
## Features

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-typescript&project-name=with-typescript&repository-name=with-typescript)
It comes with the following features:
- Source code heavily **documented**
- Strong TS typings
- Different kinds of node (`start`, `if`, `information`, `question`) with different layouts for each type _(see [NodeRouter component](blob/main/src/components/nodes/NodeRouter.tsx))_
- Nodes use `foreignObject`, which complicates things quite a bit (events, css), but it's the only way of writing HTML/CSS within an SVG `rect` (custom nodes UI)
- Advanced support for **`foreignObject`** and best-practices
- Support for **Emotion 11**
- Reaflow Nodes, Edges and Ports are properly extended (**BaseNode** component, **BaseNodeData** type, **BaseEdge** component, **BaseEdgeData** type, etc.),
which makes it easy to quickly change the properties of all nodes, edges, ports, etc.
- Creation of nodes through the `BlockPickerMenu` component, which displays either at the bottom of the canvas, or at the mouse pointer position (e.g: when dropping edges)
- **Undo/redo** support (with shortcuts)
- Node/edge **deletion**
- Node **duplication**
- **Selection** of nodes and edges, one at a time
- Uses **`Recoil`** for shared state management
- Automatically re-calculate the **height** of nodes when jumping lines in `textarea`
- Graph data (nodes, edges) are **persisted** in the browser **localstorage** and loaded upon page reload

## How to use it?
Known limitations:
- Editor direction is `RIGHT` (hardcoded) and adding nodes will add them to the right side, always (even if you change the direction)
- I don't plan on changing that at the moment

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
> This POC can be used as a boilerplate to start your own project using Reaflow.

```bash
npx create-next-app --example with-typescript with-typescript-app
# or
yarn create next-app --example with-typescript with-typescript-app
```
## Getting started

- `yarn`
- `yarn start`
- Open browser at [http://localhost:8890](http://localhost:8890)

## Deploy your own

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
Deploy the example using [Vercel](https://vercel.com):

## Notes
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/Vadorequest/poc-nextjs-reaflow&project-name=poc-nextjs-reaflow&repository-name=poc-nextjs-reaflow)

This example shows how to integrate the TypeScript type system into Next.js. Since TypeScript is supported out of the box with Next.js, all we have to do is to install TypeScript.
## Advanced - ELK

```
npm install --save-dev typescript
```
ELKjs (and ELK) are used to draw the graph (nodes, edges).
It's what Reaflow uses in the background.
ELK stands for **Eclipse Layout Kernel**.

To enable TypeScript's features, we install the type declarations for React and Node.
It seems to be one of the best Layout manager out there.

```
npm install --save-dev @types/react @types/react-dom @types/node
```
Unfortunately, it is quite complicated and lacks a comprehensive documentation.

When we run `next dev` the next time, Next.js will start looking for any `.ts` or `.tsx` files in our project and builds it. It even automatically creates a `tsconfig.json` file for our project with the recommended settings.
You'll need to dig into the ELK documentation and issues if you're trying to change **how the graph's layout behaves**.
Here are some good places to start and useful links I've compiled for my own sake.

Next.js has built-in TypeScript declarations, so we'll get autocompletion for Next.js' modules straight away.
- [ELKjs GitHub](https://github.com/kieler/elkjs)
- [ELK official website](https://www.eclipse.org/elk/)
- [ELK Demonstrators](https://rtsys.informatik.uni-kiel.de/elklive/index.html)
- [Tool to convert `elkt <=> json` both ways](https://rtsys.informatik.uni-kiel.de/elklive/conversion.html)
- [Tool to convert `elkt` to a graph](https://rtsys.informatik.uni-kiel.de/elklive/elkgraph.html)
- [Java ELK implementation of the `layered` algorithm](https://github.com/eclipse/elk/tree/master/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/p2layers)
- [Community examples soure code](https://github.com/eclipse/elk-models/tree/master/examples) _(which are displayed on [ELK examples](https://rtsys.informatik.uni-kiel.de/elklive/examples.html))_
- [Klayjs example](http://kieler.github.io/klayjs-d3/examples/interactive) (ELK is the sucessor of KlayJS and [should support the same options](https://github.com/kieler/elkjs/issues/122#issuecomment-777781503))
- [Issues opened by Austin](https://github.com/kieler/elkjs/issues?q=is%3Aissue+sort%3Aupdated-desc+author%3Aamcdnl)
- [Issues opened by Vadorequest](https://github.com/kieler/elkjs/issues?q=is%3Aissue+sort%3Aupdated-desc+author%3Avadorequest)

A `type-check` script is also added to `package.json`, which runs TypeScript's `tsc` CLI in `noEmit` mode to run type-checking separately. You can then include this, for example, in your `test` scripts.
Known limitations:
- [Tracking issue - Manually positioning the nodes ("Standalone Edge Routing")](https://github.com/eclipse/elk/issues/315)
2 changes: 2 additions & 0 deletions app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module '@unly/utils';

24 changes: 24 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Babel configuration for Next.js
*
* The official documentation uses a ".babelrc" file, but we prefer using "babel.config.js" for better documentation support.
*
* @see https://nextjs.org/docs/advanced-features/customizing-babel-config Official doc reference v10
* @see https://github.com/vercel/next.js/blob/canary/packages/next/build/babel/preset.ts You can take a look at this file to learn about the presets included by next/babel.
* @see https://emotion.sh/docs/css-prop#babel-preset Configuring Emotion 11
* @example https://github.com/vercel/next.js/tree/canary/examples/with-custom-babel-config Next.js official example of customizing Babel
*/
module.exports = {
presets: [
[
'next/babel',
{
'preset-react': {
'runtime': 'automatic',
'importSource': '@emotion/react',
},
},
],
],
plugins: ['@emotion/babel-plugin'],
};
6 changes: 6 additions & 0 deletions browser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Extends the native browser Window object by adding our custom keys.
*/
interface Window {
initialCanvasDataset?: any;
}
41 changes: 0 additions & 41 deletions components/Layout.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions components/List.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions components/ListDetail.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions components/ListItem.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions interfaces/index.ts

This file was deleted.

79 changes: 65 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,73 @@
{
"name": "with-typescript",
"version": "1.0.0",
"name": "poc-nextjs-reaflow",
"license": "MIT",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"type-check": "tsc"
"start": "next dev --port 8890",
"type-check": "tsc",
"link:reaflow": "yarn link reaflow && yarn link react && yarn link react-dom"
},
"dependencies": {
"next": "latest",
"react": "^16.12.0",
"react-dom": "^16.12.0"
"@chakra-ui/icons": "1.0.4",
"@chakra-ui/react": "1.2.1",
"@chakra-ui/theme-tools": "1.0.3",
"@emotion/react": "11.1.4",
"@emotion/styled": "11.0.0",
"@fortawesome/fontawesome-svg-core": "1.2.34",
"@fortawesome/free-brands-svg-icons": "5.15.2",
"@fortawesome/free-solid-svg-icons": "5.15.2",
"@fortawesome/react-fontawesome": "0.1.14",
"@types/lodash.clonedeep": "4.5.6",
"@types/lodash.merge": "4.6.6",
"@types/lodash.now": "4.0.6",
"@types/lodash.size": "4.2.6",
"@unly/utils": "1.0.3",
"@welldone-software/why-did-you-render": "6.0.5",
"animate.css": "4.1.1",
"classnames": "2.2.6",
"framer-motion": "3.2.1",
"lodash.capitalize": "4.2.1",
"lodash.clonedeep": "4.5.0",
"lodash.debounce": "4.0.8",
"lodash.filter": "4.6.0",
"lodash.includes": "4.3.0",
"lodash.isequal": "4.5.0",
"lodash.merge": "4.6.2",
"lodash.now": "4.0.2",
"lodash.remove": "4.7.0",
"lodash.size": "4.2.0",
"lodash.some": "4.6.0",
"lodash.sortby": "4.7.0",
"next": "10.0.6",
"rdk": "5.0.6",
"react": "17.0.1",
"react-debounce-input": "3.2.3",
"react-dom": "17.0.1",
"react-select": "4.0.2",
"react-textarea-autosize": "8.3.0",
"reaflow": "3.0.13",
"recoil": "0.1.2",
"recoil-devtools-dock": "^0.1.6",
"recoil-devtools-log-monitor": "^0.2.7",
"recoil-devtools-logger": "^0.1.5",
"uuid": "8.3.2"
},
"devDependencies": {
"@types/node": "^12.12.21",
"@types/react": "^16.9.16",
"@types/react-dom": "^16.9.4",
"typescript": "4.0"
},
"license": "MIT"
"@emotion/babel-plugin": "11.1.2",
"@types/classnames": "2.2.11",
"@types/lodash.capitalize": "4.2.6",
"@types/lodash.debounce": "4.0.6",
"@types/lodash.filter": "4.6.6",
"@types/lodash.includes": "4.3.6",
"@types/lodash.isequal": "4.5.5",
"@types/lodash.remove": "4.7.6",
"@types/lodash.some": "4.6.6",
"@types/lodash.sortby": "4.7.6",
"@types/node": "14.14.22",
"@types/react": "17.0.1",
"@types/react-dom": "17.0.0",
"@types/react-select": "4.0.12",
"@types/uuid": "8.3.0",
"typescript": "4.1.3"
}
}
16 changes: 0 additions & 16 deletions pages/about.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions pages/api/users/index.ts

This file was deleted.

Loading