SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
Compass

                                                                       Tim Riley
                                                                    openmonkey.com




My perspective: non-designer wanting a predictable world and to be able to knock together some decent looking things.
#main {
                                        width: 90%;
   #main                              }
     :width 90%                       #main p {
     p                                  border-style: solid;
       :border-style solid              border-width: 1px;
       :border-width 1px                border-color: #00f;
       :border-color #00f             }
       a                              #main p a {
         :text-decoration none          text-decoration: none;
         :font-weight bold              font-weight: bold;
       a:hover                        }
         :text-decoration underline   #main p a:hover {
                                        text-decoration: underline;
                                      }




Intro to Sass

Cleaner Syntax
Whitespace aware
Nested selectors
!main_bg= #46ar12
            !main_width= 40em

            #main
              :background-color= !main_bg
              :width= !main_width
              .sidebar
                :background-color= !main_bg + #333333
                :width= !main_width - 25em




Variables
Sass Mixins
                                                      =blue-border
                                                        :border
                                                          :color blue
                                                          :width 2px
                                                          :style dotted

                                                      .comment
                                                        +blue-border
                                                        :padding 2px
                                                        :margin 10px 0

                                                      .reply
                                                        +blue-border




Define groups of CSS attributes and include them inline in any selectors throughout your stylesheet.

Mixins are like CSS macros, or ruby modules or abstract classes.
=outer-table-borders(!width = 2px, !color = black)
                     :border= !width "solid" !color
                     thead
                        th
                           :border-bottom= !width "solid" !color
                     tfoot
                        th, td
                           :border-top= !width "solid" !color
                     th
                       &:first-child
                           :border-right= !width "solid" !color




In the 2.1 (development) version of Sass, mixins can take arguments, which makes them much more flexible.
CSS Frameworks



To reiterate from before: Iʼm a non-designer looking to extend my predictable world of backend code to the frontend.
I want to avoid the browser compatibility nightmares.

The frameworks come from the people who know better than me.
So for me, CSS frameworks are a godsend. At the foundation, they are collections of CSS utility classes for you to include in your makrup. They can
help you avert the unpleasant surprises of browser compatibility. Found some traction especially for creating grid-based layouts.
.container.showgrid
                           %h2 Tests for common HTML elements
                           %hr

                             .span-8
                               %p Lorem ipsum dolor sit
                               %p Lorem ipsum dolor sit

                             .span-8
                               %p.small Lorem ipsum dolor sit
                               %p Lorem ipsum dolor sit
                               %p.large Lorem ipsum dolor sit

                             .span-8.last
                               .box
                                 %p.last Aliquip ex ea commodo consequat
                               %blockquote
                                 %p Lorem ipsum dolor sit




But! They pollute your markup with “display classes” - non-semantic class names.

Also, they are little more than just a collection of CSS classes, not a true framework (EXPLAIN)
Compass is a framework that combines Sass with these CSS frameworks - and much more - to make it easier to develop stylesheets for semantic
markup.
Framework Ports
                                                            Blueprint
                                                             960.gs
                                                               YUI



Compass includes ports of several frameworks to Sass: Blueprint, 960.gs & YUI.
+container                                              !blueprint_grid_columns
             +column(n, last)                                        !blueprint_grid_width
             +last                                                   !blueprint_grid_margin
             +append(n)
             +prepend(n)
             +push(n)                                                +blueprint-typography
             +pull(n)                                                +blueprint-form




These are not just Sass conversions - the frameworks enhanced these using mixins to provide a DSL that allows you to hook into the frameworks
and provide smenatic markup
.container.showgrid
  %h2 Tests for common HTML elements
  %hr

  .span-8
    %p Lorem ipsum dolor sit
    %p Lorem ipsum dolor sit

  .span-8
    %p.small Lorem ipsum dolor sit
    %p Lorem ipsum dolor sit
    %p.large Lorem ipsum dolor sit

  .span-8.last
    .box
      %p.last Aliquip ex ea commodo consequat
    %blockquote
      %p Lorem ipsum dolor sit
#page                                                       #page
  %h2 Tests for common HTML elements                          +container
  %hr                                                         +showgrid

    #sales
      %p Lorem ipsum dolor sit                              #sales
      %p Lorem ipsum dolor sit                                +column(8)

    #engineering
      %p.small Lorem ipsum dolor sit                        #engineering
      %p Lorem ipsum dolor sit                                +column(8)
      %p.large Lorem ipsum dolor sit

    #support                                                #support
      .testimonial                                            +column(8, true)
        %p Aliquip ex ea commodo consequat                    .testimonial
      %blockquote                                               +box
        %p Lorem ipsum dolor sit                                %p
                                                                  +last


With Compass it is easy to write unobtrusive stylesheets.
Compass Core Lib
                  •      CSS Reset                                              •      Text replacement

                  •      Sticky Footer                                          •      Link styling

                  •      Clearfix                                                •      List styling (bullets,
                                                                                       orientation)
                  •      Tag Cloud
                                                                                •      Table styling
                  •      Cross-browser inline-                                         (background colours,
                                                                                       borders)
                         block




Besides the big frameworks, Compass provides its own useful core library, which includes support for:

CSS Resets, Sticky Footers, Clear Fixes, Tag Clouds, Text Replacement, Link Styling, Table Styling
#app-suite-links
  :float left
  +horizontal-list



.tickets
  +alternating-rows-and-columns(#ddffc8,#bbff91,#000)
Mix & Match

                                    @import         compass/reset.sass
                                    @import         compass/utilities.sass
                                    @import         blueprint/modules/colors.sass
                                    @import         blueprint/modules/grid.sass




Compass allows you to build your stylesheets efficiently insofar as you are never required to pull in all the libs or frameworks wholesale. You can
just pull in the parts that you want. Youʼre not confined to working with just one framework. It is easy to mix and match elements from each of these
framework ports and the core lib.
Installation

$ git clone git://github.com/nex3/haml.git

$ cd haml && sudo rake install

$ sudo gem install chriseppstein-compass 
  --source=http://gems.github.com/
Standalone Usage
$ compass -f blueprint project_dir

$ cd project_dir

$ compass -u # update the current project

$ compass -w # watch
Rails Integration
 $ rails project_dir

 $ cd project_dir

 $ haml --rails .

 $ compass --rails -f blueprint .
Sinatra Integration
gem 'haml', '~> 2.1'
require 'haml'

gem 'chriseppstein-compass'
require 'compass'

configure do
  Compass.configuration do |config|
    config.project_path = File.dirname(__FILE__)
    config.sass_dir     = File.join('views', 'stylesheets')
  end
end

get "/stylesheets/screen.css" do
  content_type 'text/css'
  sass :"stylesheets/screen", :sass => Compass.sass_engine_options
end
http://github.com/chriseppstein/compass/

http://github.com/timriley/unfuddle-helpdesk

Más contenido relacionado

Destacado

Infrastructure In The Cloud Era
Infrastructure In The Cloud EraInfrastructure In The Cloud Era
Infrastructure In The Cloud Era
elliando dias
 
12 L A E L A S T I C I D A D P R E C I O D E L A O F E R T A
12  L A  E L A S T I C I D A D   P R E C I O  D E  L A  O F E R T A12  L A  E L A S T I C I D A D   P R E C I O  D E  L A  O F E R T A
12 L A E L A S T I C I D A D P R E C I O D E L A O F E R T A
CARLOS MASSUH
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
elliando dias
 
How to go from Double Stuffed to International Fame
How to go from Double Stuffed to International FameHow to go from Double Stuffed to International Fame
How to go from Double Stuffed to International Fame
Adam Evers
 
How to ChoosHow to Choose A Web Application Framework
How to ChoosHow to Choose A Web Application FrameworkHow to ChoosHow to Choose A Web Application Framework
How to ChoosHow to Choose A Web Application Framework
elliando dias
 

Destacado (10)

Infrastructure In The Cloud Era
Infrastructure In The Cloud EraInfrastructure In The Cloud Era
Infrastructure In The Cloud Era
 
getting agile Final
getting agile Finalgetting agile Final
getting agile Final
 
Speak asia
Speak asiaSpeak asia
Speak asia
 
12 L A E L A S T I C I D A D P R E C I O D E L A O F E R T A
12  L A  E L A S T I C I D A D   P R E C I O  D E  L A  O F E R T A12  L A  E L A S T I C I D A D   P R E C I O  D E  L A  O F E R T A
12 L A E L A S T I C I D A D P R E C I O D E L A O F E R T A
 
WordPress SEO on Drugs!
WordPress SEO on Drugs!WordPress SEO on Drugs!
WordPress SEO on Drugs!
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
 
4 gwes2012
4 gwes20124 gwes2012
4 gwes2012
 
How to go from Double Stuffed to International Fame
How to go from Double Stuffed to International FameHow to go from Double Stuffed to International Fame
How to go from Double Stuffed to International Fame
 
How to ChoosHow to Choose A Web Application Framework
How to ChoosHow to Choose A Web Application FrameworkHow to ChoosHow to Choose A Web Application Framework
How to ChoosHow to Choose A Web Application Framework
 
Restructuring Technical Debt - A Software and System Quality Approach
Restructuring Technical Debt - A Software and System Quality ApproachRestructuring Technical Debt - A Software and System Quality Approach
Restructuring Technical Debt - A Software and System Quality Approach
 

Similar a Compass And Sass(Tim Riley)

Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
Even Wu
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
Wynn Netherland
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
Bryce Kerley
 

Similar a Compass And Sass(Tim Riley) (20)

Sass compass
Sass compassSass compass
Sass compass
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
 
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
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Haml and Sass Introduction
Haml and Sass IntroductionHaml and Sass Introduction
Haml and Sass Introduction
 
Palestra pré processadores CSS
Palestra pré processadores CSSPalestra pré processadores CSS
Palestra pré processadores CSS
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
 
Sass Essentials
Sass EssentialsSass Essentials
Sass Essentials
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 
Cheat sheet blueprint
Cheat sheet blueprintCheat sheet blueprint
Cheat sheet blueprint
 
Blueprint V0.8by Gjms
Blueprint V0.8by GjmsBlueprint V0.8by Gjms
Blueprint V0.8by Gjms
 
Bridging the gap between designers and developers at theguardian.com
Bridging the gap between designers and developers at theguardian.comBridging the gap between designers and developers at theguardian.com
Bridging the gap between designers and developers at theguardian.com
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 

Más de elliando dias

Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
elliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
elliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
elliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
elliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
elliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
elliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 

Más de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Último

Último (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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?
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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...
 
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
 
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...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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...
 
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)
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Compass And Sass(Tim Riley)

  • 1. Compass Tim Riley openmonkey.com My perspective: non-designer wanting a predictable world and to be able to knock together some decent looking things.
  • 2. #main { width: 90%; #main } :width 90% #main p { p border-style: solid; :border-style solid border-width: 1px; :border-width 1px border-color: #00f; :border-color #00f } a #main p a { :text-decoration none text-decoration: none; :font-weight bold font-weight: bold; a:hover } :text-decoration underline #main p a:hover { text-decoration: underline; } Intro to Sass Cleaner Syntax Whitespace aware Nested selectors
  • 3. !main_bg= #46ar12 !main_width= 40em #main :background-color= !main_bg :width= !main_width .sidebar :background-color= !main_bg + #333333 :width= !main_width - 25em Variables
  • 4. Sass Mixins =blue-border :border :color blue :width 2px :style dotted .comment +blue-border :padding 2px :margin 10px 0 .reply +blue-border Define groups of CSS attributes and include them inline in any selectors throughout your stylesheet. Mixins are like CSS macros, or ruby modules or abstract classes.
  • 5. =outer-table-borders(!width = 2px, !color = black) :border= !width "solid" !color thead th :border-bottom= !width "solid" !color tfoot th, td :border-top= !width "solid" !color th &:first-child :border-right= !width "solid" !color In the 2.1 (development) version of Sass, mixins can take arguments, which makes them much more flexible.
  • 6. CSS Frameworks To reiterate from before: Iʼm a non-designer looking to extend my predictable world of backend code to the frontend.
  • 7. I want to avoid the browser compatibility nightmares. The frameworks come from the people who know better than me.
  • 8. So for me, CSS frameworks are a godsend. At the foundation, they are collections of CSS utility classes for you to include in your makrup. They can help you avert the unpleasant surprises of browser compatibility. Found some traction especially for creating grid-based layouts.
  • 9. .container.showgrid %h2 Tests for common HTML elements %hr .span-8 %p Lorem ipsum dolor sit %p Lorem ipsum dolor sit .span-8 %p.small Lorem ipsum dolor sit %p Lorem ipsum dolor sit %p.large Lorem ipsum dolor sit .span-8.last .box %p.last Aliquip ex ea commodo consequat %blockquote %p Lorem ipsum dolor sit But! They pollute your markup with “display classes” - non-semantic class names. Also, they are little more than just a collection of CSS classes, not a true framework (EXPLAIN)
  • 10. Compass is a framework that combines Sass with these CSS frameworks - and much more - to make it easier to develop stylesheets for semantic markup.
  • 11. Framework Ports Blueprint 960.gs YUI Compass includes ports of several frameworks to Sass: Blueprint, 960.gs & YUI.
  • 12. +container !blueprint_grid_columns +column(n, last) !blueprint_grid_width +last !blueprint_grid_margin +append(n) +prepend(n) +push(n) +blueprint-typography +pull(n) +blueprint-form These are not just Sass conversions - the frameworks enhanced these using mixins to provide a DSL that allows you to hook into the frameworks and provide smenatic markup
  • 13. .container.showgrid %h2 Tests for common HTML elements %hr .span-8 %p Lorem ipsum dolor sit %p Lorem ipsum dolor sit .span-8 %p.small Lorem ipsum dolor sit %p Lorem ipsum dolor sit %p.large Lorem ipsum dolor sit .span-8.last .box %p.last Aliquip ex ea commodo consequat %blockquote %p Lorem ipsum dolor sit
  • 14. #page #page %h2 Tests for common HTML elements +container %hr +showgrid #sales %p Lorem ipsum dolor sit #sales %p Lorem ipsum dolor sit +column(8) #engineering %p.small Lorem ipsum dolor sit #engineering %p Lorem ipsum dolor sit +column(8) %p.large Lorem ipsum dolor sit #support #support .testimonial +column(8, true) %p Aliquip ex ea commodo consequat .testimonial %blockquote +box %p Lorem ipsum dolor sit %p +last With Compass it is easy to write unobtrusive stylesheets.
  • 15. Compass Core Lib • CSS Reset • Text replacement • Sticky Footer • Link styling • Clearfix • List styling (bullets, orientation) • Tag Cloud • Table styling • Cross-browser inline- (background colours, borders) block Besides the big frameworks, Compass provides its own useful core library, which includes support for: CSS Resets, Sticky Footers, Clear Fixes, Tag Clouds, Text Replacement, Link Styling, Table Styling
  • 16. #app-suite-links :float left +horizontal-list .tickets +alternating-rows-and-columns(#ddffc8,#bbff91,#000)
  • 17. Mix & Match @import compass/reset.sass @import compass/utilities.sass @import blueprint/modules/colors.sass @import blueprint/modules/grid.sass Compass allows you to build your stylesheets efficiently insofar as you are never required to pull in all the libs or frameworks wholesale. You can just pull in the parts that you want. Youʼre not confined to working with just one framework. It is easy to mix and match elements from each of these framework ports and the core lib.
  • 18. Installation $ git clone git://github.com/nex3/haml.git $ cd haml && sudo rake install $ sudo gem install chriseppstein-compass --source=http://gems.github.com/
  • 19. Standalone Usage $ compass -f blueprint project_dir $ cd project_dir $ compass -u # update the current project $ compass -w # watch
  • 20. Rails Integration $ rails project_dir $ cd project_dir $ haml --rails . $ compass --rails -f blueprint .
  • 21. Sinatra Integration gem 'haml', '~> 2.1' require 'haml' gem 'chriseppstein-compass' require 'compass' configure do Compass.configuration do |config| config.project_path = File.dirname(__FILE__) config.sass_dir = File.join('views', 'stylesheets') end end get "/stylesheets/screen.css" do content_type 'text/css' sass :"stylesheets/screen", :sass => Compass.sass_engine_options end