SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
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

Contenu connexe

En vedette

New Product Development Report
New Product Development ReportNew Product Development Report
New Product Development ReportGlen Chan
 
37 Ways for New Product Ideas
37 Ways for New Product Ideas37 Ways for New Product Ideas
37 Ways for New Product IdeasMarc Heleven
 
Report on launching of new product
Report on launching of new productReport on launching of new product
Report on launching of new productFaiza Javaid
 
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 YANGTail-f Systems
 
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 SystemsNEI Marine
 
My Communication Lab
My Communication LabMy Communication Lab
My Communication LabCorey Durward
 
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İ TASARIMIMutugu Gultepe
 
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?paysafecard6curtis57
 
Lotus Notes Migration
Lotus Notes MigrationLotus Notes Migration
Lotus Notes MigrationRam Prabhalla
 
Netezza vs teradata
Netezza vs teradataNetezza vs teradata
Netezza vs teradataAsis Mohanty
 
Immunohistochemistry (IHC)Staining Steps
Immunohistochemistry (IHC)Staining StepsImmunohistochemistry (IHC)Staining Steps
Immunohistochemistry (IHC)Staining StepsLawrence Richards
 
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 PracticesBiBoard.Org
 
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 Practicesvasuballa
 
Speech Lessons 1-7
Speech Lessons 1-7Speech Lessons 1-7
Speech Lessons 1-7Monica P
 
Processed Meat Packaging - Anas Shaikh - 13FET1006
Processed Meat Packaging - Anas Shaikh - 13FET1006Processed Meat Packaging - Anas Shaikh - 13FET1006
Processed Meat Packaging - Anas Shaikh - 13FET1006Anas Ejaz Yasmeen Shaikh
 
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 Sourav Sarkar
 
Operational Transformation in Banking Operations
Operational Transformation in Banking OperationsOperational Transformation in Banking Operations
Operational Transformation in Banking OperationsRajeev De Roy
 

En vedette (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
 

Similaire à 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 NewsKaelig Deloumeau-Prigent
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.Eugene Nor
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentationMario Noble
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3 Wynn Netherland
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid PrototypingEven Wu
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Startededgincvg
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compassdrywallbmb
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With SassThomas Reynolds
 
Messy css
Messy cssMessy css
Messy cssxavijam
 
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 DeutschlandThemePartner
 
Learn to Love CSS3 [English]
Learn to Love CSS3 [English]Learn to Love CSS3 [English]
Learn to Love CSS3 [English]ThemePartner
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustKyle Adams
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
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 DeveloperWynn Netherland
 
Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)elliando dias
 
Oocss & progressive css3 selectors
Oocss & progressive css3 selectorsOocss & progressive css3 selectors
Oocss & progressive css3 selectorsdaniel_sternlicht
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)emrox
 

Similaire à 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)
 

Dernier

[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Dernier (20)

[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

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