PolymathNetwork / polymath-apps

Monorepo containing Polymath's Apps
https://tokenstudio.polymath.network
Apache License 2.0
14 stars 16 forks source link

Modernize frontend UI stack #150

Closed Grsmto closed 5 years ago

Grsmto commented 5 years ago

Hey guys, Here are some notes about the current frontend stack (purely UI-wise). This is for me and also to discuss and see what you think.

Currently the UI is based on Carbon Design System. Very similar to Bootstrap or Material UI, this had the advantage of making the UI development very quick. Also it's a design system so it proposes useful classes to have a consistent UI (spacing, font-sizes etc.) that we are not using at the moment and the website hasn't been build with them unfortunately.

But it comes with cons:

For applications like ours, a more modern CSS architecture would bring the following improvements:

Solution 1: stay with Sass + BEM

pros:

cons:

Solution 2: CSS-in-JS

pros:

cons:

Patterns

Some resources to achieve this:

RafaelVidaurre commented 5 years ago

First of all: Great work, thanks for putting together this document, this is something that has been worrying me for a while. I agree with what you wrote down about how the architecture should be like.

I'd definitely go for solution 2. About what library to use I've used StyledComponents many times before and I like it a lot, but I know Emotion is pretty popular nowadays, so maybe it is worth considering the differences before making a decision (we probably won't be able to look back once we pick one).

About performance, I don't think this is really an issue, we can also precompile most of the styles to css in build time I believe, right?

RafaelVidaurre commented 5 years ago

What I'd suggest, is to do the refactor without any ties to the legacy code, and slowly start moving our deprecated components to the new ones. That way we are not limited to previous architectural decisions, this will heavily influence how the dApp will end up looking like in the future, so lets treat this as a definitive change

RafaelVidaurre commented 5 years ago

@monitz87 comments?

Grsmto commented 5 years ago

Update

tooling

I have been experimenting with both Reakit, Styled-System and I recently discovered Smooth UI to see what fits best. All 3 are "primitives based" React UI frameworks. It means that you don't actually need to use the built in components. You just use the primitives and build your own custom components on top. Great thing with this pattern is that every components are based on a single root Box component. So the frameworks are not leaving a huge footprint on the codebase (pretty much just the Box.js component). I think this is primordial for maintenance as it would let us swap/upgrade easily to another framework more easily if needed.

Styled-Components vs Emotion

The main difference between the two is performances: Emotion was faster. The APIs are really similar. But apparently since SC v4, the performances are now pretty much the same and everybody seems to go back to SC now.

Background experience

For the record, I have been using a similar pattern on a previous project. It was fully custom code (using Tailwind CSS + custom props mapping to class names functions). It was quite complex and not well documented, so not best for maintenance. However the pattern itself was awesome and extremely powerful. We ended up to a point where building new pages was just importing primitive components, no css to write at all, and everything was consistent and nicely layout-ed.