Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCSS Architecture: Choose a CSS naming convention to stick to #10883

Open
superbiche opened this issue Nov 22, 2018 · 4 comments
Open

SCSS Architecture: Choose a CSS naming convention to stick to #10883

superbiche opened this issue Nov 22, 2018 · 4 comments

Comments

@superbiche
Copy link
Collaborator

superbiche commented Nov 22, 2018

This is part of the SCSS Architecture rewrite in #10881

What

The goal is to discuss available CSS naming conventions.

Why?

Because currently class names have no structure, aren't DRY, editing the CSS is painful with a bunch of side effects and we don't use the power of the C in CSS.

Expected outcomes

  • Allow rewriting the styles in a modular way (Atomic Design-ish)
  • Prevent side-effects when editing a given component
  • Use semantic CSS naming to help new and existing contributors find their way easily in the code
  • Globally make the code more maintainable

I'll add my candidates and my opinion on each of these, feel free to add some or join the conversation here.

Available options

To be totally honest I've been working a lot with BEM (as it's used in Drupal) but anytime I can I rewrite everything to SuitCSS:

  • Less typing
  • PascalCase demonstrate the fact we're styling a component, quite like UI components can be thought as Classes (and are Classes in major JS Frontend frameworks)
  • The u- prefix for utilities makes it really easy to know whether it's a component class or a helper
  • The alternance between PascalCase for the "root component", camelCase after the dash for the "component elements", and double dash for the modifier, make it even more clear and readable

That's just my honest opinion having spent a lot of time during the past 7 years doing CSS and always test&learning, I stick with SuitCSS naming convention.
And to be totally impartial, BEM is much more famous so maybe adoption would be easier (or less tough considering the mindset shift needed whatever convention is enforced).

Recommended reading material

@superbiche superbiche mentioned this issue Nov 22, 2018
11 tasks
@zulipbot

This comment has been minimized.

@schrej
Copy link

schrej commented Nov 24, 2018

From what you've proposed I'd prefer SMACSS, as it's the most simple and straight-forward, and the stuff in the sass guide.
I probably won't have time to contribute, but that's just what I'd choose.

@superbiche
Copy link
Collaborator Author

@schrej you're right, it's the most straightforward thus great candidate for adoption.
I'd like us to keep the .u- utility class prefixing from SuitCSS as in my experience I've found it very useful to enhance readability in a medium-large-scale project

@zulipbot
Copy link
Member

zulipbot commented Dec 13, 2018

Hello @zulip/server-refactoring members, this issue was labeled with the "area: refactoring" label, so you may want to check it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants