Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 3ee6813

Browse files
committed
Update preferred sort order for CSS properties.
1 parent ff30167 commit 3ee6813

1 file changed

Lines changed: 113 additions & 74 deletions

File tree

css/Readme.md

Lines changed: 113 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This document outlines the way Customer Success team is expected to write their
22

33
# Philosophy
44

5-
The Customer Success team uses the SCSS syntax. If you're not familiar with SASS/SCSS, you should take the time to read up on the documentation before you dive into our styles.
5+
The Customer Success team uses the SCSS syntax. If you're not familiar with Sass/SCSS, you should take the time to read up on the documentation before you dive into our styles.
66

77
We strive to write extremely modular, object-oriented CSS that will work in as many situations as possible. We also know that sometimes our clients' markup does not allow for this. With those two things in mind, we've come up with a strategy for writing CSS that will help us write faster and better the first time while still being maintainable for new people entering a project.
88

@@ -24,18 +24,26 @@ The first thing you'll notice when going through Customer Success's CSS is that
2424
## Format
2525
Please use consistent formatting following these rules:
2626
* One selector per line
27+
* Use hyphenated lowercase for selector names
2728
* Use a soft indent of four spaces
28-
* Use one space between selector and first bracket
29-
* Use one space between property and value after :
29+
* Use one space between the selector and opening brace of a declaration block
30+
* Use no space between property and :
31+
* Use one space after the colon in a property declaration
3032
* Always add a semicolon after property value
3133
* Use single quotes
32-
* Do not specify units for a zero value
34+
* Always use quotes around urls
35+
* Do not specify units on a value of zero
36+
* Omit leading zeros for decimals in the range 0..1, i.e. prefer .5 over 0.5
37+
* Avoid selectors with more than three levels, e.g. `ul > li > a` is OK, but `ul > li > a > span` is not (except when targeting client markup).
3338
* Include a space after each comma in a comma separated property list
3439
* User lowercase and shorthand hex values, e.g., #aaa
35-
* Always use hex values unless you are declaring rgba.
36-
* Separate each ruleset by an empty line
40+
* Always use hex values unless you are declaring rgba or hsla.
41+
* Don’t pad parentheses with whitespace, e.g. `linear-gradient(to bottom, #fff, #000)`, not `linear-gradient( to bottom, #fff, #000 )`.
3742
* Separate each declaration block by an empty line
43+
* Separate each rule group by an empty line (see examples)
3844
* Use // for comment blocks (instead of /* */)
45+
* Place Sass `@else` statements on the same line as the closing brace of the preceding `@if`.
46+
* Always include a blank newline at the end of files.
3947

4048
```scss
4149
.x-selector1,
@@ -50,98 +58,129 @@ Please use consistent formatting following these rules:
5058
.x-selector-a,
5159
.x-selector-b {
5260
padding: 10px;
53-
background: rgba(255, 255, 255, 0.25);
61+
background: rgba(255, 255, 255, 0.25);
5462
}
5563
```
5664

5765
## Declaration Order
5866

59-
All properties should be consistently ordered according to the following standard.
67+
All properties should be consistently ordered according to the following standard. Include a newline between these groups.
6068

61-
>Property specific mixins live where the expanded property would live. For example, if you're using a background–image mixin, that should live in the Visual Styles block instead of in the standard includes section.
62-
63-
1. Extends
64-
1. Mixins/Includes (except for property specific mixins)
65-
1. Position
66-
1. Display & Box Model
67-
1. Visual Styles
69+
1. Extends (`@extend`)
70+
1. Mixins (`@include`)
71+
1. Generated content & CSS counters
72+
1. Positioning
73+
1. Display, layout modes & box model
74+
1. Visual styles
6875
1. Text Styles
69-
1. Vendor Prefixed Styles
70-
1. Animations & Transitions
71-
1. Pseudo-classes
76+
1. Transforms
77+
1. Transitions & animations
78+
1. Browser UI adjustments
79+
1. Non-standard properties
80+
1. Pseudo-classes & states
7281
1. Pseudo-elements
73-
1. Modifier elements
74-
1. Child elements
82+
1. BEM Modifiers
83+
1. Descendents
7584

7685
```scss
7786
.x-selector {
78-
// Extends
79-
@extend %x-extend;
87+
// Extends
88+
@extend %x-extend;
8089

81-
// Includes
82-
@include mixin();
90+
// Include mixins
91+
@include mixin();
8392

84-
// Content
85-
content: '\25B6';
93+
// Content
94+
content: '\25B6';
95+
quotes: quotes: '' '' '' '';
96+
counter-reset: my-counter
97+
counter-increment: my-counter;
8698

8799
// Positioning
88100
position: absolute;
89-
left: 10px;
90-
z-index: 10;
101+
top: 10px;
102+
right: 10px;
103+
left: 10px;
104+
z-index: 100;
91105

92106
// Display & Box Model
93-
display: inline-block;
107+
display: flex;
94108
overflow: hidden;
109+
float: left;
110+
clear: both;
111+
table-layout: fixed;
112+
flex-flow: row wrap;
113+
align-items: center;
114+
flex: 1 1 auto;
115+
order: 1;
95116
box-sizing: border-box;
96117
width: 100px;
118+
min-width: 0;
97119
height: 100px;
98-
margin: 10px;
99-
padding: 10px;
100-
border: 1px solid #333;
120+
max-height: none;
121+
margin: 10px;
122+
padding: 10px;
123+
border: 1px solid #333;
101124

102125
// Visual styles
126+
visibility: visible;
127+
opacity: 1;
128+
border-radius: 10px;
103129
background: #000;
104-
border-radius: 10px;
105-
@include box-shadow(5px 5px 0 rgba(0, 0, 0, 0);
106-
107-
// Text styles
130+
box-shadow: 5px 5px 0 rgba(0, 0, 0, 0);
131+
outline: 2px solid #039;
132+
133+
// Text styles
108134
color: #fff;
109135
font-family: sans-serif;
110136
font-size: 16px;
137+
line-height: 1.5;
111138
text-align: right;
112-
113-
// Vendor prefixed styles
114-
-webkit-user-select: none;
115-
-webkit-tap-highlight: rgba(0, 0, 0, 0);
116-
117-
// Styles that don't fall under any of the above categories
118-
pointer-events: none;
119-
120-
// Animations & Transitions
121-
transition: all 0.2s;
139+
list-syle: none;
140+
141+
// Transforms
142+
transform: translate3d(0, 0, 0);
143+
perspective: 1000;
144+
backface-visibility: hidden;
145+
146+
// Transitions & animations
147+
transition: all 0.2s;
148+
animation-name: foo;
149+
150+
// Browser UI
151+
user-select: none;
152+
resize: vertical;
153+
pointer-events: none;
154+
155+
// Non-standard properties
156+
-webkit-appearance: none;
157+
-webkit-overflow-scrolling: touch;
158+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
122159

123-
// Pseudo-classes
124-
&:active {
125-
background: blue;
126-
}
127-
&:last-child {
128-
border-top: 1px solid blue;
129-
}
160+
// Pseudo-classes and states
161+
&:active {
162+
background: blue;
163+
}
164+
165+
&:last-child {
166+
border-top: 1px solid blue;
167+
}
130168

131-
// Pseudo-elements
132-
&::before {
133-
content: 'CSS Rules!';
134-
}
169+
// Pseudo-elements
170+
&::before {
171+
content: 'CSS Rules!';
172+
}
135173

136-
// Modifier Elements
137-
&.x--light {
138-
background: #999;
139-
}
174+
// BEM Modifiers
175+
&.x--light {
176+
background: #999;
177+
}
140178

141-
// Child Elements
142-
span {
143-
font-weight: bold;
144-
}
179+
// Descendents (selecting client markup)
180+
> .child,
181+
.descendent {
182+
font-weight: bold;
183+
}
145184
}
146185
```
147186

@@ -151,21 +190,21 @@ Sometimes we break out of this convention to add to the readability of our style
151190

152191
```scss
153192
.x-selector {
154-
@include icon(
155-
home,
156-
$color: blue,
157-
$size: 15px
158-
);
193+
@include icon(
194+
home,
195+
$color: blue,
196+
$size: 15px
197+
);
159198

160-
transition:
161-
opacity 0.2s ease-in-out,
162-
width 0.5s linear;
199+
transition:
200+
opacity 0.2s ease-in-out,
201+
width 0.5s linear;
163202
}
164203
```
165204

166205
## Preprocessor/SCSS Guidelines
167206

168-
As mentioned earlier, we use SASS and Compass to build our CSS. We have some guidelines when using these guys.
207+
As mentioned earlier, we use Sass and Compass to build our CSS. We have some guidelines when using these guys.
169208

170209
### General
171210

0 commit comments

Comments
 (0)