HSLdevcom / jore4

Public transport registry
European Union Public License 1.2
4 stars 2 forks source link

As a developer, I'd like to know which frontend libraries and coding conventions to use #290

Closed tuokait closed 3 years ago

tuokait commented 3 years ago

E.g which solutions for writing styles we want to use

and which component library we want to use as a base for our UI, if any (previously #291)

but also other libraries / conventions / solutions can be discussed in the comments.

288

pallost commented 3 years ago

The HSL style guide can be found from here: https://tyyliopas.hsl.fi/

pallost commented 3 years ago

There also seems to be an existing HSL component library but it's for mobile devices and was abandoned 4 years ago: https://github.com/HSLdevcom/shared-components

pallost commented 3 years ago

As I can see from the HSL style guide, there aren't many components whose style are actually defined: https://tyyliopas.hsl.fi/d/h8JR9dHeqfgd/digitaaliset-palvelut#/elementit-ja-maeaerittelyt/komponentit This would allow us to use basically any component library if we wish...

Personally, I don't want to use Material UI, because its coding style is very restricting. You cannot easily overwrite its CSS with the style or class attribute, you have to use its build-in CSS definition system. It's a steep learning curve to learn what all DOM nodes you need to create for a more complex design (e.g. look just here: https://material-ui.com/components/cards/). It's not very customizable either...

Personally, I would choose bootstrap because it feels light and easily customizable for most components.

pallost commented 3 years ago

For the CSS usage, I don't want to use plain .css files, because we'll almost certainly hit a wall at some point where we want to implement something that is not possible / annoying / very hard with plain css.

I've had some bad experience with SASS, because it needs a whole massive compiler toolchain with it (even gcc if I remember correctly). But I'm not against it either...

Tailwind is weird concept, but I liked it in the end in the previous project...

I would be interested in trying React's build-in CSS-in-JS system: https://reactjs.org/docs/dom-elements.html#classname

I haven't used styled-components, so I cannot form an opinion about it. It certainly looks like a horrible syntax to me but that's something I could live with :)

haphut commented 3 years ago

I expect you two have more experience on this topic. I'll share my two cents, anyway.

Agree with @pallost on not using Material UI due to its inflexibility. I've seen Bootstrap used for delivering satisfactory results quickly with reactstrap.

I've understood that the trend is toward unstyled component libraries like Base Web or Headless UI. Might be easier than overriding existing styles. Base Web uses its own styling solution, Styletron. Headless UI uses Tailwind CSS.

If ELY-keskus and others will use Jore4 codebase, they will require support for styling the UI according to their own brand.

haphut commented 3 years ago

Here's an example of quite specific guidelines from HSL: https://tyyliopas.hsl.fi/d/h8JR9dHeqfgd/braendi#/muotokieli/muotokieli-ja-sommittelu

"Yhtenäisen tyylin luomiseksi käytetään yksinkertaisia sääntöjä kulmien pyöristyksen koon määrittämiseksi. Pyöristetyt elementit eivät ole toistensa sisällä vaan sisäkkäisissä yhdistelmissä käytetään teräväkulmaisia elementtejä yhdessä pyöreäkulmaisten elementtien kanssa. -- Kulmapyöristyksen säde on enintään 1/5 suorakulmion lyhimmästä sivusta."

Yes, that link is not for the digital services. Those guidelines have been created after the brand styling. But could be something to think about when browsing the component libraries. Considering that we are building an UI that is not for consumers, I'm personally not fussy about the margins.

pallost commented 3 years ago

This Base Web and Headless UI is actually a pretty smart approach, I like that

tuokait commented 3 years ago

Characteristics of good CSS/styling solution

These are my opinions. Someone else might have different opinions.

Located close to the place where they are used

Scoped to one file

Enforce consistency

Theming/variable support

(Possibility for 1-off hacks if needed)

Some popular libraries to consider

(not in particular order)

"Styled-components family"

These use styled-components internally or are inspired by it.

"Tailwind family"

Tailwind + related libraries.

Other

jschummer commented 3 years ago

Would storybook be an option for us?

Does it cause too much overhead if we don't want to develop a generalized component library?

haphut commented 3 years ago

Is https://react-styleguidist.js.org/ a relevant alternative to storybook?

haphut commented 3 years ago

A decision was reached in Slack and in the architecture meeting to use Tailwind CSS and Headless UI for styling and components.

haphut commented 3 years ago

As adding Storybook does not block working on the UI right now, I've added a separate idea issue about it in #305 .