MozillaFoundation / engineering-handbook

Mozilla Foundation's Engineering Handbook
https://mozillafoundation.github.io/engineering-handbook/
13 stars 11 forks source link

Write a Chapter: "Front End UI Libraries" #41

Closed gvn closed 3 years ago

gvn commented 9 years ago

We need to codify best practices for writing UI components that are reusable across all our codebases and stack variants.

gvn commented 9 years ago

Initial thoughts:

gvn commented 9 years ago

Would love to hear thoughts from @gesa and @k88hudson

jbuck commented 9 years ago

After doing login 3 times I honestly think it's a goddamned fool's errand.

The problem basically boils down to CSS. It's a big global variable that each potential consumer of your UI blob modifies. If you're using the same CSS base in every consumer then you might have a chance to make it work the first time you implement it. Otherwise it's a shitshow.

If we're going to write UI blobs that we expect to work across platforms then we need to write them in one of two ways: 1) a completely hostile environment, where we inline every single style with !important or something equally ridiculous 2) a completely clean environment, aka an iframe. this will probably have mobile issues though.

gvn commented 9 years ago

I have done CSS "namespacing" in the past where everything for a component's CSS is nested under a wrapper ID (eg: #webmaker-login .thing). It's not a perfect solution, but it does keep collisions down...

gesa commented 9 years ago

I'm a strong supporter of namespacing css with a wrapper ID

gvn commented 9 years ago

Also, I do think that if we wrote login with vanilla DOM instead of the Angular+Shim approach we'd be in a far better place. What we have now is a serious maintenance problem and we should try our best to avoid ever getting into that situation again.