Skip to content

Update css guides#794

Open
enatario wants to merge 4 commits into
mainfrom
en-update-css-guides
Open

Update css guides#794
enatario wants to merge 4 commits into
mainfrom
en-update-css-guides

Conversation

@enatario
Copy link
Copy Markdown
Contributor

Our CSS guides were pretty stale and not comprehensive. This updates them to include more modern approaches, including recommending native CSS over SCSS (this removes the Sass guides). This also leverages Roux as a baseline for best practices.

Copy link
Copy Markdown

@vendelal vendelal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm so grateful you took the time to make these updates! I know I will reference this in the near future knowing it's current and there were some great tips in here that were new to me/that I often forget!

Comment thread css/README.md
- Use stylelint to lint CSS & Sass
- We maintain a [sharable stylelint configuration] which enforces our guides
found in this repo
For new projects, consider using [Roux] as a structured starting point. It
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Comment thread css/README.md

`h1.page-title` carries a specificity of 2, but can be reduced to 1 by removing
the `h1` type selector:
- [Lightning CSS] is fast, modern, and light
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these tools have good longevity? This isn't inherently an issue, but just wondering if this landscape changes frequently and whether we want to include specific links or not

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly! Most of them have been around for long enough that I'd err on the side of recommending them, even if they get stale. Mostly want to ensure folks are bundling instead of using @import raw.

Comment thread css/README.md
#### Resources
Modern CSS layout tools can often eliminate the need for breakpoints entirely.
Reaching for a media query is reasonable, but it's worth considering whether the
layout could respond naturally first.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is honestly kind of news to me 😅 I just saw you're including some examples below, that's really helpful!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahahah breakpoint management is the bane of my existence so the less you have to use it the betterrrrr

Comment thread css/README.md Outdated
Comment thread css/README.md
[Stylelint] is a good option for enforcing CSS conventions. The
[stylelint-order] plugin can handle alphabetical declaration ordering. If
adopting a shared config, it's worth reviewing its rules to make sure they
reflect native CSS rather than Sass-specific conventions.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a stylelint config we can share here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have our thoughtbot one but that is also woefully out of date 😭

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

womp womp haha. Well next step could be to update that and then add it here in a future PR

Comment thread css/README.md
### Naming

- Use lowercase and hyphens (kebab-case) for class names and custom properties
- Be consistent with whatever naming convention the project is already using. Introducing a
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention that we prefer BEM if starting fresh or is that too opinionated? Maybe that's covered by the first bullet here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we could be more strong about BEM usage!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to ask this as well. Personally I think BEM could be a "reasonable-default" also worth linking to a resource here

Co-authored-by: Vendela Colavecchio (Larsson) <vendelalinnea@mac.com>
Copy link
Copy Markdown

@aspencer116 aspencer116 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great update 👏 thanks for working on this! Definitely worth promoting in a blog or social post once it's merged!

Comment thread css/README.md
- Vendor prefixes are rarely needed for modern browsers. If a project requires
legacy browser support, consider automating prefixes via a build tool rather
than maintaining them by hand
- Prefer native CSS over preprocessors like SCSS
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BIG DEAL

Comment thread css/README.md
Comment on lines +192 to +193
**Note:** Unfortunately, you can't use a CSS custom property as a value within a media query, so be sure
to keep track of your values here and perhaps scope it per partial.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so annoying!

Comment thread css/README.md

### Declaration ordering

[Alphabetical ordering is a reasonable default] because it's predictable and easy to
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the phrasing "reasonable default" which makes it clear this is a good choice but not the only option

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also happy to add in other preferences like by property type! Thoughts?

Comment thread css/README.md
### Naming

- Use lowercase and hyphens (kebab-case) for class names and custom properties
- Be consistent with whatever naming convention the project is already using. Introducing a
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to ask this as well. Personally I think BEM could be a "reasonable-default" also worth linking to a resource here

Comment thread css/README.md
Comment on lines +209 to +210
- Use hyphens when naming classes and custom properties: `span-columns` not
`span_columns` or `spanColumns`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a BEM class format as an example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup good call!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants