SlideShare una empresa de Scribd logo
1 de 42
Descargar para leer sin conexión
More of {less}
Guilherme Zühlke O’Connor
The Author
Head of front end development at Snupps
Snupps
We are a B2C, cross platform app on the web and
mobile that helps you organise your stuff.
We are an early stage startup.
We are getting ready to launch.
The problem
When you get to a certain point in life, you
1.
2.
3.
4.

Have too much stuff
Don’t know what you have
Don’t know where it is
Don’t have quick access to the details
The solution
Snupps is the one place for you to store and keep
track of your stuff and have it at your fingertips at
all times.
So, stuff, huh?
Lots of it...
Scattered around...
Difficult to find…
So, stuff, huh?
Lots of it...
Scattered around...
Difficult to find…
Surely I’m not the only one who sees a
resemblance with CSS!
Which begs the question...
Which begs the question...

How on Earth do we organise CSS?
The problem
Easy syntax

Cascading Style Sheets (CSS) is a simple mechanism
for adding style (e.g., fonts, colors, spacing) to Web
documents.”

ttp://www.w3.org/Style/CSS/Overview.en.html

Gentle learning curve
Conceptually minimalistic
The problem
Easy syntax

C”Cascading Style Sheets (CSS) is a simple
mechanism for adding style (e.g., fonts, colors,
spacing) to Web documents.”

http://www.w3.org/Style/CSS/Overview.en.html

Gentle learning curve
Conceptually minimalistic
Also minimal support for software engineering
Simple enough
CSS is simple enough for a simple document, but
today’s average page on a web app is an
amalgamation of several heavily complex design
elements.
Every element may itself depend on an
amalgamation of different techniques, glued
together for the overall effect.
Each element on the page may be used more than
once. Maybe on different pages. Maybe variations
of its basic form.
Oh, did I just say Web App instead of Web
document?
Oh, did I just say Web App instead of Web
document?
Oops...
Compromises
Invariably, writing enough CSS for a website will
require that at least one of the following is
compromised
DRY (Don’t Repeat Yourself)
CSS Modularization
Separation of Concerns (classitis)
Repetition
button.addComment {

button.search {

color: #ccc;
background: #333;

background: #333;

padding: 10px;
}

color: #ccc;
padding: 10px;
}
Don’t Repeat Yourself
Every piece of knowledge must have a single,
unambiguous, authoritative representation within
a system
Poor Grouping
button.addComment,
button.search,
button.login {
color: #ccc;
background: #333;
padding: 10px;
}

.comment .timestamp,
.notification .timestamp,
.creation .timestamp {
color: #ccc;
background: #333;
padding: 10px;
}
DOM pollution and classitis
.button-1 {
color: #ccc;
background: #333;
padding: 10px;
<button class=”addComment button-1”>
}
<button class=”search button-1”>
<button class=”login button-1”>
Enter CSS preprocessing
A CSS preprocessor is an augmentation of the CSS
language that can be run through a script to
generate native CSS a browser can understand.
Why CSS preprocesing?
CSS preprocessing gives the developer tools to
organize their code and create reusable
components. It allows for the code to be grouped
in semantic, logical components that can be
defined elsewhere than where they are being
used.
Variables
@btnColor: #ea5430

button {
background-color: #ea5430;

button {

}

background-color: @btnColor;
}

label {

label {
background-color: @btnColor;
}

background-color: #ea5430;
}
Mixins - browser prefixes
.border-radius(@n: 3px) {
-webkit-border-radius: @n;
-moz-border-radius: @n;
border-radius: @n;
}

button {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

button {
.border-radius();
}

label {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}

label {
.border-radius(5px);
}
Mixins - combined rules
.hide-offscreen() {
position: absolute;
left: -999em;
}

button {
position: absolute;
left: -999em;
}

button {
.hide-offscreen();
}

a.skipToContent {
position: absolute;
left: -999em;
}

a.skipToContent {
.hide-offscreen();
}
Nested Rules
p{

p{
text-indent: 1em;
em {

text-indent: 1em;
}

color: #ea5430;

p em {

}
}

color: #ea5430;
}
The ”&” Combinator
The ”this” of CSS
The “&” Combinator
a{

a{
color: #ea5430;

color: #ea5430;

text-decoration: none;

text-decoration: none;

&:hover {

}

text-decoration: underline;
}

a:hover {

&.someClass {
background-color: #ccc;

text-decoration: underline;
}

}
}

a:someClass {
background-color: #ccc;
}
Going wild...
input[type=checkbox] {

input[type=checkbox] {

.hide-offscreen();

position: absolute;

& + label {

left: -999em;

background-color: #ea5430;

}

&:before {

input[type=checkbox] + label {

content: ””;
.icon();

background-color: #ea5430;
}

}

input[type=checkbox] + label:before { … }

&:hover {

input[type=checkbox] + label:hover { … }

background-color: #cc4b29;
}
&:active {
background-color: #cc4b29;
}
}
}

input[type=checkbox] + label:active { … }
Really wild...
input[type=checkbox] {

input[type=checkbox] {

.hide-offscreen();

position: absolute;

& + label {

left: -999em;

background-color: #ea5430;

}

&:before {…}

input[type=checkbox] + label {

&:hover {…}
&:active {…}

background-color: #ea5430;
}

}

input[type=checkbox] + label:before { … }

&:checked + label {

input[type=checkbox] + label:hover { … }

&:before {…}
&:hover {…}

}

input[type=checkbox]:checked + label:before { … }

&:active {…}
}

input[type=checkbox] + label:active { … }

input[type=checkbox]:checked + label:hover { … }
input[type=checkbox]:checked + label:active { … }
Even backwards...
input[type=checkbox] {

input[type=checkbox] { … }

.style-1();
.someParent & {
.style-2();
}
}

.someParent input[type=checkbox] { … }
Operations
@colorRegular: #ea5430;

@colorRegular: #ea5430;

@colorHover: @colorRegular - #111;
@colorActive: @colorRegular - #222;

@colorHover: #d9431f;

p {color: @colorRegular}
p {color: @colorHover}
p {color: @colorActive}

@colorActive: #c8320e;
All together now!
There’s much more...
Guarded mixins, client side usage, watch mode,
javascript functions, reading parameters from
other properties, debuggable in Web Inspector…
The list goes on.
What about SASS?
Less is not the only CSS preprocessor. There
are different flavours of preprocessors with pros
and cons. What we covered here, can be used
on SASS as well, though the syntax may differ.
Architecture
This presentation is not meant to be an exhaustive
overview of less syntax but a display of how it can
be used to build a powerful CSS architecture for
modern day, complex web apps.
Less is almost as easy to learn as CSS. Go nuts!
Questions?
Guilherme Zühlke O’Connor, London, Nov/2013

Más contenido relacionado

Destacado

Aperture in Photography (or how bokeh happens)
Aperture in Photography (or how bokeh happens)Aperture in Photography (or how bokeh happens)
Aperture in Photography (or how bokeh happens)Guilherme Zühlke O'Connor
 
How Your Camera Works
How Your Camera WorksHow Your Camera Works
How Your Camera Worksalorino
 
White balance
White balanceWhite balance
White balanceMary Haas
 
Light Meter (LM-120)
Light Meter (LM-120)Light Meter (LM-120)
Light Meter (LM-120)NYCCTfab
 
Photography: Apperture, Depth of Field, Focal Length
Photography: Apperture, Depth of Field, Focal LengthPhotography: Apperture, Depth of Field, Focal Length
Photography: Apperture, Depth of Field, Focal LengthJennifer Laluna
 
Making Your Bokeh Fascinating - Real-time Rendering of Physically Based Opti...
Making Your Bokeh Fascinating - Real-time Rendering of Physically Based Opti...Making Your Bokeh Fascinating - Real-time Rendering of Physically Based Opti...
Making Your Bokeh Fascinating - Real-time Rendering of Physically Based Opti...Silicon Studio Corporation
 
Session 7 White Balance (Basic Photography Class)
Session 7 White Balance (Basic Photography Class)Session 7 White Balance (Basic Photography Class)
Session 7 White Balance (Basic Photography Class)Jeremy Eliab
 
Introductory Lecture on photography
Introductory Lecture on photographyIntroductory Lecture on photography
Introductory Lecture on photographyAditya Rao
 

Destacado (9)

Shutterspeed
ShutterspeedShutterspeed
Shutterspeed
 
Aperture in Photography (or how bokeh happens)
Aperture in Photography (or how bokeh happens)Aperture in Photography (or how bokeh happens)
Aperture in Photography (or how bokeh happens)
 
How Your Camera Works
How Your Camera WorksHow Your Camera Works
How Your Camera Works
 
White balance
White balanceWhite balance
White balance
 
Light Meter (LM-120)
Light Meter (LM-120)Light Meter (LM-120)
Light Meter (LM-120)
 
Photography: Apperture, Depth of Field, Focal Length
Photography: Apperture, Depth of Field, Focal LengthPhotography: Apperture, Depth of Field, Focal Length
Photography: Apperture, Depth of Field, Focal Length
 
Making Your Bokeh Fascinating - Real-time Rendering of Physically Based Opti...
Making Your Bokeh Fascinating - Real-time Rendering of Physically Based Opti...Making Your Bokeh Fascinating - Real-time Rendering of Physically Based Opti...
Making Your Bokeh Fascinating - Real-time Rendering of Physically Based Opti...
 
Session 7 White Balance (Basic Photography Class)
Session 7 White Balance (Basic Photography Class)Session 7 White Balance (Basic Photography Class)
Session 7 White Balance (Basic Photography Class)
 
Introductory Lecture on photography
Introductory Lecture on photographyIntroductory Lecture on photography
Introductory Lecture on photography
 

Similar a More of less (take 2)

How to develop frontend application
How to develop frontend applicationHow to develop frontend application
How to develop frontend applicationSeokjun Kim
 
IML 140 Design - Basics
IML 140 Design - BasicsIML 140 Design - Basics
IML 140 Design - BasicsEvan Hughes
 
Clickable DIVs and other icebergs
Clickable DIVs and other icebergsClickable DIVs and other icebergs
Clickable DIVs and other icebergsBen Buchanan
 
I thought you were my friend - Malicious Markup
I thought you were my friend - Malicious MarkupI thought you were my friend - Malicious Markup
I thought you were my friend - Malicious MarkupMario Heiderich
 
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...takeoutweight
 
Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3Todd Zaki Warfel
 
Building a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBuilding a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBen Limmer
 
Web Application Hacking
Web Application HackingWeb Application Hacking
Web Application HackingSensePost
 
Death of a Themer - Frontend United - 14 April 2013
Death of a Themer - Frontend United - 14 April 2013Death of a Themer - Frontend United - 14 April 2013
Death of a Themer - Frontend United - 14 April 2013Matt Fielding
 
Componentization css angular
Componentization css angularComponentization css angular
Componentization css angularDavid Amend
 
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...Axway Appcelerator
 
Accelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemAccelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemWynn Netherland
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQueryAngel Ruiz
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
Rapid web development, the right way.
Rapid web development, the right way.Rapid web development, the right way.
Rapid web development, the right way.nubela
 
CSS in React - Will Change Transform
CSS in React - Will Change TransformCSS in React - Will Change Transform
CSS in React - Will Change TransformJoe Seifi
 
La build your own website september 5
La build your own website september 5La build your own website september 5
La build your own website september 5Thinkful
 

Similar a More of less (take 2) (20)

How to develop frontend application
How to develop frontend applicationHow to develop frontend application
How to develop frontend application
 
IML 140 Design - Basics
IML 140 Design - BasicsIML 140 Design - Basics
IML 140 Design - Basics
 
Clickable DIVs and other icebergs
Clickable DIVs and other icebergsClickable DIVs and other icebergs
Clickable DIVs and other icebergs
 
I thought you were my friend - Malicious Markup
I thought you were my friend - Malicious MarkupI thought you were my friend - Malicious Markup
I thought you were my friend - Malicious Markup
 
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
Haste (Same Language, Multiple Platforms) and Tagless Final Style (Same Synta...
 
Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3
 
Building a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBuilding a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profit
 
Web Application Hacking
Web Application HackingWeb Application Hacking
Web Application Hacking
 
Use atomic design ftw
Use atomic design ftwUse atomic design ftw
Use atomic design ftw
 
Variations on a Theme
Variations on a ThemeVariations on a Theme
Variations on a Theme
 
Death of a Themer - Frontend United - 14 April 2013
Death of a Themer - Frontend United - 14 April 2013Death of a Themer - Frontend United - 14 April 2013
Death of a Themer - Frontend United - 14 April 2013
 
Componentization css angular
Componentization css angularComponentization css angular
Componentization css angular
 
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
Wynn Netherland: Accelerating Titanium Development with CoffeeScript, Compass...
 
Accelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemAccelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gem
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQuery
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
Rapid web development, the right way.
Rapid web development, the right way.Rapid web development, the right way.
Rapid web development, the right way.
 
CSS in React - Will Change Transform
CSS in React - Will Change TransformCSS in React - Will Change Transform
CSS in React - Will Change Transform
 
La build your own website september 5
La build your own website september 5La build your own website september 5
La build your own website september 5
 

Último

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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 Scriptwesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Último (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

More of less (take 2)

  • 1. More of {less} Guilherme Zühlke O’Connor
  • 2. The Author Head of front end development at Snupps
  • 3. Snupps We are a B2C, cross platform app on the web and mobile that helps you organise your stuff. We are an early stage startup. We are getting ready to launch.
  • 4. The problem When you get to a certain point in life, you 1. 2. 3. 4. Have too much stuff Don’t know what you have Don’t know where it is Don’t have quick access to the details
  • 5. The solution Snupps is the one place for you to store and keep track of your stuff and have it at your fingertips at all times.
  • 6. So, stuff, huh? Lots of it... Scattered around... Difficult to find…
  • 7. So, stuff, huh? Lots of it... Scattered around... Difficult to find… Surely I’m not the only one who sees a resemblance with CSS!
  • 8.
  • 9. Which begs the question...
  • 10. Which begs the question... How on Earth do we organise CSS?
  • 11. The problem Easy syntax Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to Web documents.” ttp://www.w3.org/Style/CSS/Overview.en.html Gentle learning curve Conceptually minimalistic
  • 12. The problem Easy syntax C”Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to Web documents.” http://www.w3.org/Style/CSS/Overview.en.html Gentle learning curve Conceptually minimalistic Also minimal support for software engineering
  • 14. CSS is simple enough for a simple document, but today’s average page on a web app is an amalgamation of several heavily complex design elements.
  • 15. Every element may itself depend on an amalgamation of different techniques, glued together for the overall effect.
  • 16. Each element on the page may be used more than once. Maybe on different pages. Maybe variations of its basic form.
  • 17. Oh, did I just say Web App instead of Web document?
  • 18. Oh, did I just say Web App instead of Web document? Oops...
  • 19. Compromises Invariably, writing enough CSS for a website will require that at least one of the following is compromised DRY (Don’t Repeat Yourself) CSS Modularization Separation of Concerns (classitis)
  • 20. Repetition button.addComment { button.search { color: #ccc; background: #333; background: #333; padding: 10px; } color: #ccc; padding: 10px; }
  • 21. Don’t Repeat Yourself Every piece of knowledge must have a single, unambiguous, authoritative representation within a system
  • 22. Poor Grouping button.addComment, button.search, button.login { color: #ccc; background: #333; padding: 10px; } .comment .timestamp, .notification .timestamp, .creation .timestamp { color: #ccc; background: #333; padding: 10px; }
  • 23. DOM pollution and classitis .button-1 { color: #ccc; background: #333; padding: 10px; <button class=”addComment button-1”> } <button class=”search button-1”> <button class=”login button-1”>
  • 25. A CSS preprocessor is an augmentation of the CSS language that can be run through a script to generate native CSS a browser can understand.
  • 26. Why CSS preprocesing? CSS preprocessing gives the developer tools to organize their code and create reusable components. It allows for the code to be grouped in semantic, logical components that can be defined elsewhere than where they are being used.
  • 27. Variables @btnColor: #ea5430 button { background-color: #ea5430; button { } background-color: @btnColor; } label { label { background-color: @btnColor; } background-color: #ea5430; }
  • 28. Mixins - browser prefixes .border-radius(@n: 3px) { -webkit-border-radius: @n; -moz-border-radius: @n; border-radius: @n; } button { -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } button { .border-radius(); } label { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } label { .border-radius(5px); }
  • 29. Mixins - combined rules .hide-offscreen() { position: absolute; left: -999em; } button { position: absolute; left: -999em; } button { .hide-offscreen(); } a.skipToContent { position: absolute; left: -999em; } a.skipToContent { .hide-offscreen(); }
  • 30. Nested Rules p{ p{ text-indent: 1em; em { text-indent: 1em; } color: #ea5430; p em { } } color: #ea5430; }
  • 31. The ”&” Combinator The ”this” of CSS
  • 32. The “&” Combinator a{ a{ color: #ea5430; color: #ea5430; text-decoration: none; text-decoration: none; &:hover { } text-decoration: underline; } a:hover { &.someClass { background-color: #ccc; text-decoration: underline; } } } a:someClass { background-color: #ccc; }
  • 33. Going wild... input[type=checkbox] { input[type=checkbox] { .hide-offscreen(); position: absolute; & + label { left: -999em; background-color: #ea5430; } &:before { input[type=checkbox] + label { content: ””; .icon(); background-color: #ea5430; } } input[type=checkbox] + label:before { … } &:hover { input[type=checkbox] + label:hover { … } background-color: #cc4b29; } &:active { background-color: #cc4b29; } } } input[type=checkbox] + label:active { … }
  • 34. Really wild... input[type=checkbox] { input[type=checkbox] { .hide-offscreen(); position: absolute; & + label { left: -999em; background-color: #ea5430; } &:before {…} input[type=checkbox] + label { &:hover {…} &:active {…} background-color: #ea5430; } } input[type=checkbox] + label:before { … } &:checked + label { input[type=checkbox] + label:hover { … } &:before {…} &:hover {…} } input[type=checkbox]:checked + label:before { … } &:active {…} } input[type=checkbox] + label:active { … } input[type=checkbox]:checked + label:hover { … } input[type=checkbox]:checked + label:active { … }
  • 35. Even backwards... input[type=checkbox] { input[type=checkbox] { … } .style-1(); .someParent & { .style-2(); } } .someParent input[type=checkbox] { … }
  • 36. Operations @colorRegular: #ea5430; @colorRegular: #ea5430; @colorHover: @colorRegular - #111; @colorActive: @colorRegular - #222; @colorHover: #d9431f; p {color: @colorRegular} p {color: @colorHover} p {color: @colorActive} @colorActive: #c8320e;
  • 38. There’s much more... Guarded mixins, client side usage, watch mode, javascript functions, reading parameters from other properties, debuggable in Web Inspector… The list goes on.
  • 39. What about SASS? Less is not the only CSS preprocessor. There are different flavours of preprocessors with pros and cons. What we covered here, can be used on SASS as well, though the syntax may differ.
  • 40. Architecture This presentation is not meant to be an exhaustive overview of less syntax but a display of how it can be used to build a powerful CSS architecture for modern day, complex web apps. Less is almost as easy to learn as CSS. Go nuts!
  • 42. Guilherme Zühlke O’Connor, London, Nov/2013