SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
HOWTOWRITECLEAN&SCALABLECODE
CSSARCHITECTURE
.mat.czajka@gmail.com /czajkovsky
MateuszCzajka-seniordev@netguru.co
IT’SCSSWITHSUPERPOWERS
USEPREPROCESSORS
0.
ANDBECONSISTENTABOUTIT
DEFINEASTYLEGUIDE
1.
DEFINEASTYLEGUIDESCSSLINT
.pill-box {
&__icon{
display: block;
border: 1px solid $primary-color;
}
}
.pill-box {
&__icon{
display: block;
border: 1px solid $primary-color;
}
}
2 of 5 errors: SpaceBeforeBrace: Opening curly `{` should be
preceded by one space, Line 38, Column 8
DEFINEASTYLEGUIDEHOUND
+ =SCSSLINT
THATYOUNEEDTOSUPPORT
DETERMINEBROWSERS
2.
DETERMINEBROWSERSAUTOPREFIXER
// in code
a {
display: flex;
}
// output
a {
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex
}
INTOSMALLPIECES
DIVIDEYOURCODE
3.
ASMANYASITMAKESSENSE
USEVARIABLES
4.
USEVARIABLESBASICS
// colors
$primary-color: #4391d7;
// font-sizes
$fs-1: 12px;
$fs-2: 14px;
// font-families
$ff-open-sans:$ff-open-sans: 'Open Sans', sans-serif;
// font-weights
$fw-bold: 700;
USEVARIABLESZINDEXES
// view/component
.settings-modal {
// ...
z-index: $z-index-settings-modal;
}
.avatar-popover {
// ...
z-index: $z-index-avatar-popover;
}
USEVARIABLESZINDEXES
// _z-index-variables.scss
$z-index-1: 1000;
$z-index-2: 2000;
// ...
$z-index-9: 9000;
// ...
$z-index-settings-modal:$z-index-settings-modal: $z-index-5;
$z-index-avatar-popover: $z-index-6;
ITREALLYHELPSTOKEEPYOURCODEDRY
USEMIXINS&EXTENDS
5.
USEMIXINS&EXTENDSMIXINS
// Sass
.box {
@include absolute(top 5px left 10px);
@include sizing(100% 50px);
}
// CSS
.box.box {
position: absolute;
top: 5px;
left: 10px;
width: 100%;
height: 50px;
}
USEMIXINS&EXTENDSEXTENDS
// Sass
%error {
background: $error-color;
}
.error {
@extend %error;
border-width: 1px;
&--important {
@extend %error;
border-width: 3px;
}
}
// CSS
.error,
.error--important {
background: #f00;
}
.error {
border-width: 1px;
}
.error--important {
border-width: 3px;
}
THINKABOUTRETINAUSERS
USEVECTORS
6.
BUTUSEITTHESMARTWAY
USEAFRAMEWORK
7.
USEAFRAMEWORKSTRUCTURE
framework
├── _components.scss
├── _overrides.scss
├── _variables.scss
└── overrides
└── _framework-overrides-go-here.scss
USEAFRAMEWORKCOMPONENTS
// framework/_components.scss
// Core CSS
@import "bootstrap/scaffolding";
@import "bootstrap/type";
// @import "bootstrap/code";
@import "bootstrap/grid";
// @import "bootstrap/tables";// @import "bootstrap/tables";
@import "bootstrap/forms";
// @import "bootstrap/buttons";
// ...
USEFRAMEWORKVARIABLES
// variables from package/GEM
$gray-base: #eee !default;
$gray-darker: darken($gray-base, 10%) !default;
// etc...
// framework/_variables.scss (overrides)
// $gray-base: #eee !default;
$gray-darker:$gray-darker: darken($gray-base, 20%);
// etc...
USEAFRAMEWORKOVERRIDES
// framework/_overrides.scss
// Core CSS
// @import "overrides/scaffolding";
// @import "overrides/type";
// @import "overrides/code";
@import "overrides/grid";
// @import "overrides/tables";// @import "overrides/tables";
@import "overrides/forms";
// @import "overrides/buttons";
// ...
STRUCTUREANDORDER
THERESULT
THERESULTSTRUCTURE
├── application.scss
├── components
│ └── _your-custom-components-go-here.scss
├── views
│ └── _your-view-based-styles-go-here.scss
├── framework
│ ├──│ ├── _components.scss
│ ├── _overrides.scss
│ ├── _variables.scss
│ └── overrides
│ └── _framework-overrides-go-here.scss
├── settings
│ ├── _z-index-variables.scss
│ ├──│ ├── _breakpoint-variables.scss
│ └── _custom-variables.scss
└── utilities
├── _functions.scss
├── _mixins.scss
├── _shared.scss
└── _typography.scss
THERESULTSTRUCTURE
@import 'settings/z-index-variables';
@import 'settings/variables';
@import 'framework/variables';
@import 'framework/components';
@import 'settings/breakpoint-variables';
@import 'utilities/functions';
@import@import 'utilities/mixins';
@import 'utilities/shared';
@import 'utilities/typography';
@import 'framework/overrides';
@import 'components/first-component';
// more components
@import 'views/home';
// more views// more views
Q&A
THANKYOU
.mat.czajka@gmail.com /czajkovsky
MateuszCzajka-seniordev@netguru.co

Más contenido relacionado

Destacado

Paradygmaty Programowania: Czy Istnieje Najlepszy?
Paradygmaty Programowania: Czy Istnieje Najlepszy?Paradygmaty Programowania: Czy Istnieje Najlepszy?
Paradygmaty Programowania: Czy Istnieje Najlepszy?
Netguru
 
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, NetguruRozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Biznes 2.0
 
Blogi w firmie
Blogi w firmieBlogi w firmie
Blogi w firmie
Netguru
 

Destacado (16)

Paradygmaty Programowania: Czy Istnieje Najlepszy?
Paradygmaty Programowania: Czy Istnieje Najlepszy?Paradygmaty Programowania: Czy Istnieje Najlepszy?
Paradygmaty Programowania: Czy Istnieje Najlepszy?
 
Why no one is looking for rockstar programmers (updated version)
Why no one is looking for rockstar programmers (updated version)Why no one is looking for rockstar programmers (updated version)
Why no one is looking for rockstar programmers (updated version)
 
Everyday Rails
Everyday RailsEveryday Rails
Everyday Rails
 
Hidden Gems in Swift
Hidden Gems in SwiftHidden Gems in Swift
Hidden Gems in Swift
 
Czy Project Manger Musi Być Osobą Techniczną?
Czy Project Manger Musi Być Osobą Techniczną?Czy Project Manger Musi Być Osobą Techniczną?
Czy Project Manger Musi Być Osobą Techniczną?
 
Agile Retrospectives
Agile RetrospectivesAgile Retrospectives
Agile Retrospectives
 
Z 50 do 100 w ciągu roku Jak rekrutować w IT?
Z 50 do 100 w ciągu roku Jak rekrutować w IT?Z 50 do 100 w ciągu roku Jak rekrutować w IT?
Z 50 do 100 w ciągu roku Jak rekrutować w IT?
 
KISS Augmented Reality
KISS Augmented RealityKISS Augmented Reality
KISS Augmented Reality
 
Defining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using RubyDefining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using Ruby
 
Communication With Clients Throughout The Project
Communication With Clients Throughout The ProjectCommunication With Clients Throughout The Project
Communication With Clients Throughout The Project
 
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, NetguruRozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
 
From Birds To Bugs: Testowanie Z Pasją
From Birds To Bugs: Testowanie Z PasjąFrom Birds To Bugs: Testowanie Z Pasją
From Birds To Bugs: Testowanie Z Pasją
 
Blogi w firmie
Blogi w firmieBlogi w firmie
Blogi w firmie
 
Ruby Rails Overview
Ruby Rails OverviewRuby Rails Overview
Ruby Rails Overview
 
How To Build Great Relationships With Your Clients
How To Build Great Relationships With Your ClientsHow To Build Great Relationships With Your Clients
How To Build Great Relationships With Your Clients
 
Payments integration: Stripe & Taxamo
Payments integration: Stripe & TaxamoPayments integration: Stripe & Taxamo
Payments integration: Stripe & Taxamo
 

Similar a CSS architecture: How To Write Clean & Scalable Code

Building a fast web experience [beta]
Building a fast web experience [beta]Building a fast web experience [beta]
Building a fast web experience [beta]
Kirk Yamamoto
 
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Techsylvania
 

Similar a CSS architecture: How To Write Clean & Scalable Code (20)

Bluespec Tutorial Helloworld
Bluespec Tutorial HelloworldBluespec Tutorial Helloworld
Bluespec Tutorial Helloworld
 
What I discovered about layout vis CSS Grid
What I discovered about layout vis CSS GridWhat I discovered about layout vis CSS Grid
What I discovered about layout vis CSS Grid
 
Aaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security TeamsAaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security Teams
 
Advanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection ProtectionAdvanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection Protection
 
Cipher block modes
Cipher block modesCipher block modes
Cipher block modes
 
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
 
Building a fast web experience [beta]
Building a fast web experience [beta]Building a fast web experience [beta]
Building a fast web experience [beta]
 
Sq lite python tutorial sqlite programming in python
Sq lite python tutorial   sqlite programming in pythonSq lite python tutorial   sqlite programming in python
Sq lite python tutorial sqlite programming in python
 
фабрика Blockly
фабрика Blocklyфабрика Blockly
фабрика Blockly
 
Dbms lab Manual
Dbms lab ManualDbms lab Manual
Dbms lab Manual
 
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
Cristiano Betta (Betta Works) - Lightweight Libraries with Rollup, Riot and R...
 
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
PostgreSQL as seen by Rubyists (Kaigi on Rails 2022)
 
vgg.pdf
vgg.pdfvgg.pdf
vgg.pdf
 
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
 
Fpga creating counter with external clock
Fpga   creating counter with external clockFpga   creating counter with external clock
Fpga creating counter with external clock
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Plugins
 
Checking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xChecking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-x
 
Silicon scanners cambridge report
Silicon scanners cambridge reportSilicon scanners cambridge report
Silicon scanners cambridge report
 
cscript_controller.pdf
cscript_controller.pdfcscript_controller.pdf
cscript_controller.pdf
 
Star bed 2018.07.19
Star bed 2018.07.19Star bed 2018.07.19
Star bed 2018.07.19
 

Más de Netguru

Coffeescript presentation DublinJS
Coffeescript presentation DublinJSCoffeescript presentation DublinJS
Coffeescript presentation DublinJS
Netguru
 
Barcamps in Europe
Barcamps in EuropeBarcamps in Europe
Barcamps in Europe
Netguru
 
Wiktor Schmidt, RuPy 2008, Caching in Rails
Wiktor Schmidt, RuPy 2008, Caching in RailsWiktor Schmidt, RuPy 2008, Caching in Rails
Wiktor Schmidt, RuPy 2008, Caching in Rails
Netguru
 
Barcamp #5 - API
Barcamp #5 - APIBarcamp #5 - API
Barcamp #5 - API
Netguru
 
Barcamp #5 - Mikrocelebryci
Barcamp #5 - MikrocelebryciBarcamp #5 - Mikrocelebryci
Barcamp #5 - Mikrocelebryci
Netguru
 

Más de Netguru (15)

Estimation myths debunked
Estimation myths debunkedEstimation myths debunked
Estimation myths debunked
 
Programming Paradigms Which One Is The Best?
Programming Paradigms Which One Is The Best?Programming Paradigms Which One Is The Best?
Programming Paradigms Which One Is The Best?
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails Intro
 
Perfect Project Read Me (in a few steps)
Perfect Project Read Me (in a few steps)Perfect Project Read Me (in a few steps)
Perfect Project Read Me (in a few steps)
 
The Git Basics
The Git BasicsThe Git Basics
The Git Basics
 
From nil to guru: intro to Ruby on Rails
From nil to guru: intro to Ruby on RailsFrom nil to guru: intro to Ruby on Rails
From nil to guru: intro to Ruby on Rails
 
Working With Teams Across The Borders
Working With Teams Across The BordersWorking With Teams Across The Borders
Working With Teams Across The Borders
 
Front-End Dev Tools
Front-End Dev ToolsFront-End Dev Tools
Front-End Dev Tools
 
OOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsOOScss Architecture For Rails Apps
OOScss Architecture For Rails Apps
 
Coffeescript presentation DublinJS
Coffeescript presentation DublinJSCoffeescript presentation DublinJS
Coffeescript presentation DublinJS
 
Developing a webdevelopment company
Developing a webdevelopment companyDeveloping a webdevelopment company
Developing a webdevelopment company
 
Barcamps in Europe
Barcamps in EuropeBarcamps in Europe
Barcamps in Europe
 
Wiktor Schmidt, RuPy 2008, Caching in Rails
Wiktor Schmidt, RuPy 2008, Caching in RailsWiktor Schmidt, RuPy 2008, Caching in Rails
Wiktor Schmidt, RuPy 2008, Caching in Rails
 
Barcamp #5 - API
Barcamp #5 - APIBarcamp #5 - API
Barcamp #5 - API
 
Barcamp #5 - Mikrocelebryci
Barcamp #5 - MikrocelebryciBarcamp #5 - Mikrocelebryci
Barcamp #5 - Mikrocelebryci
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 

CSS architecture: How To Write Clean & Scalable Code