-
Notifications
You must be signed in to change notification settings - Fork 1
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
Unify overall file structure and code #463
Comments
@Sharqiewicz I started fleshing the description of this ticket out a bit more. Do you have thoughts/suggestions on how we should structure the code, what to refactor/align, etc? |
cc @Sharqiewicz incase you missed the message from Marcel |
@TorstenStueber if you have any thoughts/opinions about the guidelines I added to the description please feel free to share them as well. |
@ebma Great proposal. On the question of whether to define components as proper functions or arrow functions, I have the strong opinion that top level functions in JS should always be functions, otherwise JS gets degraded to C/C++ where the definition order of functions matter. Is there any advantage for using arrow functions instead? Also the official React docs use this style. I mostly agree with the folder structure. Where would you put config/constants/contracts? What is the purpose of For the components I tend more towards option 1, but we might then have a large collection of components in the The CSS styling seems to be a wild combination of classic CSS files and Tailwind. I think it makes sense to unify this as well and slowly migrate towards tailwind (as this is also the technology we use in the Vortex UI now). As you already pointed out: when there are no test or CSS files, I strongly prefer that we move components into |
@ebma I've already put some work into unifying the components between Nabla and Portal, removed duplicate components, refactored the components used by both and created tests for the most important ones. But there are still some components to be processed like: |
@ebma @TorstenStueber WDYT?
remove /shared /models and move the components and files that are directly under /src to their corresponding directories |
If it really does not matter much if we use arrow vs normal functions for functional components, I'm more in @TorstenStueber's boat because I personally prefer giving more space to components. Declaring them with a simple
I know that we can save some lines by already destructuring the props in the function definition but I prefer having it more explicit. Not too hard feelings about this though.
Works for me. I'm fine if we agree to only use named exports going forward. Regarding the structure, your proposal looks good to me @Sharqiewicz but I would opt for |
I would also prefer not to introduce any new .css declarations if possible and only relying on tailwind. However, I think some things can only be declared in CSS unfortunately.
What exactly do you mean with subdividing? Let's maybe talk about examples. I understand that you would group components like the SwapAssetsButton and ModalClose button in a
My understanding of the |
Arrow functions@Sharqiewicz about arrow functions. Sure they handle It's purely a matter of taste what you find cleaner:
Or also destructuring the argument within the component as @ebma proposes. I didn't see the style that you use before that refers to StructureFor the structure: looks good. What is
Makes sense. So should ExportsI also agree on named exports. Components
@ebma yes, instead of having one flat |
Should we estimate the work that is done here? |
@Sharqiewicz should we add a link to the Notion page you created for the guidelines? |
Context
In #326 we identified the need for some refactorings because we are having duplicate components with different stylings. Besides that, the code style diverged as the development of the Nabla UI happened in parallel to the development of the core portal features.
We should clean this up and unify the components and structure again.
Guidelines
Functional components
Do we want to declare functional components as
function MyCompenent(props: Props)
or asconst MyComponent = (props:Props) => ()
? At the moment we have a mixture of both notations.Folder structure
The ideal folder structure is roughly as follows:
We should remove the folders
models
,shared
,config
, andconstants
and move the contained files somewhere else. We should add a new foldercontexts
and move all theuseContext
components inside.We need to agree on where to put components. Currently, some components live in
src/components
and some live insrc/pages/xxx
. This isn't very clear because it is unclear when and where a component is created.Two options:
src/pages/xxx
paths and into thecomponents
folder. The files inpages
should only import components to display them, not define them.pages
directory.Component file structure
Each component should live in a separate file. (Components that are tightly coupled can live in the same file). Component file names should be in Pascal case. When a component has a related
styles.css
file or test, it should live in an extra directory as follows:If neither a
styles.css
nor test file is relevant for the component, it doesn't need to live in a separate directory and can just be calledMyComponent.tsx
.TODO
The text was updated successfully, but these errors were encountered: