ChainSafe / engineering-handbook

ChainSafe Engineering Handbook
https://handbook.chainsafe.io
Apache License 2.0
6 stars 2 forks source link

Frontend standardisation #18

Open mpetrunic opened 2 years ago

mpetrunic commented 2 years ago

Migrated from notion:

Brainstorm

https://mui.com/


On Friday, November 5, We had a discussion about $Component Library Implementation$ which opened a few new questions.

My recommendation is to contain 2 separate meetings between the architecture and component library. (please comment if you agree or disagree about this)

cc @BeroBurny @sweetpea22 @FSM1 @Tbaut @RyRy79261 and others who I forgot to tag

BeroBurny commented 2 years ago

Personally don't like the idea of having MUI skin as a component library.


About CSS, we tried (@irubido and me) to use the BEM bus is more confusing but dint does not work well with component hierarchy. For other methodologies, we dint dive enough to find a good way to use it in our architecture.


Architecture Think we can go to 2 approaches it depends on the project scale. For small scale projects, they should have folders inside src something like this

  • assets
  • components
  • containers
  • pages
  • services
  • styles
  • ducks
  • hooks
  • types
  • utils

A bigger project should be split into chunks inside the pages folder to represent the routes hierarchy for example

  • pages (is root page)
    • index.tsx
    • trades
    • components
    • containers
    • assets
    • index.tsx
    • history
      • index.tsx
      • User.tsx

where subfolders are only relevant for specific routes and root-level are used for globally shared code.


Recommender libs

ivanceras commented 2 years ago

Hi guys, apology if I'm pushing my personal project.

I have created a front-end framework which is inspired by elm (The Elm Architecture). The name of the project is sauron.

It has demonstrated that is a viable alternative to other front-end. Here is an example code on how to use it as front-end for a Near contract.

This project is certainly a niche, which is targeting rust developers who are trying to use rust for front-end development. Most rust programmers are in the back-end side of things.

The advantage of using sauron is that I am the core developer and adding support for case where it is not supported can be added as we go along.

wainola commented 2 years ago

Personally don't like the idea of having MUI skin as a component library.

About CSS, we tried (@irubido and me) to use the BEM bus is more confusing but dint does not work well with component hierarchy. For other methodologies, we dint dive enough to find a good way to use it in our architecture.

Architecture Think we can go to 2 approaches it depends on the project scale. For small scale projects, they should have folders inside src something like this

  • assets
  • components
  • containers
  • pages
  • services
  • styles
  • ducks
  • hooks
  • types
  • utils

A bigger project should be split into chunks inside the pages folder to represent the routes hierarchy for example

  • pages (is root page)

    • index.tsx

    • trades

    • components

    • containers

    • assets

    • index.tsx

    • history

      • index.tsx
      • User.tsx

where subfolders are only relevant for specific routes and root-level are used for globally shared code.

Recommender libs

  • classnames - simple utility but pretty useful tool for manipulating className's
  • axios - defacto standard for HTTP requests
  • date-fns - date manipulation library
  • react-router-dom - routing library
  • formik - extremely useful for big form
  • joi - validating object/form
  • redux - global state managment tool

    • @reduxjs/toolkit - simplifies life of writing redux loop
    • redux-saga - powerful data flow managment

We had a meeting with @FSM1 about this, so we can figure it out a way to organize this. I guess it would be great to organize a guild meeting to talk about this. Our general considerations are the following:

mpetrunic commented 2 years ago

@wainola Just a note for library usage, I didn't mean that you write here libraries that each project must include. But rather to have something like:

But for certain we should standardize directory naming across organisation so it's easier to onboard and guide new developers as well as make it easy for people to switch between projects. Obviously some project will have additional directories and that's ok.

I'm thinking of creating github repo for standards (similar to https://github.com/ipfs/eslint-config-ipfs) which we can push to npm so for lining instead of copying configuration, you could do in .eslint.json

extends: "@chainsafe/standard"