Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Making your Front-End Workflow AWESOME

Kitt Hodsden
February 14, 2014

Making your Front-End Workflow AWESOME

Using Sass + Grunt and other front end tools for Drupal Front-End workflow automation.

Kitt Hodsden

February 14, 2014
Tweet

More Decks by Kitt Hodsden

Other Decks in Technology

Transcript

  1. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Embrace the DRY principle 2. Make changes easy 3. Make finding mistakes easy 8 Guiding principles of making our workflows AWESOME
  2. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Implement

    a design or prototype Update the designs 11 What magic do we do?
  3. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Implement

    a design or prototype Update the designs Make sure it works in all browsers 12 What magic do we do?
  4. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Implement

    a design or prototype Update the designs Make sure it works in all browsers Make it faster 13 What magic do we do?
  5. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 15

    How often do we have a blank slate, really?
  6. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Implement

    a design or prototype Update the designs Make sure it works in all browsers Make it faster 16 We’re going to start talking about the middle of our projects...
  7. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Embrace the DRY principle 2. Make changes easy 3. Make finding mistakes easy 24 Guiding principles!
  8. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Embrace the DRY principle 2. Make changes easy 3. Make finding mistakes easy 25 Guiding principles!
  9. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Use

    a CSS preprocessor. 26 Saw that coming, didn’t you?
  10. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Sass

    / LESS / Stylus 27 Saw that coming, didn’t you?
  11. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 32

    HOMEBREW http://mxcl.github.com/homebrew/ Installation information - ruby on OSX
  12. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz RVM

    RUBY VERSION MANAGER 34 Installation information for ruby https://rvm.io/rvm/install
  13. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Installation

    information - ruby on linux # apt-get install ruby1.9.1 $ sudo apt-get install ruby1.9.1 36
  14. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Installation

    information - ruby on linux # yum install ruby1.9.1 $ sudo yum install ruby1.9.1 37
  15. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz RVM

    RUBY VERSION MANAGER 38 Installation information for ruby https://rvm.io/rvm/install
  16. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz RUBYINSTALLER

    = FRIEND 40 Installation information - ruby on windows http://rubyinstaller.org/downloads/
  17. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz While

    you’re at it... 41 If you’re installing software...
  18. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 45

    $ gem update --system $ gem install sass $ sudo gem update --system $ sudo gem install sass Yay! Sass installed!
  19. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz COMPASS

    46 Install Compass, too http://compass-style.org/install/
  20. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 47

    $ gem update --system $ gem install compass $ sudo gem update --system $ sudo gem install compass Setting up tools. In this case, Compass.
  21. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Let

    us count the (3) ways. 49 How we get started with Sass in an existing project.
  22. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Move

    and rename files. 50 How we get started with Sass in an existing project.
  23. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 51

    $ mkdir scss $ mv css/styles.css scss/styles.scss Setting up tools. In this case, Compass.
  24. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Use

    sass-convert 52 How we get started with Sass in an existing project.
  25. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 53

    $ sass-convert --help Usage: sass-convert [options] [INPUT] [OUTPUT] $ $ cd theme-dir $ sass-convert --recursive --from=css --to=scss css scss Setting up tools. In this case, Compass.
  26. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Use

    http://css2sass.heroku.com 54 How we get started with Sass in an existing project.
  27. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 58

    dev[405]% grep background-color * style.css: background-color: #edf5fa; style.css: background-color: #ddecf5; style.css: background-color: #e6f1f7; style.css: background-color: #d4e7f3; style.css: background-color: #edf5fa; style.css: background-color: #fcfce8; style.css: background-color: #fcf9e5; style.css: background-color: #fbf5cf; style.css: background-color: #fefefe; style.css: background-color: #f5f5f5; style.css: background-color: #fdf5e6; style.css: background-color: #fdf2de; style.css: background-color: #fbe4e4; style.css: background-color: #fbdbdb; style.css: background-color: #ffcccc; style.css: background-color: #ffffdd; style.css: background-color: #ddffdd; Before variables...
  28. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 59

    $color-main: rgb(255,251,114); $color-second: rgb(70,87,204); $color-hilite: rgb(189,177,255); ... .button { background-color: $color-main; ... } See? Easy!
  29. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 60

    $font-times: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif; $font-garamond: "Palatino Linotype", Palatino, Palladio, "URW Palladio L", "Book Antiqua", Baskerville, "Bookman Old Style", "Bitstream Charter", "Nimbus Roman No9 L", Garamond, "Apple Garamond", "ITC Garamond Narrow", "New Century Schoolbook", "Century Schoolbook", "Century Schoolbook L", Georgia, serif; Uses of variables: fonts http://css-tricks.com/snippets/css/font-stacks/
  30. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 62

    $ourBlue : #1f4363; $ourBlueLight : #355673; $ourBlueLighter : #6c869d; $ourBlueDark : #0e2c47; $ourBlueDarker : #212939; $ourBlueHover : #7e99b3; ... $color_border $ourBlue; $color_link: $ourBlue; $table_header: $ourBlueLighter; Use descriptive AND functional variable names http://sachagreif.com/sass-color-variables
  31. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 64

    .navigation { a { display: block; padding: .5em; color: $color-link; border: none; } b { font-size: .9em; } span { display: block; font-size: .8em; } } .navigation a { display: block; padding: .5em; color: #444040; border: none; } .navigation b { font-size: .9em; } .navigation span { display: block; font-size: .8em; } Sass syntax, talking nesting
  32. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 66

    Sass syntax, talking @extend .box { padding: 2em; color: $color-text; background-color: $color-bg; } .box-warning { @extend .box; border: 2px dotted $color-yikes; } .box-success { @extend .box; border: 2px dotted $color-success; } .box-info { @extend .box; border: 2px dotted $color-info; }
  33. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 67

    Sass syntax, talking @extend .box, .box-warning, .box-success, .box-info { padding: 2em; color: #333333; background-color: white; } .box-warning { border: 2px dotted #cc0000; } .box-success{ border: 2px dotted #33cc00; } .box-info { border: 2px dotted #996633; }
  34. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz <div

    class=”box box-info”> ... </div> 68 Sass syntax, talking @extend
  35. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 69

    Sass syntax, talking @extend <div class=”box-info”> ... </div>
  36. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 71

    Sass syntax, @mixin @mixin module($parent-color) { color: darken($parent-color, 50%); } .main_module { @include module(#ccc); min-height: 3em; } .sidebar_module { @include module(#444); min-height: 2em; }
  37. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 73

    Sass syntax, @mixin @import "compass/css3/box-sizing"; * { @include box-sizing(border-box); } http://compass-style.org/reference/compass/css3/box_sizing/
  38. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 77

    Quick! Sass in 5 slides! @if/@else @for @each @functions (return a single value)
  39. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 79

    @mixin bp($point) { $bp-mobile: "(max-width: 600px)"; $bp-notso: "(max-width: 1250px)"; $bp-fullon: "(max-width: 1600px)"; @if $point == mq-fullon { @media #{$bp-fullon} { @content; } } @else if $point == mq-notso { @media #{$bp-notso} { @content; } } @else if $point == mq-mobile { @media #{$bp-mobile} { @content; } } }
  40. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 80

    h1 { font-size: 20px; font-family: $font-main; @include bp(mq-notso) { font-size: 30px; } @include bp(mq-fullon) { font-size: 60px; } }
  41. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 81

    h1 { font-size: 20px; } @media (max-width: 1250px) { h1 { font-size: 30px; } } @media (max-width: 1600px) { h1 { font-size: 60px; } }
  42. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Embrace the DRY principle 2. Make changes easy 3. Make finding mistakes easy 82 Guiding principles!
  43. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz More

    Information. 83 Sass for Designers Pragmatic Guide To Sass Sass and Compass in Action
  44. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 84

    sass --watch --line-numbers --style expanded scss:css
  45. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 87

    compass config config.rb --sass-dir=scss \ --css-dir=css --javascripts-dir=js \ --output-style=expanded How to create a compass conifig.rb file
  46. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Embrace the DRY principle 2. Make changes easy 3. Make finding mistakes easy 94 Guiding principles!
  47. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Embrace the DRY principle 2. Make changes easy 3. Make finding mistakes easy 96 Guiding principles!
  48. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 100

    <script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ': 35729/livereload.js? snipver=1"></' + 'script>')</ script> If you don’t use browser plugins, you need this JS for LiveReload
  49. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 101

    drupal_add_html_head( array( '#type' => 'markup', '#markup' => '<script>document.write(\'<script src="http://\' + (location.host || \'localhost\').split(\':\')[0] + \':35729/livereload.js? snipver=1"></\' + 'script>\')</ script>'), 'livereload' );
  50. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz IE

    options http://github.com/dvdotsenko/livereload_ie_extension http://reloadit.codeplex.com/ 104 LiveReload IE options
  51. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz browser-sync

    106 https://github.com/shakyShane/browser-sync/wiki/options
  52. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 108

    <script src='//10.1.9.52:3000/socket.io/socket.io.js'></script> <script>var ___socket___ = io.connect('http://10.1.9.52:3000');</script> <script src='//10.1.9.52:3001/client/browser-sync-client.min.js'></script>
  53. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 109

    drupal_add_html_head( array( '#type' => 'markup', '#markup' => " <script src='//10.1.9.52:3000/ socket.io/socket.io.js'></script> <script>var ___socket___ = io.connect('http:// 10.1.9.52:3000');</script> <script src='//10.1.9.52:3001/client/ browser-sync-client.min.js'></script> ", );
  54. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 111

    module.exports = { files: "css/*.css", proxy: { host: "drupalsouth.localhost", port: 8082 }, ghostMode: { clicks: true, links: true, forms: true, scroll: true }, open: true, injectChanges: false, notify: true, };
  55. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Embrace the DRY principle 2. Make changes easy 3. Make finding mistakes easy 114 Guiding principles!
  56. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Alfred

    http://alfredapp.com/ Quicksilver http://qsapp.com/ Launchbar http://www.obdev.at/products/launchbar/ 116
  57. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Skylight

    http://www.candylabs.com/skylight Launchy http://www.launchy.net/ http://pylaunchy.sourceforge.net/docs/ 117
  58. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Gnome

    Launch Box https://live.gnome.org/ Gnome Do http://do.davebsd.com/ Launchy http://www.launchy.net/ http://pylaunchy.sourceforge.net/ 118
  59. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 125

    https://github.com/zenorocha/alfred-workflows/ https://github.com/aiyodk/Alfred-Extensions/tree/master/AlfredApp_2.x https://github.com/willfarrell/alfred-workflows Alfred Workflows
  60. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 130

    $ npm install -g grunt-cli Install the grunt package
  61. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz YEOMAN

    http://yeoman.io/ 131 Yeoman will be the grunt initializer later.
  62. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 132

    $ npm install -g grunt-init This is one way to start using grunt in a project, use grunt-init
  63. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 133

    $ git clone https:// github.com/gruntjs/grunt- init-gruntfile.git ~/.grunt-init/gruntfile Download and save the grunt template files
  64. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 134

    $ grunt-init gruntfile Generate the files grunt needs
  65. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 135

    package.json Gruntfile.js The two files grunt uses
  66. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 136

    { "engines": { "node": ">= 0.10.0" }, "devDependencies": { "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.7.2", "grunt-contrib-watch": "~0.5.3", } } This is what a package.json file looks like
  67. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Watch for Sass file changes 2. Compile the Sass to CSS 3. Refresh the browser on change 137 What we want grunt to do.
  68. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 138

    module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: { options: { banner: '/*! <%= pkg.name %> <%="yyyy-mm-dd") %> */\n' }, build: { src: 'src/<%= pkg.name %>.js', dest: 'build/<%= pkg.name %>.min.js' } } }); // Load the plugin that provides the "uglify" task. grunt.loadNpmTasks('grunt-contrib-uglify'); // Default task(s). grunt.registerTask('default', ['uglify']); }; A basic Gruntfile.js file
  69. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 139

    $ npm install grunt-contrib-compass --save-dev Installing the compass compiling node package
  70. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz “grunt

    compass” 141 What I searched for on npmjs.org
  71. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 143

    Just like we have abandoned modules, node does, too.
  72. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 144

    $ npm install grunt-contrib-compass --save-dev Installing the compass compiling node package
  73. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 145

    $ ls Gemfile! ! README.txt fonts node_modules template.php Gemfile.lock bs-config.js images package.json templates Gruntfile.js config.rb js screenshot.png theme.info Guardfile! css logo.png scss widgets
  74. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 147

    grunt.initConfig({ compass: { dist: { options: { config: 'config.rb' } } } });
  75. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 148

    grunt.initConfig({ watch: { css: { files: ['**/*.scss'], tasks: ['compass'] } }, compass: { dev: { options: { sassDir: 'scss', cssDir: 'css', outputStyle: 'expanded' } }, } });
  76. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 149

    grunt.initConfig({ watch: { css: { files: ['**/*.scss'], tasks: ['compass'] } }, compass: { dev: { options: { sassDir: 'scss', cssDir: 'css', outputStyle: 'expanded' } }, } });
  77. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 150

    grunt.initConfig({ watch: { css: { files: ['**/*.scss'], tasks: ['compass'] } }, compass: { dev: { options: { sassDir: 'scss', cssDir: 'css', outputStyle: 'expanded' } }, } });
  78. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 151

    grunt.loadNpmTasks('grunt-contrib-compass'); ... grunt.registerTask('default', ['compass']);
  79. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 152

    grunt.registerTask('gogogo', ['browser_sync', 'watch']);
  80. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Find module 2. Install with npm install --save-dev 3. Add the task to our Gruntfile.js file 4. Add the tasks to a command 5. Run the command ... 7. Profit! 154
  81. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Watch for Sass file changes 2. Compile the Sass to CSS 3. Refresh the browser on change 155 What we want grunt to do.
  82. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 156

    $ npm install grunt-browser-sync --save-dev
  83. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 157

    browser_sync: { bsFiles: { src: [ 'css/*.css', 'img/*', 'js/*.js' ] }, options: { watchTask: true, proxy: { host: "kitthod.localhost", port: 8082 }, server: false, } } https://www.npmjs.org/package/grunt-browser-sync
  84. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Implement

    a design or prototype Update the designs Make sure it works in all browsers Make it faster 159
  85. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Reduce file sizes 2. Reduce the number of files 3. Reduce content rendering time 160
  86. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Reduce file sizes 2. Reduce the number of files 3. Reduce content rendering time 161
  87. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz npm

    install grunt-contrib-imagemin --save-dev 163 Make pages load faster by reducing image sizes
  88. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 164

    imagemin: { prod: { files: [{ expand: true, cwd: 'imgs-src/', src: ['**/*.{png,jpg,gif}'], dest: 'imgs/' }] } }
  89. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz npm

    install grunt-svgmin --save-dev 165 Reduce SVG sizes, too
  90. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz npm

    install grunt-contrib-cssmin --save-dev 166 Minimize CSS files
  91. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz npm

    install grunt-contrib-uglify --save-dev 167 Minimze javascript files
  92. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz npm

    install grunt-contrib-jshint --save-dev 168 Use jshint when editing your Gruntfile.js https://github.com/gruntjs/grunt-contrib-jshint
  93. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Reduce file sizes 2. Reduce the number of files 3. Reduce content rendering time 170
  94. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 174

    @import "compass/utilities/sprites"; ... $sprites-spacing: 20px; @import “../img/sprites/*png”; Creating sprite images with Compass
  95. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 175

    @import "compass/utilities/sprites"; ... $orange-spacing: 20px; @import “../img/orange/*png”; Sprite names are dependent on your directory name
  96. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 176

    @import "compass/utilities/sprites"; ... $awesome-spacing: 20px; @import “../img/awesome/*png”; Sprite names are dependent on your directory name
  97. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 177

    Using generated sprites .footer-follow-us{ .twitter { @include awesome-sprite(follow-us-twitter); } .facebook { @include awesome-sprite(follow-us-fb); } .google { @include awesome-sprite(follow-us-google); } .pinterest { @include awesome-sprite(follow-us-pins); } } .awesome-sprite, .footer-follow-us .twitter, .footer-follow-us .facebook, .footer-follow-us .google, .footer-follow-us .pinterest { background: url('../images/ awesome-s34fe0604ab.png') no-repeat; } .footer-follow-us .twitter { background-position: 0 -96px; } .footer-follow-us .facebook { background-position: 0 0; } .footer-follow-us .google { background-position: 0 -32px; } .footer-follow-us .pinterest { background-position: 0 -64px; }
  98. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Reduce file sizes 2. Reduce the number of files 3. Reduce content rendering time 178
  99. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Don’t

    nest more than 3 deep 179 http://css-tricks.com/sass-style-guide/
  100. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Avoid

    using tag selectors Use class selectors if you can. 180 https://developers.google.com/speed/docs/best-practices/rendering
  101. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 1.

    Embrace the DRY principle 2. Make changes easy 3. Make finding mistakes easy 181 Guiding principles of making our workflows AWESOME
  102. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz npm

    install grunt-phantomcss --save-dev install details at https://www.npmjs.org/package/grunt-phantomcss 184
  103. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 185

    phantomcss: { desktop: { options: { screenshots: 'test/visual/desktop/', results: 'results/visual/desktop', viewportSize: [1024, 768] }, src: [ 'test/visual/**.js' ] }, mobile: { options: { screenshots: 'test/visual/mobile/', results: 'results/visual/mobile', viewportSize: [320, 480] }, src: [ 'test/visual/**.js' ] } } phantomcss grunt task
  104. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 186

    casper.start('http://drupalsouth.localhost:8082/') .then(function() { phantomcss.screenshot('#region-branding', 'region-branding'); }). then( function now_check_the_screenshots(){ phantomCSS.compareAll(); }); phantomcss website flow
  105. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Seeing

    failures 187 http://tldr.huddle.com/blog/css-testing/
  106. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz Implement

    a design or prototype Update the designs Make sure it works in all browsers Make it faster 189 What magic do we do?
  107. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz https://github.com/mattbanks/Drupal-7-Starter-Theme

    https://drupal.org/project/aurora https://drupal.org/project/omega 191 Projects already set up with all of this!
  108. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz <div

    id="banner"> <div class="logo"></div> <ul id="navigation"> <li><a href=""></a></li> <li><a href=""></a></li> <li><a href=""></a></li> <li><a href=""></a></li> </ul> </div> 195
  109. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz 199

    npm install grunt-drush --save-dev https://github.com/nickpack/grunt-drush
  110. DrupalSouth 2014 • Kitt Hodsden • @kitt • http://ki.tt/dsnz I

    skipped over Source maps Where in your Sass files that CSS is from http://code.tutsplus.com/tutorials/developing-with-sass- and-chrome-devtools--net-32805 Bundler Managing what ruby gems you have installed http://bundler.io/ Creating your own Grunt tasks http://gruntjs.com/creating-tasks Yeoman Generating modules, themes, even template files. http://yeoman.io/ 201