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

Refs #2 Adds beginning outline of our scss coding standards #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kmuncie
Copy link

@kmuncie kmuncie commented Jul 18, 2017

Cleaned up a few things and tried to isolate from any one project example

Copy link
Member

@jthomerson jthomerson left a comment

Choose a reason for hiding this comment

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

Please make the changes noted in the review. Once we have all those changes reviewed, there will also be one sweeping change that needs to be made to line-wrap all your paragraphs, but we will hold off on that until after we get the actual review done so that the re-reviews are easier.


Sass (file extension .scss) is a language which compiles to CSS. It is a powerful tool in the writing of CSS but does not absolve you as a developer from the code which is output. You must understand what good CSS looks like before you can effectively write Sass.

Below are some guiding principles and rules when writting styling code.
Copy link
Member

Choose a reason for hiding this comment

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

s/writting/writing/

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

* >3 selectors (when compiled)
* ID's or !important
* element.class
* z-index declarations
Copy link
Member

Choose a reason for hiding this comment

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

Please format all markdown lists where they start with a three-space indent as is done in our other markdown files in this repo.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Some basic [code smells](https://en.wikipedia.org/wiki/Code_smell) might include:

* >3 selectors (when compiled)
* ID's or !important
Copy link
Member

Choose a reason for hiding this comment

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

no apostrophe ... the ID is not possessive or a contraction

Copy link
Author

Choose a reason for hiding this comment

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

Fixed


### Naming

Class and ID names should be **camel case (first word lower-case) and dashes used sparingly**. Example: `.classNameThatsPrettyLong`
Copy link
Member

Choose a reason for hiding this comment

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

rather than re-defining what camel case means here, just link the words "camel case" to the glossary

Copy link
Member

Choose a reason for hiding this comment

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

I also think "and dashes used sparingly" should be separated into its own paragraph rather than being in the same one that has the camelCase rule. That paragraph can explain acceptable and unacceptable usecases for hyphens. (also better to call them hyphens than dashes since "dash" is ambiguous)

Copy link
Author

Choose a reason for hiding this comment

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

Rewrote naming section to simplify


Class and ID names should be **camel case (first word lower-case) and dashes used sparingly**. Example: `.classNameThatsPrettyLong`

Variables should in ["kebab-case" style](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) and feature a logical structure which
Copy link
Member

Choose a reason for hiding this comment

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

Rather than linking externally to a definition of a case, this should be added to the other definitions of cases in our glossary. The "kebab-case" (no need for the word "style" here) can be linked to the glossary.

Copy link
Author

Choose a reason for hiding this comment

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

Rewrote naming section to simplify, not even mentioning kebab-case any longer

```
.mainContainer {
.nestedClassOne {
color: Tomato;
Copy link
Member

Choose a reason for hiding this comment

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

You have an indentation error here.

color: firebrick;
}
}
// ----------------------
Copy link
Member

Choose a reason for hiding this comment

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

For example, I would have expected a blank line above this comment line ...

Copy link
Author

Choose a reason for hiding this comment

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

I have a strong personal opinion on this so perhaps we can discuss further

}
.oneThing,
.secondThing,
.thirdThing {
Copy link
Member

Choose a reason for hiding this comment

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

I didn't see anything in the documentation about this ... lists of selectors separated by commas. Should they always be on their own line, or would .oneThing, .secondThing, .thirdThing { ever be valid?

Copy link
Author

Choose a reason for hiding this comment

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

Added

}
```

Most **RTL** rules should be written so as to be independent of the page direction. We have mixed content in many places so any major component should get a direction set on its outermost container. Example:
Copy link
Member

Choose a reason for hiding this comment

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

Most people may not be familiar with the term RTL, so please s/RTL/right-to-left (RTL)/ here, and then you can use RTL after that as much as needed.

Copy link
Member

Choose a reason for hiding this comment

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

"We have mixed content in many places" may not make sense in this public forum ... it's an internal thing. Please explain it in a more neutral way, and clarify what "mixed content" means.

}
```

An example where this method is used extensively is in *_synopsis.scss*. Because synopsis is an element that can inherit the direction of the site language *or* the direction of the mixed content language (depending on where it appears on the page), its behavior relies only on the language direction explicitly specified on the synopsis container itself.
Copy link
Member

Choose a reason for hiding this comment

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

You can't have references to an internal piece of code in this public repo.

Copy link
Member

Choose a reason for hiding this comment

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

Also, let's hyphenate mixed-content so it reads more clearly.

@pbredenberg
Copy link
Contributor

It would not be terrible for this to get merged sometime soon. kthanksbye

Copy link

@acemuncie acemuncie left a comment

Choose a reason for hiding this comment

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

Please take a look at the changes in this review. Based on our other documentation, I've tried to note where the voice should change from "we" to imperative "you".

@@ -0,0 +1,139 @@
# Styling Code Standards

Sass (file extension .scss) is a language which compiles to CSS. It is a powerful tool in the writing of CSS but does not absolve you as a

Choose a reason for hiding this comment

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

Needs additional wording - language that compiles what to CSS?


## General Standards

Unless there is a compelling reason to use an ID we should always default to using classes [[1]](#references) for styling.

Choose a reason for hiding this comment

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

What about:
Unless there is a compelling reason to use an ID, you should default to classes first for styling [1].


Unless there is a compelling reason to use an ID we should always default to using classes [[1]](#references) for styling.

Code smells [[2]](#references) to watch out for might include:

Choose a reason for hiding this comment

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

What about:
Be wary of these code smells[2]:


Code smells [[2]](#references) to watch out for might include:

* >3 selectors (when compiled)

Choose a reason for hiding this comment

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

What about spelling out > to More than 3 selectors? Otherwise, > needs to be escaped.

Code smells [[2]](#references) to watch out for might include:

* >3 selectors (when compiled)
* Using an ID or !important

Choose a reason for hiding this comment

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

!important should be inline code


### Blank Lines

Follow our blank lines [[8]](#references) standards. There should always be a blank line seperating top level selectors.

Choose a reason for hiding this comment

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

  • s/seperating/separating/
  • s/top level/top-level/


Follow our blank lines [[8]](#references) standards. There should always be a blank line seperating top level selectors.

In most cases multiple selectors in a single block should each be listed on a new line.

Choose a reason for hiding this comment

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

Needs comma after In most cases

* `$color-link--visited`
* `.pm-mediaGroup-top--mobile`
* `.pm-mediaGroup-top--desktop`
* `$color-primButtonBg--hover`

Choose a reason for hiding this comment

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

The above three examples seem like internal names.

```
### References

[1] [http://oli.jp/2011/ids/](http://oli.jp/2011/ids/)

Choose a reason for hiding this comment

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

When viewing the document, these references run together in one line. A linebreak is needed after each reference.


### Directional Content

Often styling needs to consider if the immediate context is being displayed in a left-to-right (LTR) or right-to-left (RTL) manner,

Choose a reason for hiding this comment

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

Can we add some context for when this is needed? Something like:
When content with different writing directions is included on the same page...

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.

4 participants