SlideShare une entreprise Scribd logo
1  sur  41
The New UI 
Staying Strong with 
Flexbox, SASS, and 
{{Mustache}} 
1. Install Koala. 
http://koala-app.com/ 
(for Windows, Mac, Linux) 
Prep: 
2. Get source code zip file. 
https://github.com/ecarlisle/TheNewUI 
3. Pick any editor.
Who’s This Guy? 
Name: 
Craft: 
Crew: 
Locale: 
XP: 
Eric Carlisle 
UI / UX Architect 
Lookingglass - http://www.lgscout.com 
Baltimore, MD
Agenda 
∙ General Best Practices 
∙ SASS – variables, nesting, mixins, extensions 
∙ CSS Flexible Box Layout & responsive design 
∙ {{ mustache }} templating 
∙ Q/A
General Best Practices 
K 
I 
S 
S 
(Not quite what you think it means)
General Best Practices 
Keep 
It 
Stunningly 
Simple
General Best Practices 
K 
I 
S 
S 
Projects assets can be: 
∙ Approachable 
∙ Reusable 
∙ Maintainable 
∙ Self Documenting
General Best Practices 
K 
I 
S 
S 
Projects assets can 
be: 
Cost Saving! 
(Simple doesn’t have to be 
boring)
General Best Practices 
Ideal Project Execution
General Best Practices 
Ideal Project Execution 
Bare Necessity Comprehensiveness
General Best Practices 
Ideal Project Execution 
Mediocrity? Indulgence?
General Best Practices 
Ideal Project Execution 
Hacking Architecture
General Best Practices 
The right tool for the job.
SASS 
Stands for: 
Syntactically Awesome Style Sheets
SASS 
Stands for: 
Syntactically Awesome Style Sheets 
It is a: 
CSS Extension Language 
(a.k.a. CSS Preprocessor)
SASS 
Stands for: 
Syntactically Awesome Style Sheets 
It is a: 
CSS Extension Language 
(a.k.a. CSS Preprocessor) 
Ultimately: 
Keeps CSS Maintainable
Why do we need SASS? 
CSS Can Be: 
∙ Repetitive 
∙ Verbose 
∙ Inconsistently supported 
∙ A precedence nightmare 
∙ Not scalable
Why do we need SASS? 
SASS can make CSS: 
∙ DRY (don’t repeat yourself) 
∙ Modular 
∙ Reusable 
∙ Scalable 
Also see CSS frameworks like SMACSS (https://smacss.com)
SASS or SCSS Formatting? 
We will be using SCSS 
More Info: http://thesassway.com/editorial/sass-vs-scss-which-syntax-is-better
SASS Variables 
Name, value pairs. 
Examples: 
$font-stack: Lato, Helvetica, sans-serif; 
$blue: #369; 
$light-blue: lighten($blue, 40); // #b3cce6 
$font-size: 10px; 
$big-font-size: $font-size + 8px; // 18px 
Fun Color Function Tool: http://sassme.arc90.com/
SASS Nesting 
Source: 
nav { 
ul { 
list-style: none; 
li { 
display: inline-block; 
} 
} 
} 
Compiled: 
nav ul { 
list-style: none; 
} 
nav ul li { 
display: inline-block; 
} 
Creating a visual hierarchy
SASS Mixins 
For dynamic selector attributes 
Source: 
@mixin border-radius ($radius) { 
- webkit-border-radius: $radius; 
- moz-border-radius: $radius; 
-ms-border-radius: $radius; 
border-radius: $radius; 
} 
nav { 
border: solid 1px black; 
@include border-radius(5px); 
} 
Compiled: 
nav { 
border: solid 1px black; 
- webkit-border-radius: 5px; 
- moz-border-radius: 5px; 
-ms-border-radius: 5px; 
border-radius: 5px; 
}
SASS Extends 
Assigning inheritance (and keeping it clean) 
Source: 
.message { 
border: solid 1px #333; 
color: #FFFF; 
} 
.confirmation { 
@extend .message; 
background: #0F0; 
} 
.error { 
@extend .message; 
background: #F00; 
} 
Compiled: 
.message, .confirmation, .error { 
border: solid 1px #333; 
color: #FFFF; 
} 
.confirmation { 
background: #0F0; 
} 
.error{ 
background: #F00; 
}
Let’s Code!
Flexbox Layout
Flexbox Layout 
// Old version 
display: box; 
// Oldish version 
display: flexbox; 
// Today... 
display: flex;
Flexbox Layout 
// Old version 
display: box; 
// Oldish version 
display: flexbox; 
WC3 Working Draft 
http://dev.w3.org/csswg/css-flexbox/ 
// Today... 
display: flex; 
Browser Support 
http://caniuse.com/#feat=flexbox
What is Flexbox? 
“Aims at providing a more efficient way to lay out, 
align and distribute space among items in a 
container, even when their size is unknown and/or 
dynamic” 
http://css-tricks.com/snippets/css/a-guide-to-flexbox/
Why Flexbox? 
How can our content flow? 
<!– Block elements flow Vertically. --> 
<div></div> 
<div></div> 
<div></div> 
<!– Inline elements flow horizontally. --> 
<span></span> 
<span></span> 
<span></span> 
<!-- Flex elements flow... Well, it depends! :-) --> 
<container style=“display: flex”> 
<item></item> 
<item></item> 
<item></item> 
</container> 
*drumroll* 
? 
?
Why Flexbox? 
What about dimension? Space distribution? Alignment? 
<!– Things can get complicated pretty fast with CSS! --> 
<div> 
<div style=“float: left; margin: 10px; width: 200px”></div> 
<div style=“float: left: margin: 20px; padding: 10px; width: 4em”></div> 
<div style=“float: right; margin: 0; width: 50%></div> 
<div style=“clear: both”></div> 
</div>
Why Flexbox? 
Floats? Clears? Padding? Margins? 
What happens when... 
<!– Things can get chaotic in a hurry... --> 
<div> 
<div style=“float: left; margin: 10px; width: 200px”></div> 
<div style=“float: ∙ left: Different margin: 20px; padding: Screens? 
10px; width: 4em”></div> 
<div style=“float: right; margin: 0; width: 50%></div> 
<div style=“clear: both”></div> 
</div> 
∙ Different (dynamic) content? 
∙ Design Changes?
Why Flexbox? 
Responsive Frameworks to the rescue?
Why Flexbox? 
Responsive Frameworks to the rescue? 
BRILLIANT but… 
…Still pretty complicated!!!
The Flexbox Layout Box Model 
Dual axis flow!
The Flexbox Layout Box Model 
http://css-tricks.com/snippets/css/a-guide-to-flexbox/
Let’s Code!
{{Mustache}} 
{
Mustache.js 
Logicless Templating 
<!-- Example --> 
<script> 
data = {“name”: “Guy Incognito”, 
“company”: “Horizons Unlimited Ltd.”} 
output = Mustache.render(“Hello {{name}} from {{Company}}!”,data); 
</script>
Mustache.js 
Using an HTML script template 
<div id=“greeting”></div> 
<script> 
$template = $(“#template”).html(); 
data = {“name”: “Guy Incognito”, 
“company”: “Horizons Unlimited Ltd.”} 
output = Mustache.render($template ,data); 
</script> 
<script id=“template” type=“x-tmpl-mustache”> 
<p>Hello {{name}} from {{Company}}!</p> 
</script>
Let’s Code!
Q&A 
eric@ericcarlisle.com 
http://www.twitter.com/eric_carlisle 
http://www.slideshare.net/ericcarlisle

Contenu connexe

Tendances

HTML5 Web Workers-unleashed
HTML5 Web Workers-unleashedHTML5 Web Workers-unleashed
HTML5 Web Workers-unleashed
Peter Lubbers
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
taggg
 

Tendances (20)

It's a Mod World - A Practical Guide to Rocking Modernizr
It's a Mod World - A Practical Guide to Rocking ModernizrIt's a Mod World - A Practical Guide to Rocking Modernizr
It's a Mod World - A Practical Guide to Rocking Modernizr
 
Mastering Grunt
Mastering GruntMastering Grunt
Mastering Grunt
 
Extending Custom Post Types
Extending Custom Post Types Extending Custom Post Types
Extending Custom Post Types
 
Don't Over-React - just use Vue!
Don't Over-React - just use Vue!Don't Over-React - just use Vue!
Don't Over-React - just use Vue!
 
SocketStream
SocketStreamSocketStream
SocketStream
 
Rapid Testing, Rapid Development
Rapid Testing, Rapid DevelopmentRapid Testing, Rapid Development
Rapid Testing, Rapid Development
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 
HTML5 Web Workers-unleashed
HTML5 Web Workers-unleashedHTML5 Web Workers-unleashed
HTML5 Web Workers-unleashed
 
Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015
Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015
Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015
 
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
So You Want to Build and Release a Plugin? WordCamp Lancaster 2014
 
jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013
 
Bower - A package manager for the web
Bower - A package manager for the webBower - A package manager for the web
Bower - A package manager for the web
 
HTTP 2.0 - Web Unleashed 2015
HTTP 2.0 - Web Unleashed 2015HTTP 2.0 - Web Unleashed 2015
HTTP 2.0 - Web Unleashed 2015
 
Learning jQuery @ MIT
Learning jQuery @ MITLearning jQuery @ MIT
Learning jQuery @ MIT
 
Responsive Design with WordPress (WCPHX)
Responsive Design with WordPress (WCPHX)Responsive Design with WordPress (WCPHX)
Responsive Design with WordPress (WCPHX)
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
 
Yuihacku iitd-sumana
Yuihacku iitd-sumanaYuihacku iitd-sumana
Yuihacku iitd-sumana
 
Getting started with flexbox
Getting started with flexboxGetting started with flexbox
Getting started with flexbox
 
BOOM Performance
BOOM PerformanceBOOM Performance
BOOM Performance
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's Encrypt
 

En vedette

Roberto Marras - An unusual portfolio
Roberto Marras - An unusual portfolioRoberto Marras - An unusual portfolio
Roberto Marras - An unusual portfolio
Roberto Marras
 
English projects
English projectsEnglish projects
English projects
andygc25
 
Projekt anglisht
Projekt anglishtProjekt anglisht
Projekt anglisht
Ueda Rrukaj
 

En vedette (20)

Roberto Marras - An unusual portfolio
Roberto Marras - An unusual portfolioRoberto Marras - An unusual portfolio
Roberto Marras - An unusual portfolio
 
Start With Strengths - Canadian Association of Principals 2015
Start With Strengths - Canadian Association of Principals 2015Start With Strengths - Canadian Association of Principals 2015
Start With Strengths - Canadian Association of Principals 2015
 
Project Petersburg: An Xbox Kinect Ballet Videogame Proposal
Project Petersburg: An Xbox Kinect Ballet Videogame ProposalProject Petersburg: An Xbox Kinect Ballet Videogame Proposal
Project Petersburg: An Xbox Kinect Ballet Videogame Proposal
 
Beyond the Toolkit (Nathan Curtis at Enterprise UX 2016)
Beyond the Toolkit (Nathan Curtis at Enterprise UX 2016)Beyond the Toolkit (Nathan Curtis at Enterprise UX 2016)
Beyond the Toolkit (Nathan Curtis at Enterprise UX 2016)
 
Stop disabling SELinux!
Stop disabling SELinux!Stop disabling SELinux!
Stop disabling SELinux!
 
First-time users, longtime strategies: Why Parkinson’s Law is making you less...
First-time users, longtime strategies: Why Parkinson’s Law is making you less...First-time users, longtime strategies: Why Parkinson’s Law is making you less...
First-time users, longtime strategies: Why Parkinson’s Law is making you less...
 
Lightning Talk #11: Designer spaces by Alastair Simpson
Lightning Talk #11: Designer spaces by Alastair SimpsonLightning Talk #11: Designer spaces by Alastair Simpson
Lightning Talk #11: Designer spaces by Alastair Simpson
 
16 Reasons Why You Need to Address Payment Security
16 Reasons Why You Need to Address Payment Security16 Reasons Why You Need to Address Payment Security
16 Reasons Why You Need to Address Payment Security
 
Sketchnotes-SF Meetup :: Round 17 :: People & Faces [Wed Apr 29, 2015]
Sketchnotes-SF Meetup :: Round 17 :: People & Faces [Wed Apr 29, 2015]Sketchnotes-SF Meetup :: Round 17 :: People & Faces [Wed Apr 29, 2015]
Sketchnotes-SF Meetup :: Round 17 :: People & Faces [Wed Apr 29, 2015]
 
Ballet
BalletBallet
Ballet
 
Roadmap Lightning Updates (November 3, 2016)
Roadmap Lightning Updates (November 3, 2016)Roadmap Lightning Updates (November 3, 2016)
Roadmap Lightning Updates (November 3, 2016)
 
EURO Currency
EURO CurrencyEURO Currency
EURO Currency
 
English projects
English projectsEnglish projects
English projects
 
Plani vjetor lëndor byirenakotobelli
Plani vjetor lëndor byirenakotobelliPlani vjetor lëndor byirenakotobelli
Plani vjetor lëndor byirenakotobelli
 
Do Real Company Stuff - Mozcon 2012 Version
Do Real Company Stuff - Mozcon 2012 Version Do Real Company Stuff - Mozcon 2012 Version
Do Real Company Stuff - Mozcon 2012 Version
 
English projects from 6th class!!!
English projects from 6th class!!!English projects from 6th class!!!
English projects from 6th class!!!
 
Projekt anglisht
Projekt anglishtProjekt anglisht
Projekt anglisht
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
 
Euromarket
EuromarketEuromarket
Euromarket
 
Teatro del Renacimiento
Teatro del Renacimiento Teatro del Renacimiento
Teatro del Renacimiento
 

Similaire à The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}

SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
Itai Koren
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Erin M. Kidwell
 

Similaire à The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}} (20)

SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
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
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & Post
 
Refresh OKC
Refresh OKCRefresh OKC
Refresh OKC
 
Slow kinda sucks
Slow kinda sucksSlow kinda sucks
Slow kinda sucks
 
Death of a Themer
Death of a ThemerDeath of a Themer
Death of a Themer
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sass
 
CSS előfeldolgozók
CSS előfeldolgozókCSS előfeldolgozók
CSS előfeldolgozók
 
IV - CSS architecture
IV - CSS architectureIV - CSS architecture
IV - CSS architecture
 
CSS3
CSS3CSS3
CSS3
 
Web Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaosWeb Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaos
 
CSS Frameworks
CSS FrameworksCSS Frameworks
CSS Frameworks
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFx
 
[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
 
Hardboiled Front End Development — Found.ation
Hardboiled Front End Development — Found.ationHardboiled Front End Development — Found.ation
Hardboiled Front End Development — Found.ation
 

Dernier

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

Dernier (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
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
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
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...
 
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...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

The New UI - Staying Strong with Flexbox, SASS, and {{Mustache.js}}

  • 1. The New UI Staying Strong with Flexbox, SASS, and {{Mustache}} 1. Install Koala. http://koala-app.com/ (for Windows, Mac, Linux) Prep: 2. Get source code zip file. https://github.com/ecarlisle/TheNewUI 3. Pick any editor.
  • 2. Who’s This Guy? Name: Craft: Crew: Locale: XP: Eric Carlisle UI / UX Architect Lookingglass - http://www.lgscout.com Baltimore, MD
  • 3. Agenda ∙ General Best Practices ∙ SASS – variables, nesting, mixins, extensions ∙ CSS Flexible Box Layout & responsive design ∙ {{ mustache }} templating ∙ Q/A
  • 4. General Best Practices K I S S (Not quite what you think it means)
  • 5. General Best Practices Keep It Stunningly Simple
  • 6. General Best Practices K I S S Projects assets can be: ∙ Approachable ∙ Reusable ∙ Maintainable ∙ Self Documenting
  • 7. General Best Practices K I S S Projects assets can be: Cost Saving! (Simple doesn’t have to be boring)
  • 8. General Best Practices Ideal Project Execution
  • 9. General Best Practices Ideal Project Execution Bare Necessity Comprehensiveness
  • 10. General Best Practices Ideal Project Execution Mediocrity? Indulgence?
  • 11. General Best Practices Ideal Project Execution Hacking Architecture
  • 12. General Best Practices The right tool for the job.
  • 13.
  • 14. SASS Stands for: Syntactically Awesome Style Sheets
  • 15. SASS Stands for: Syntactically Awesome Style Sheets It is a: CSS Extension Language (a.k.a. CSS Preprocessor)
  • 16. SASS Stands for: Syntactically Awesome Style Sheets It is a: CSS Extension Language (a.k.a. CSS Preprocessor) Ultimately: Keeps CSS Maintainable
  • 17. Why do we need SASS? CSS Can Be: ∙ Repetitive ∙ Verbose ∙ Inconsistently supported ∙ A precedence nightmare ∙ Not scalable
  • 18. Why do we need SASS? SASS can make CSS: ∙ DRY (don’t repeat yourself) ∙ Modular ∙ Reusable ∙ Scalable Also see CSS frameworks like SMACSS (https://smacss.com)
  • 19. SASS or SCSS Formatting? We will be using SCSS More Info: http://thesassway.com/editorial/sass-vs-scss-which-syntax-is-better
  • 20. SASS Variables Name, value pairs. Examples: $font-stack: Lato, Helvetica, sans-serif; $blue: #369; $light-blue: lighten($blue, 40); // #b3cce6 $font-size: 10px; $big-font-size: $font-size + 8px; // 18px Fun Color Function Tool: http://sassme.arc90.com/
  • 21. SASS Nesting Source: nav { ul { list-style: none; li { display: inline-block; } } } Compiled: nav ul { list-style: none; } nav ul li { display: inline-block; } Creating a visual hierarchy
  • 22. SASS Mixins For dynamic selector attributes Source: @mixin border-radius ($radius) { - webkit-border-radius: $radius; - moz-border-radius: $radius; -ms-border-radius: $radius; border-radius: $radius; } nav { border: solid 1px black; @include border-radius(5px); } Compiled: nav { border: solid 1px black; - webkit-border-radius: 5px; - moz-border-radius: 5px; -ms-border-radius: 5px; border-radius: 5px; }
  • 23. SASS Extends Assigning inheritance (and keeping it clean) Source: .message { border: solid 1px #333; color: #FFFF; } .confirmation { @extend .message; background: #0F0; } .error { @extend .message; background: #F00; } Compiled: .message, .confirmation, .error { border: solid 1px #333; color: #FFFF; } .confirmation { background: #0F0; } .error{ background: #F00; }
  • 26. Flexbox Layout // Old version display: box; // Oldish version display: flexbox; // Today... display: flex;
  • 27. Flexbox Layout // Old version display: box; // Oldish version display: flexbox; WC3 Working Draft http://dev.w3.org/csswg/css-flexbox/ // Today... display: flex; Browser Support http://caniuse.com/#feat=flexbox
  • 28. What is Flexbox? “Aims at providing a more efficient way to lay out, align and distribute space among items in a container, even when their size is unknown and/or dynamic” http://css-tricks.com/snippets/css/a-guide-to-flexbox/
  • 29. Why Flexbox? How can our content flow? <!– Block elements flow Vertically. --> <div></div> <div></div> <div></div> <!– Inline elements flow horizontally. --> <span></span> <span></span> <span></span> <!-- Flex elements flow... Well, it depends! :-) --> <container style=“display: flex”> <item></item> <item></item> <item></item> </container> *drumroll* ? ?
  • 30. Why Flexbox? What about dimension? Space distribution? Alignment? <!– Things can get complicated pretty fast with CSS! --> <div> <div style=“float: left; margin: 10px; width: 200px”></div> <div style=“float: left: margin: 20px; padding: 10px; width: 4em”></div> <div style=“float: right; margin: 0; width: 50%></div> <div style=“clear: both”></div> </div>
  • 31. Why Flexbox? Floats? Clears? Padding? Margins? What happens when... <!– Things can get chaotic in a hurry... --> <div> <div style=“float: left; margin: 10px; width: 200px”></div> <div style=“float: ∙ left: Different margin: 20px; padding: Screens? 10px; width: 4em”></div> <div style=“float: right; margin: 0; width: 50%></div> <div style=“clear: both”></div> </div> ∙ Different (dynamic) content? ∙ Design Changes?
  • 32. Why Flexbox? Responsive Frameworks to the rescue?
  • 33. Why Flexbox? Responsive Frameworks to the rescue? BRILLIANT but… …Still pretty complicated!!!
  • 34. The Flexbox Layout Box Model Dual axis flow!
  • 35. The Flexbox Layout Box Model http://css-tricks.com/snippets/css/a-guide-to-flexbox/
  • 38. Mustache.js Logicless Templating <!-- Example --> <script> data = {“name”: “Guy Incognito”, “company”: “Horizons Unlimited Ltd.”} output = Mustache.render(“Hello {{name}} from {{Company}}!”,data); </script>
  • 39. Mustache.js Using an HTML script template <div id=“greeting”></div> <script> $template = $(“#template”).html(); data = {“name”: “Guy Incognito”, “company”: “Horizons Unlimited Ltd.”} output = Mustache.render($template ,data); </script> <script id=“template” type=“x-tmpl-mustache”> <p>Hello {{name}} from {{Company}}!</p> </script>
  • 41. Q&A eric@ericcarlisle.com http://www.twitter.com/eric_carlisle http://www.slideshare.net/ericcarlisle