SlideShare uma empresa Scribd logo
1 de 5
10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab
http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 1/5
Home (/uicoe/eg-empact-scss-styleguide/wikis/home)
Pages (/uicoe/eg-empact-scss-styleguide/wikis/pages)
Git Access (/uicoe/eg-empact-scss-styleguide/wikis/git_access)
Home · last edited by Karthikeyan Rajendran 8 months ago
A reference style guide to develop robust stylesheets in SCSS using any front-end framework
The point of having this style guide is to have a common vocabulary of coding across Emirates
projects, so people (esp. UI devs) can concentrate on what you’re saying rather than on how you’re
saying it. If the code you add to a file looks drastically different from the existing project code, it
throws the devs out of their rhythm when they go to read it. Avoid this.
If you’re editing the code, take a few minutes to look at the code around you and determine its style.
1. General Principles
2. Folder Structure
3. Importing Files
4. Naming conventions
5. Handling Breakpoints
6. Nesting
7. Categorizing CSS-Rules
Todo:
1. Comments
1. Consistent Indentation: 2 spaces per block
2. Consistent spacing before/a er braces/colons
3. One selector per line, one rule per line
4. List related properties together, follow CSS Modal: refer Categorizing CSS-Rules ( width/height,
margin/padding etc.)
5. Use SASS variables as per reusability
6. Remove any Trailing white-spaces as it can complicate diffs.
EG SCSS Style Guide
Table of Contents
General Principles
10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab
http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 2/5
7. Closing brace should be on it's own line.
8. Avoid ID selectors & child selectors
9. Avoid !important
Try using the EG-SASS-SMACSS (http://dolnxprodvm1036/uicoe/eg-empact-smacss) folder
structure only if you are staring a fresh project.
Ignore the EG-SASS-SMACSS directory structure if you are writing styles for components, follow a
modular structure (eg: angular-seed structure) to maintain all the dependencies within the
components. Most importantly, provide a importable link from the components to the project’s
vendor/component structure.
If you have a big project with much modules and variants, then you come to the point to make
thoughts about the current structure. You blow up your file with a bunch of code and it's hard to
maintain it.
Because of this we need a small improvement of the structure and add some folders if you noticed,
that your module need to much lines of code. Then make more small partials and include it in one
main-file for this module.
If a project has multiple partials/template in a given module, always prefer to have one single file
like all.scss or index.scss indexed to the main-file main.scss and then include all
partials/templates. For this I created a structure like in this example:
// MAIN.scss
@import "search/all";
// search/_all.scss inside Search Module
@import "search.css",
"search_summary",
"search_results";
Structure in base, layouts and modules
For each section declare @import only once
Remove file-ending
Use BEM for naming conventions as its gives a lot of flexibility and readability down the line in a
huge project with multiple UI developers pushing out code. SMACSS makes sense on how to
structure and maintain a project, where as BEM relates as the code goes, BEM defines a set or rules
that makes life easier when it comes to reusability and maintainability of the existing code.
Combining these two methods is the best way for a huge team to handle naming conventions.
Folder Structure
Importing files
Brief :
Naming conventions (BEM)
Block, Element, Modifier
10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab
http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 3/5
// Layouts
// Prefix "l-"
.l-default {}
// Modules
// Prefix "m-"
.m-accordion {}
// Child element of accordion
// Seperator: "__"
.m-accordion__trigger {}
// Modifier of accordion
// Seperator: "--"
.m-accordion--plain {}
// States
// Mostly with prefix like "is-"
.is-active {}
.is-hidden {}
"Element Queries" with Sass are so much better than traditional media queries. If you want to the
custom module to be responsive, you should declare the responsive behavior of it there itself, Not
in another file.
// Scss
.m-nav {
&:after {
@media screen and (min-width: $tab-breakpoint) {
content: '';
display: inline-block;
width: 100%;
}
}
li {
display: block;
@media screen and (min-width: tab-breakpoint) {
float: left;
}
}
}
Avoid writing new media queries if you are using any framework which has grid systems in it. Follow
the grid style which the framework uses rather than inventing a new grid system or writing vanilla
code for responsive design.
Handling Breakpoints: Element Queries
Nesting
10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab
http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 4/5
Maximum nesting: three levels deep. Do not make the styles too reliant on HTML structure
(fragile), overly specific (too powerful), and not very reusable (not useful). It's also on the edge of
being difficult to understand & maintain.
The CSS code should be consistent and should be as per the CSS modal rules:
// Element-Base
.element {
margin: 10px;
padding: 10px;
border: 1px solid red;
background: blue;
color: white;
font-size: 16px;
-webkit-transform: translate3d(0,0,0);
}
Box
margin , padding , display , etc.
Border & Background
border , border-radius , background-color and so on
Text
color , font-size , text-transform , etc.
Other stuff
animations , transform 's, ...
Planning to implement SASSDoc (http://sassdoc.com/).
Categorizing CSS-Rules
Comments (Sassdoc)
10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab
http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 5/5

Mais conteúdo relacionado

Semelhante a SCSS Styleguide

Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
David Amend
 

Semelhante a SCSS Styleguide (20)

ZURB Foundation 5: Clean + Organized
ZURB Foundation 5: Clean + OrganizedZURB Foundation 5: Clean + Organized
ZURB Foundation 5: Clean + Organized
 
Developing sites with Magnolia 4 / STK
Developing sites with Magnolia 4 / STKDeveloping sites with Magnolia 4 / STK
Developing sites with Magnolia 4 / STK
 
CSS pattern libraries
CSS pattern librariesCSS pattern libraries
CSS pattern libraries
 
CUST-3 Document Management with Share
CUST-3 Document Management with ShareCUST-3 Document Management with Share
CUST-3 Document Management with Share
 
Cssdoc
CssdocCssdoc
Cssdoc
 
five Sling features you should know
five Sling features you should knowfive Sling features you should know
five Sling features you should know
 
Leveraging the Power of Custom Elements in Gutenberg
Leveraging the Power of Custom Elements in GutenbergLeveraging the Power of Custom Elements in Gutenberg
Leveraging the Power of Custom Elements in Gutenberg
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
ITea&Coffee: React best practices
ITea&Coffee: React best practicesITea&Coffee: React best practices
ITea&Coffee: React best practices
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
 
Efficiently theming a multi-site Drupal 8 portal - Drupal Dev Days Seville 2017
Efficiently theming a multi-site Drupal 8 portal - Drupal Dev Days Seville 2017Efficiently theming a multi-site Drupal 8 portal - Drupal Dev Days Seville 2017
Efficiently theming a multi-site Drupal 8 portal - Drupal Dev Days Seville 2017
 
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented DesignCSMess to OOCSS: Refactoring CSS with Object Oriented Design
CSMess to OOCSS: Refactoring CSS with Object Oriented Design
 
Facets of applied smw
Facets of applied smwFacets of applied smw
Facets of applied smw
 
Drupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating ModulesDrupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating Modules
 
Front end frameworks
Front end frameworksFront end frameworks
Front end frameworks
 
vitepress-en.pdf
vitepress-en.pdfvitepress-en.pdf
vitepress-en.pdf
 
MANAGE STATIC RESOURCES IN SITECORE IN HELIX WAY
MANAGE STATIC RESOURCES IN SITECORE IN HELIX WAYMANAGE STATIC RESOURCES IN SITECORE IN HELIX WAY
MANAGE STATIC RESOURCES IN SITECORE IN HELIX WAY
 
Managing Complex Projects with Design Components - Drupalcon Austin 2014
Managing Complex Projects with Design Components - Drupalcon Austin 2014Managing Complex Projects with Design Components - Drupalcon Austin 2014
Managing Complex Projects with Design Components - Drupalcon Austin 2014
 
Atomic design
Atomic designAtomic design
Atomic design
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 

SCSS Styleguide

  • 1. 10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 1/5 Home (/uicoe/eg-empact-scss-styleguide/wikis/home) Pages (/uicoe/eg-empact-scss-styleguide/wikis/pages) Git Access (/uicoe/eg-empact-scss-styleguide/wikis/git_access) Home · last edited by Karthikeyan Rajendran 8 months ago A reference style guide to develop robust stylesheets in SCSS using any front-end framework The point of having this style guide is to have a common vocabulary of coding across Emirates projects, so people (esp. UI devs) can concentrate on what you’re saying rather than on how you’re saying it. If the code you add to a file looks drastically different from the existing project code, it throws the devs out of their rhythm when they go to read it. Avoid this. If you’re editing the code, take a few minutes to look at the code around you and determine its style. 1. General Principles 2. Folder Structure 3. Importing Files 4. Naming conventions 5. Handling Breakpoints 6. Nesting 7. Categorizing CSS-Rules Todo: 1. Comments 1. Consistent Indentation: 2 spaces per block 2. Consistent spacing before/a er braces/colons 3. One selector per line, one rule per line 4. List related properties together, follow CSS Modal: refer Categorizing CSS-Rules ( width/height, margin/padding etc.) 5. Use SASS variables as per reusability 6. Remove any Trailing white-spaces as it can complicate diffs. EG SCSS Style Guide Table of Contents General Principles
  • 2. 10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 2/5 7. Closing brace should be on it's own line. 8. Avoid ID selectors & child selectors 9. Avoid !important Try using the EG-SASS-SMACSS (http://dolnxprodvm1036/uicoe/eg-empact-smacss) folder structure only if you are staring a fresh project. Ignore the EG-SASS-SMACSS directory structure if you are writing styles for components, follow a modular structure (eg: angular-seed structure) to maintain all the dependencies within the components. Most importantly, provide a importable link from the components to the project’s vendor/component structure. If you have a big project with much modules and variants, then you come to the point to make thoughts about the current structure. You blow up your file with a bunch of code and it's hard to maintain it. Because of this we need a small improvement of the structure and add some folders if you noticed, that your module need to much lines of code. Then make more small partials and include it in one main-file for this module. If a project has multiple partials/template in a given module, always prefer to have one single file like all.scss or index.scss indexed to the main-file main.scss and then include all partials/templates. For this I created a structure like in this example: // MAIN.scss @import "search/all"; // search/_all.scss inside Search Module @import "search.css", "search_summary", "search_results"; Structure in base, layouts and modules For each section declare @import only once Remove file-ending Use BEM for naming conventions as its gives a lot of flexibility and readability down the line in a huge project with multiple UI developers pushing out code. SMACSS makes sense on how to structure and maintain a project, where as BEM relates as the code goes, BEM defines a set or rules that makes life easier when it comes to reusability and maintainability of the existing code. Combining these two methods is the best way for a huge team to handle naming conventions. Folder Structure Importing files Brief : Naming conventions (BEM) Block, Element, Modifier
  • 3. 10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 3/5 // Layouts // Prefix "l-" .l-default {} // Modules // Prefix "m-" .m-accordion {} // Child element of accordion // Seperator: "__" .m-accordion__trigger {} // Modifier of accordion // Seperator: "--" .m-accordion--plain {} // States // Mostly with prefix like "is-" .is-active {} .is-hidden {} "Element Queries" with Sass are so much better than traditional media queries. If you want to the custom module to be responsive, you should declare the responsive behavior of it there itself, Not in another file. // Scss .m-nav { &:after { @media screen and (min-width: $tab-breakpoint) { content: ''; display: inline-block; width: 100%; } } li { display: block; @media screen and (min-width: tab-breakpoint) { float: left; } } } Avoid writing new media queries if you are using any framework which has grid systems in it. Follow the grid style which the framework uses rather than inventing a new grid system or writing vanilla code for responsive design. Handling Breakpoints: Element Queries Nesting
  • 4. 10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 4/5 Maximum nesting: three levels deep. Do not make the styles too reliant on HTML structure (fragile), overly specific (too powerful), and not very reusable (not useful). It's also on the edge of being difficult to understand & maintain. The CSS code should be consistent and should be as per the CSS modal rules: // Element-Base .element { margin: 10px; padding: 10px; border: 1px solid red; background: blue; color: white; font-size: 16px; -webkit-transform: translate3d(0,0,0); } Box margin , padding , display , etc. Border & Background border , border-radius , background-color and so on Text color , font-size , text-transform , etc. Other stuff animations , transform 's, ... Planning to implement SASSDoc (http://sassdoc.com/). Categorizing CSS-Rules Comments (Sassdoc)
  • 5. 10/5/2016 Home · Wiki · uicoe / eg-empact-scss-styleguide · GitLab http://dolnxprodvm1036/uicoe/eg-empact-scss-styleguide/wikis/home 5/5