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

Sass for designers

Sass for designers

From a talk at CSS Summit in July 2013

Laura Kalbag

July 25, 2013
Tweet

More Decks by Laura Kalbag

Other Decks in Design

Transcript

  1. Slide Sass for designers @laurakalbag 2 HTML and CSS loads

    JavaScript a tiny bit Programming argh! scary! Illustration fairly often Print design every now and again Web design loads What I do
  2. Slide Sass for designers @laurakalbag 5 this talk will show

    you some of the basic features of Sass
  3. Slide Sass for designers @laurakalbag You can re-trace my steps

    later on GitHub 7 https://github.com/laurakalbag/webtalkdogwalk
  4. Slide Sass for designers @laurakalbag 18 File > Add Project…

    choose the project folder add the project to CodeKit
  5. Slide Sass for designers @laurakalbag 20 Hold shift to select

    multiple files and then click ‘Hide These Files’ hide the files we don’t want to compile or compress
  6. Slide Sass for designers @laurakalbag 22 Create an empty folder

    called ‘sass’ in the site’s root folder set up a folder for the Sass files
  7. Slide Sass for designers @laurakalbag 23 Create an empty file

    in the ‘sass’ folder and call it ‘style.scss’ our first Sass file (.scss)
  8. Slide Sass for designers @laurakalbag 24 Use the Package Manager

    to install Syntax Highlighting for Sass add syntax highlighting so Sass is easy to read
  9. Slide Sass for designers @laurakalbag 27 .scss .sass no semi-colons

    ; and no curly brackets {} semi-colons ; and curly brackets {} the differences between .scss and .sass
  10. Slide Sass for designers @laurakalbag .scss allows ordinary CSS to

    be used in the same files 28 and this is why I use it
  11. Slide Sass for designers @laurakalbag 31 Hit the refresh icon

    on the bottom left to see the style.scss file our first .scss file in CodeKit
  12. Slide Sass for designers @laurakalbag 32 compile the Sass file

    using CodeKit select the style.scss file and click ‘Compile’
  13. Slide Sass for designers @laurakalbag 33 the CSS folder CodeKit

    has created you can see where CodeKit created the folder and file
  14. Slide Sass for designers @laurakalbag 34 style.css, as generated by

    CodeKit from the style.scss file the CSS CodeKit has created
  15. Slide Sass for designers @laurakalbag 35 Select ‘Compressed’ from the

    Output Style: dropdown compress the outputted CSS to make it nice and quick
  16. Slide Sass for designers @laurakalbag 36 Select ‘Compressed’ from the

    Output Style: dropdown when CodeKit compiles, it has a progress bar and notification
  17. Slide Sass for designers @laurakalbag 43 @import “reset”; Sass partial

    syntax include this in the compiled version of this file the file name
  18. Slide Sass for designers @laurakalbag 44 Use @import to tell

    CodeKit to compile all these files into style.css
  19. Slide Sass for designers @laurakalbag 45 see how CodeKit doesn’t

    compile partials directly Save the files so CodeKit compiles them
  20. Slide Sass for designers @laurakalbag 52 /* this comment will

    show in the CSS */ // this comment will only show in the Sass Sass comment syntax
  21. Slide Sass for designers @laurakalbag 55 the CodeKit Log and

    error Syntax error: undefined variable: "$grey-dark";
  22. Slide Sass for designers @laurakalbag 59 I’ve added web fonts

    to the site but it lacks visual hierarchy
  23. Slide Sass for designers @laurakalbag 63 Sass variable operations syntax

    font-size: $unit*1.5; property a number name of the variable multiply by
  24. Slide Sass for designers @laurakalbag 64 Make the body text

    the size of the base unit multiplied by 1.5
  25. Slide Sass for designers @laurakalbag 65 Save the file and

    see how Sass compiles the variable into 15px
  26. Slide Sass for designers @laurakalbag 66 Use the base unit

    on all elements to achieve basic vertical rhythm
  27. Slide Sass for designers @laurakalbag 67 Now the hierarchy is

    clearer, but the font size is too small
  28. Slide Sass for designers @laurakalbag 68 Change the variable unit

    to affect all instances of $unit bump up the unit size by 1px
  29. Slide Sass for designers @laurakalbag 72 the web talk dog

    walk title appears twice on the page
  30. Slide Sass for designers @laurakalbag 75 Sass mixin syntax for

    defining a mixin @mixin hide { height: 0; margin: 0; overflow: hidden; padding: 0; } create a mixin mixin rules mixin name
  31. Slide Sass for designers @laurakalbag 77 Sass mixin syntax for

    including a mixin .site-title { @include hide; } include a mixin selector mixin name
  32. Slide Sass for designers @laurakalbag 79 Now the site title

    is hidden and I can reuse that rule elsewhere
  33. Slide Sass for designers @laurakalbag 82 In CSS, I would

    lay out the rules for the navigation by specificity
  34. Slide Sass for designers @laurakalbag 86 I want to make

    the selected navigation item stand out use & to use a classname selector while nesting
  35. Slide Sass for designers @laurakalbag 91 some kind of vertical

    rhythm no kind of vertical rhythm I need to fix the text in the header. It doesn’t line up.
  36. Slide Sass for designers @laurakalbag 93 With Sass, we can

    nest the media query inside the selector
  37. Slide Sass for designers @laurakalbag 94 We can use the

    unit variable in the media queries our breakpoints are now relative to our base unit
  38. Slide Sass for designers @laurakalbag 96 The line length is

    too long, the layout feels stretched out
  39. Slide Sass for designers @laurakalbag 103 box-sizing: border-box; needs backup

    with prefixes moz and webkit need prefixes to make border-box work
  40. Slide Sass for designers @laurakalbag 108 .png .svg Use SVGs

    with a clever script to detect SVG support the .svg version of the file looks crisp at any size
  41. Slide Sass for designers @laurakalbag 109 Use the .svg class

    to show an SVG version of the image the script adds ‘svg’ as a body class when SVG is supported
  42. Slide Sass for designers @laurakalbag 110 This is how I

    would use the .svg class without a parent selector
  43. Slide Sass for designers @laurakalbag 111 Sass syntax for parent

    selectors .svg & { background: url(‘../images/bone.svg’) 0 0 no-repeat; } properties parent selector
  44. Slide Sass for designers @laurakalbag 117 Sass syntax for saturating

    colour color: saturate($green-dark, 100%); colour operation property variable name amount of saturation
  45. Slide Sass for designers @laurakalbag 118 At 100% saturation, the

    green looks much brighter previous saturation level 100% saturation
  46. Slide Sass for designers @laurakalbag 120 Thank you! Catch me

    on app.net or Twitter, I’m @laurakalbag :)