-
Notifications
You must be signed in to change notification settings - Fork 8
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
scss-coding-standards.md
Outdated
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/writting/writing/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
scss-coding-standards.md
Outdated
* >3 selectors (when compiled) | ||
* ID's or !important | ||
* element.class | ||
* z-index declarations |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
scss-coding-standards.md
Outdated
Some basic [code smells](https://en.wikipedia.org/wiki/Code_smell) might include: | ||
|
||
* >3 selectors (when compiled) | ||
* ID's or !important |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
scss-coding-standards.md
Outdated
|
||
### Naming | ||
|
||
Class and ID names should be **camel case (first word lower-case) and dashes used sparingly**. Example: `.classNameThatsPrettyLong` |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
scss-coding-standards.md
Outdated
|
||
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
scss-coding-standards.md
Outdated
``` | ||
.mainContainer { | ||
.nestedClassOne { | ||
color: Tomato; |
There was a problem hiding this comment.
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; | ||
} | ||
} | ||
// ---------------------- |
There was a problem hiding this comment.
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 ...
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
scss-coding-standards.md
Outdated
} | ||
``` | ||
|
||
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
scss-coding-standards.md
Outdated
} | ||
``` | ||
|
||
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
It would not be terrible for this to get merged sometime soon. kthanksbye |
f907bed
to
564c910
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
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/) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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...
Cleaned up a few things and tried to isolate from any one project example