Re:Front-end design, React, and a bridge over the great divide
by pierreyoda on Friday July 19, 2019 @06:33PM
(#20482990)
On your last point, I feel like components this basic should really rather be addressed at the real theming level, i.e. in CSS.
Utility-first CSS frameworks are awesome if you get past your first impression. I've been using TailwindCSS [0] both at work and for all my personal projects ever since I read Adam Wathan's justification on it [1]. In TailwindCSS those constants are configured in one place and generated at build time (through Rollup/Webpack/PostCSS etc.). Consistency and theming for free basically.
Even Bootstrap has now a decent collection of them in v4.
[0] https://tailwindcss.com/ [1] https://adamwathan.me/css-utility-classes-and-separation-of-...
But this is like any abstraction in programming. When you have a function you want to be reusable you usually have to do some work to make it more portable across your codebase and create a proper flexible "interface" for it via arguments.
The UI components are particularily easy to reuse. If you look at something like Rebass it uses predefined constants to add consistency of values across the entire site + a theming system which simply tweaks those constants (ie, colors, the scales of font sizes across h1-h6, etc).
https://rebassjs.org