SHIV5T3R / CO-DE

An Open Source Collaborative Code Editor
36 stars 26 forks source link

PR: Editor Page's Design Scaffolding/Layout & State management #51

Closed KingXP-Pythoner closed 9 months ago

KingXP-Pythoner commented 9 months ago

(Y'all might probably hate me but major updates in this PR. )

Major updates

I have developed a model that describes the flow from clicking a folder/file in the tree explorer and displaying it's contents in the editor as well as allowing navigation with the file tabs. A single file is called a node with the CODENodeModel type. This closely resembles the naming of the @minoru/react-dnd-treeview package implementation where a file is a NodeModel type.

The node takes the properties of NodeModel such as id, it's parent, droppable and utilises the optional data prop to insert FileAttributes which holds very important props such as focus, isActive, isFolder, uri,for client state management. With this in mind, I created two zustand global states documentNodes (type CODENodeModel[]) and selectedNode (`type CODENodeModel) which allows us to monitor and manipulate states of any node in the current tree any where in our app (in this case, our mock tree data is the source of the files or nodes initialised in the store while the store is the source of truth of their states) and update the editor and the page UI in sync.

Existing Dependencies Updated

I haven't written any test and would appreciate it if someone can work on that if the PR gets merged. I did a lot of manual testing but don't have much time to write tests as of now. I'm sorry I may have went overboard with this PR with so many updates but if you have any questions please message me on DIscord. Thank you :))

hobi9 commented 9 months ago

fantastic job as always!

SHIV5T3R commented 9 months ago

This is some lovely UI, would someone be able to run some tests? I'll merge this after I've tested if nobody does in the next few days.