24

Pacific Northwest Drupal Summit: Basic & SASS

Embed Size (px)

DESCRIPTION

What is Basic? Basic was originally developed for client projects. Originally a stripped down version of the ZEN theme, basic has now become its own concept of a theme starter. Basic boasts a clean HTML structure with extensible CSS classes and ID's for unlimited theming possibilities as well as a top-down load order for improved SEO. Basic's goal is to provide themers the building blocks needed to get their designs up and running quickly and simply. What is SASS? Sass is a meta-language on top of CSS that’s used to describe the style of a document cleanly and structurally, with more power than flat CSS allows. Sass both provides a simpler, more elegant syntax for CSS and implements various features that are useful for creating manageable stylesheets. What will I Learn? We will guide you through using Basic with SASS and Compass to kick-start your next Drupal theming project and show you how easy it is to get started. We will also cover the syntax and file structure of using SASS and how to get your development environment up

Citation preview

Page 1: Pacific Northwest Drupal Summit: Basic & SASS
Page 2: Pacific Northwest Drupal Summit: Basic & SASS

What we'll Learn

Learn the SASS SyntaxUtilize Compass for compilingTake a look at Basic and learn how to put our knowledge to practice

Page 3: Pacific Northwest Drupal Summit: Basic & SASS

What is SASS?

Syntactically Awesome Stylesheets.

Page 4: Pacific Northwest Drupal Summit: Basic & SASS

What is SASS?

Sass makes CSS fun again.

Page 5: Pacific Northwest Drupal Summit: Basic & SASS

What is SASS?SCSS (Sassy CSS. Newer syntax)a superset of CSS3’s syntaxSASS (Older syntax)uses indentation instead of brackets and semi-colons

Page 6: Pacific Northwest Drupal Summit: Basic & SASS

What is SASS?

nested rulesvariablesmixinsselector inheritance

Page 7: Pacific Northwest Drupal Summit: Basic & SASS

Installing SASS

need Ruby, Gem, and HAMLOSX: http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopardLinux: you probably can figure this out....Windows: good luck...

Page 8: Pacific Northwest Drupal Summit: Basic & SASS

What is Compass?

Compass is a stylesheet authoring tool that uses the Sass stylesheet language to make your stylesheets

smaller and your web site easier to maintain.

Page 9: Pacific Northwest Drupal Summit: Basic & SASS

Installing Compass

gem install compass

Page 10: Pacific Northwest Drupal Summit: Basic & SASS

What we'll use Compass for...automajically compile our SASS files

# Require any additional compass plugins here.project_type = :stand_alone# Set this to the root of your project when deployed:http_path = "/"css_dir = "css"sass_dir = "sass"images_dir = "images"javascripts_dir = "js"output_style = :compact# To enable relative paths to assets via compass helper functions. # Uncomment:# relative_assets = true

Page 11: Pacific Northwest Drupal Summit: Basic & SASS

But...as of SASS 3...

files prefixed with underscore are ignored.

sass --watch sass:css (sassdir:outputdir)

Page 12: Pacific Northwest Drupal Summit: Basic & SASS

Examples: Nested RulesSASSSCSS

table.hl { margin: 2em 0; td.ln { text-align: right; }}

li { font: { family: serif; weight: bold; size: 1.2em; }}

table.hl margin: 2em 0 td.ln text-align: right

li font: family: serif weight: bold size: 1.2em

Page 13: Pacific Northwest Drupal Summit: Basic & SASS

Examples: Nested Rules

table.hl { margin: 2em 0;}table.hl td.ln { text-align: right;}

li { font-family: serif; font-weight: bold; font-size: 1.2em;}

CSS

Page 14: Pacific Northwest Drupal Summit: Basic & SASS

Examples: VariablesSASSSCSS

$blue: #3bbfce;$margin: 16px;

.content-navigation { border-color: $blue; color: darken($blue, 9%);}

.border { padding: $margin / 2; margin: $margin / 2; border-color: $blue;}

$blue: #3bbfce$margin: 16px

.content-navigation border-color: $blue color: darken($blue, 9%)

.border padding: $margin / 2 margin: $margin / 2 border-color: $blue

Page 15: Pacific Northwest Drupal Summit: Basic & SASS

Examples: Variables

.content-navigation { border-color: #3bbfce; color: #2b9eab;}

.border { padding: 8px; margin: 8px; border-color: #3bbfce;}

CSS

Page 16: Pacific Northwest Drupal Summit: Basic & SASS

Examples: MixinsSASSSCSS

@mixin table-base { th { text-align: center; font-weight: bold; } td, th {padding: 2px}}

@mixin left($dist) { float: left; margin-left: $dist;}

#data { @include left(10px); @include table-base;}

@mixin table-base th text-align: center font-weight: bold td, th padding: 2px

@mixin left($dist) float: left margin-left: $dist

#data @include left(10px) @include table-base

Page 17: Pacific Northwest Drupal Summit: Basic & SASS

Examples: Mixins

#data { float: left; margin-left: 10px;}#data th { text-align: center; font-weight: bold;}#data td, #data th { padding: 2px;}

CSS

Page 18: Pacific Northwest Drupal Summit: Basic & SASS

Examples: Selector InheritanceSASSSCSS

.error { border: 1px #f00; background: #fdd;}.error.intrusion { font-size: 1.3em; font-weight: bold;}

.badError { @extend .error; border-width: 3px;}

.error border: 1px #f00 background: #fdd

.error.intrusion font-size: 1.3em font-weight: bold

.badError @extend .error border-width: 3px

Page 19: Pacific Northwest Drupal Summit: Basic & SASS

Examples: Selector Inheritance

.error, .badError { border: 1px #f00; background: #fdd;}

.error.intrusion,

.badError.intrusion { font-size: 1.3em; font-weight: bold;}

.badError { border-width: 3px;}

CSS

Page 20: Pacific Northwest Drupal Summit: Basic & SASS

Examples: Conditional StatementsSASS=views-row($margin: $baseline, $divide: false, $border_color: #CCC) +pie-clearfix @if $divide border-bottom: 1px solid $border_color margin-bottom: $margin * 0.5 @else margin-bottom: $margin * 0.5 p &:last-of-type margin-bottom: 0

#main-content .item +views-row($baseline, true, $brand_blue)

Page 21: Pacific Northwest Drupal Summit: Basic & SASS

Other LanguagesSASS, Less, Turbine, Switch CSS, CSS Cacheer, CSSPP, ... and more.

http://bit.ly/CSSPreprocessors

Page 22: Pacific Northwest Drupal Summit: Basic & SASS

Convert!$ css2sass input output (older syntax)$ sassconvert [options] input output (newer syntax)$ sass-convert --from less --to scss --recursive .

Page 23: Pacific Northwest Drupal Summit: Basic & SASS

Convert!Textmate Bundlehttp://github.com/seaofclouds/sass-textmate-bundleFoldable Blocks in Texmatehttp://nimbupani.com/foldable-css-blocks-in-sass-with-textmate.html

Page 24: Pacific Northwest Drupal Summit: Basic & SASS

Drupal ResourcesCompass: http://drupal.org/project/compassBasic: http://drupal.org/project/basicLess: http://drupal.org/project/less