(Web/View) Components: Should everything be a component?

An article, posted about 2 years ago filed in WebComponents, components, design system, structure, todo, programming, development, front-end & html.

Recently I was reviewing a merge request of some front-end code, and a simple div, that changed a bit of the custom appearance of a block of text through a few custom classes, was changed in a call to a view component that then applied the same classes, passed onto the component through a more deeply nested hash.

- <div class="custom-class">
+ <%= TextComponent.new(html: {class: "custom-class"}) do

I’m not sure why people would like to do it, but some ideas:

  • No more HTML / Everything is a component! (reminds me of l’art pour l’art)
  • Ability to analyse the way components are used (we’re not doing this right now)

The drawbacks:

  • Less readable code (perhaps an opinion)
  • Slower execution, instead of rendering a static snippet, code needs to be executed
  • Instead of <div>’itis you get ‘TextComponent’-itis.. we don’t add better semantic or structural informa…

Continue reading...