SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
Simplify your CSS
with Stylus and Nib
  Christian Joudrey - @cjoudrey
The current state of CSS

#comments li {
  background-color: #FEFEFE;
}

#comments .author {
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
}
Stylus




“Expressive, robust, feature-rich CSS language
built for nodejs”
Main differences
• Get rid of syntactic sugar (brackets, semi-colons, colons)

• Enforced indentation

• Don't repeat yourself (DRY)


body
  font 12px Helvetica, Arial, sans-serif

a.button
  -webkit-border-radius 5px
  -moz-border-radius 5px
  border-radius 5px
Variables
$font-size = 14px

body
  font $font-size Helvetica, Arial, sans-serif
Mixins

body
  font 12px Helvetica, Arial, sans-serif

border-radius()
  -webkit-border-radius arguments
  -moz-border-radius arguments
  border-radius arguments

a.button
  border-radius 5px
Nested selectors

#comments                   #comments h1 {
  h1                          font-size: 14px;
     font-size 14px         }
  a
     color black            #comments a {
                              color: black;
    &:hover                 }
      color blue
                            #comments a:hover {
                              color: blue;
                            }
Nib




“Stylus mixins, utilities, components, and
gradient image generation. CSS is your bitch!”
Vendor prefixes
@import 'nib'                #comments {
                               -webkit-border-radius: 4px;
                               -moz-border-radius: 4px;
#comments                      border-radius: 4px;
  border-radius 4px            -webkit-box-shadow: 0 0 1px #000;
                               -moz-box-shadow: 0 0 1px #000;
  box-shadow 0 0 1px black     box-shadow: 0 0 1px #000;
  p                          }
    opacity 0.75
                             #comments p {
                               opacity: 0.75;
                               filter: progid:DXIm[...]pha(Opacity=75);
                             }
Clearfix
@import 'nib'         .cf {
                        zoom: 1;
.cf                   }
  clearfix()          .cf:before,
                      .cf:after {
                        content: "";
                        display: table;
                      }
                      .cf:after {
                        clear: both;
                      }
Hide-text
@import 'nib'          #slogan {
                          text-indent: -99999em;
#slogan                   overflow: hidden;
  hide-text()             text-align: left;
                       }
and a lot more...
The best part is...
• It's all optional, you can mix and match Stylus and CSS

• Slowly integrate it in your existing CSS


                @import 'nib'

                #comments {
                  border-radius: 4px;
                  border: 1px solid black;
                }
Express Middleware
var express = require('express'),
    stylus = require('stylus'),
    nib = require('nib'),
    app = express.createServer();

// ...

app.use(stylus.middleware({
  src: __dirname + '/public',
  compile: function (str, path){
     return stylus(str)
       .set('filename', path)
       .set('compress', true)
       .use(nib());
  }
}));
Command-line Tool

$ npm install -g stylus


$ stylus main.styl
   compiled main.css


$ stylus -u nib main.styl
   compiled main.css
Interesting Links

• Stylus: http://learnboost.github.com/stylus

• Nib: https://github.com/visionmedia/nib

Más contenido relacionado

Destacado

Report on launching of new product
Report on launching of new productReport on launching of new product
Report on launching of new product
Faiza Javaid
 
My Communication Lab
My Communication LabMy Communication Lab
My Communication Lab
Corey Durward
 
Operational Transformation in Banking Operations
Operational Transformation in Banking OperationsOperational Transformation in Banking Operations
Operational Transformation in Banking Operations
Rajeev De Roy
 

Destacado (20)

New Product Development Report
New Product Development ReportNew Product Development Report
New Product Development Report
 
NETCONF YANG tutorial
NETCONF YANG tutorialNETCONF YANG tutorial
NETCONF YANG tutorial
 
37 Ways for New Product Ideas
37 Ways for New Product Ideas37 Ways for New Product Ideas
37 Ways for New Product Ideas
 
Report on launching of new product
Report on launching of new productReport on launching of new product
Report on launching of new product
 
A 30-minute Introduction to NETCONF and YANG
A 30-minute Introduction to NETCONF and YANGA 30-minute Introduction to NETCONF and YANG
A 30-minute Introduction to NETCONF and YANG
 
Ballast Water Treatment with VOS™ | N.E.I. Treatment Systems
Ballast Water Treatment with VOS™  | N.E.I. Treatment SystemsBallast Water Treatment with VOS™  | N.E.I. Treatment Systems
Ballast Water Treatment with VOS™ | N.E.I. Treatment Systems
 
My Communication Lab
My Communication LabMy Communication Lab
My Communication Lab
 
KABLOSUZ PROB YARDIMIYLA GEOPHONE SİSTEMİ TASARIMI
KABLOSUZ PROB YARDIMIYLA GEOPHONE SİSTEMİ TASARIMIKABLOSUZ PROB YARDIMIYLA GEOPHONE SİSTEMİ TASARIMI
KABLOSUZ PROB YARDIMIYLA GEOPHONE SİSTEMİ TASARIMI
 
Qu’est-ce que la carte MasterCard prépayée paysafecard?
Qu’est-ce que la carte MasterCard prépayée paysafecard?Qu’est-ce que la carte MasterCard prépayée paysafecard?
Qu’est-ce que la carte MasterCard prépayée paysafecard?
 
Lotus Notes Migration
Lotus Notes MigrationLotus Notes Migration
Lotus Notes Migration
 
Tc basics
Tc basicsTc basics
Tc basics
 
Netezza vs teradata
Netezza vs teradataNetezza vs teradata
Netezza vs teradata
 
Immunohistochemistry (IHC)Staining Steps
Immunohistochemistry (IHC)Staining StepsImmunohistochemistry (IHC)Staining Steps
Immunohistochemistry (IHC)Staining Steps
 
MicroStrategy Design Challenges - Tips and Best Practices
MicroStrategy Design Challenges - Tips and Best PracticesMicroStrategy Design Challenges - Tips and Best Practices
MicroStrategy Design Challenges - Tips and Best Practices
 
OOW15 - Testing Oracle E-Business Suite Best Practices
OOW15 - Testing Oracle E-Business Suite Best PracticesOOW15 - Testing Oracle E-Business Suite Best Practices
OOW15 - Testing Oracle E-Business Suite Best Practices
 
Speech Lessons 1-7
Speech Lessons 1-7Speech Lessons 1-7
Speech Lessons 1-7
 
Processed Meat Packaging - Anas Shaikh - 13FET1006
Processed Meat Packaging - Anas Shaikh - 13FET1006Processed Meat Packaging - Anas Shaikh - 13FET1006
Processed Meat Packaging - Anas Shaikh - 13FET1006
 
key word indexing and their types with example
key word indexing and their types with example key word indexing and their types with example
key word indexing and their types with example
 
31-P NMR SPECTROSCOPY
31-P NMR SPECTROSCOPY31-P NMR SPECTROSCOPY
31-P NMR SPECTROSCOPY
 
Operational Transformation in Banking Operations
Operational Transformation in Banking OperationsOperational Transformation in Banking Operations
Operational Transformation in Banking Operations
 

Similar a Simplify your CSS with Stylus and Nib

Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Kaelig Deloumeau-Prigent
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
Wynn Netherland
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
Even Wu
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
edgincvg
 
Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)
elliando dias
 

Similar a Simplify your CSS with Stylus and Nib (20)

Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Sass compass
Sass compassSass compass
Sass compass
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Less & Sass
Less & SassLess & Sass
Less & Sass
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With Sass
 
Messy css
Messy cssMessy css
Messy css
 
Learn to love CSS3 | Joomla! Day Deutschland
Learn to love CSS3 | Joomla! Day DeutschlandLearn to love CSS3 | Joomla! Day Deutschland
Learn to love CSS3 | Joomla! Day Deutschland
 
Learn to Love CSS3 [English]
Learn to Love CSS3 [English]Learn to Love CSS3 [English]
Learn to Love CSS3 [English]
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie Dust
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)
 
Oocss & progressive css3 selectors
Oocss & progressive css3 selectorsOocss & progressive css3 selectors
Oocss & progressive css3 selectors
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 

Último

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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...
 
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...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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...
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
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
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Simplify your CSS with Stylus and Nib

  • 1. Simplify your CSS with Stylus and Nib Christian Joudrey - @cjoudrey
  • 2. The current state of CSS #comments li { background-color: #FEFEFE; } #comments .author { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; }
  • 3. Stylus “Expressive, robust, feature-rich CSS language built for nodejs”
  • 4. Main differences • Get rid of syntactic sugar (brackets, semi-colons, colons) • Enforced indentation • Don't repeat yourself (DRY) body font 12px Helvetica, Arial, sans-serif a.button -webkit-border-radius 5px -moz-border-radius 5px border-radius 5px
  • 5. Variables $font-size = 14px body font $font-size Helvetica, Arial, sans-serif
  • 6. Mixins body font 12px Helvetica, Arial, sans-serif border-radius() -webkit-border-radius arguments -moz-border-radius arguments border-radius arguments a.button border-radius 5px
  • 7. Nested selectors #comments #comments h1 { h1 font-size: 14px; font-size 14px } a color black #comments a { color: black; &:hover } color blue #comments a:hover { color: blue; }
  • 8. Nib “Stylus mixins, utilities, components, and gradient image generation. CSS is your bitch!”
  • 9. Vendor prefixes @import 'nib' #comments { -webkit-border-radius: 4px; -moz-border-radius: 4px; #comments border-radius: 4px; border-radius 4px -webkit-box-shadow: 0 0 1px #000; -moz-box-shadow: 0 0 1px #000; box-shadow 0 0 1px black box-shadow: 0 0 1px #000; p } opacity 0.75 #comments p { opacity: 0.75; filter: progid:DXIm[...]pha(Opacity=75); }
  • 10. Clearfix @import 'nib' .cf { zoom: 1; .cf } clearfix() .cf:before, .cf:after { content: ""; display: table; } .cf:after { clear: both; }
  • 11. Hide-text @import 'nib' #slogan { text-indent: -99999em; #slogan overflow: hidden; hide-text() text-align: left; }
  • 12. and a lot more...
  • 13. The best part is... • It's all optional, you can mix and match Stylus and CSS • Slowly integrate it in your existing CSS @import 'nib' #comments { border-radius: 4px; border: 1px solid black; }
  • 14. Express Middleware var express = require('express'), stylus = require('stylus'), nib = require('nib'), app = express.createServer(); // ... app.use(stylus.middleware({ src: __dirname + '/public', compile: function (str, path){ return stylus(str) .set('filename', path) .set('compress', true) .use(nib()); } }));
  • 15. Command-line Tool $ npm install -g stylus $ stylus main.styl compiled main.css $ stylus -u nib main.styl compiled main.css
  • 16. Interesting Links • Stylus: http://learnboost.github.com/stylus • Nib: https://github.com/visionmedia/nib