Unit 3 - Day 4

"Where things start make sense..."

Draft Reviews First 5

  1. All applicable PDF content available on the site.
  2. Proper flow through all sttages/steps of the timeline.
  3. Navigating from stage to stage should flow easily. (UX flow)
  4. Must be accessibile (alt tags, content visibility, scaling, color blindness, touch friendly)
  5. Works on all major devices.

Draft Reviews Last 5

  1. Interface must be intuitive/easy to use (How do i use this interface? ooh thats how!)
  2. Flow and style of layout should be easy to understand (how much work does it take to find a certain piece of information)
  3. Design should not be cluttered, should be inviting, stress-free
  4. Tested against user personas.
  5. Should not require more than 3 clicks to get to your destination

Submit your Midterm draft reviews

http://bit.ly/inf-af-mt

http://bit.ly/inf-hb-mt

http://bit.ly/inf-t4-mt

http://bit.ly/inf-w3-mt

Questions?

RWD Images

We're going to use Foundation's Interchange

Interchange syntax

<img data-interchange="
    [image_path, (media query)],
    [image_path, (media query)]">

Interchange Media Queries

<img data-interchange="
    [image_path, (media query)], [image_path, (media query)]">
Name Media Query
default only screen and (min-width: 1px)
small only screen and (min-width: 1px)
medium only screen and (min-width: 641px)
large only screen and (min-width: 1024px)
landscape only screen and (orientation: landscape)
portrait only screen and (orientation: portrait)
retina only screen and (min-device-pixel-ratio: 2),
only screen and (min-resolution: 192dpi),
only screen and (min-resolution: 2dppx)
<img data-interchange="
    [image_path, (media query)], [image_path, (media query)]">

Write interchange that swaps image1.jpg with image2.jpg when it is at large

Name Media Query
default only screen and (min-width: 1px)
small only screen and (min-width: 1px)
medium only screen and (min-width: 641px)
large only screen and (min-width: 1024px)
landscape only screen and (orientation: landscape)
portrait only screen and (orientation: portrait)
retina only screen and (min-device-pixel-ratio: 2),
only screen and (min-resolution: 192dpi),
only screen and (min-resolution: 2dppx)
<img data-interchange="
    [image1.jpg, (default)], [image2.jpg, (large)]">

Now add a retina version

image1-2x.jpg

<img data-interchange="
    [image1.jpg, (default)],
    [image2.jpg, (large)],
    [image1-2x.jpg, (retina)]">

Add your own Media Query

other.jpg at screen and min-width 1px

<img data-interchange="
    [image1.jpg, (default)],
    [image2.jpg, (large)],
    [image1-2x.jpg, (retina),
    [other.jpg, (only screen and (min-width: 1px))]">

Add your own Media Query

big.jpg min-width 1280px

<img data-interchange="
    [image1.jpg, (default)],
    [image2.jpg, (large)],
    [image1-2x.jpg, (retina),
    [other.jpg, (only screen and (min-width: 1px))]
    [big.jpg, ((min-width: 1280px))]">

Interchange Notes

See the double parenthesis? Excluding only screen makes it look like that.

<img data-interchange="
    [image1.jpg, (default)],
    [image2.jpg, (large)],
    [image1-2x.jpg, (retina),
    [other.jpg, (only screen and (min-width: 1px))]
    [big.jpg, ((min-width: 1280px))]">

Interchange Notes

If breaking up the rules on new lines, each line must be a complete rule.

<img data-interchange="
    [image1.jpg, (default)],
    [image2.jpg, (large)],
    [image1-2x.jpg, (retina),
    [other.jpg, (only screen and (min-width: 1px))]
    [big.jpg, ((min-width: 1280px))]">

Name your own Media Queries

$(document).foundation('interchange', {
  named_queries : {
    myMq : '(max-width: 200px)'
  }
});

Not just for images either!

<div data-interchange="
    [../examples/interchange/default.html, (small)],
    [../examples/interchange/medium.html, (medium)],
    [../examples/interchange/large.html, (large)]">
  <div data-alert class="alert-box secondary radius">
    This is the default content.
    <a href="#" class="close">&times;</a>
  </div>
</div>

Code this Grid

grid1

<div class="row">
  <div class="small-2 columns">2 columns</div>
  <div class="small-10 columns">10 columns</div>
</div>

Code this Grid

grid1

<div class="row">
  <div class="small-2 columns">...</div>
  <div class="small-4 columns">...</div>
  <div class="small-6 columns">...</div>
</div>

Code this Grid

grid1

<div class="row">
  <div class="large-2 columns">2 columns</div>
  <div class="large-4 columns">4 columns</div>
  <div class="large-6 columns">4 columns</div>
</div>

small = 12 implied when no small class is given

Foundation Grid

Encapsulated by .row

Each column needs .column or .columns

small-x (small-12 is implied if you don't specify)

medium-x (medium-12 is implied if you don't specify small)

large-x

Visibility Classes

show/hide

class="show-for-small-only"
class="show-for-medium-up"
class="show-for-medium-only"
class="show-for-large-up"
class="show-for-large-only"
class="show-for-xlarge-up"
class="show-for-xlarge-only"
class="show-for-xxlarge-up"
class="show-for-touch"

CSS

Lots of options!

Which of the following is from the CSS3 Spec?

  1. Media Queries
  2. @font-face
  3. Border-Radius
  4. CSS Floats
  5. Border-Style

Browser Compatbility

IE

<!DOCTYPE html>
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->

HTML5 boilerplate

Caniuse.com

Progressive Enhancement

Modernizr

Adds classes to the html element that you can target for features

Given the following classes

borderradius, boxshadow

How should you progressively enhance .foo for browsers without these features?

.foo {
    border-radius: 10px;
    box-shadow: 3px 3px #333;
}

Attribute Selectors

elem[att^="val"] {} //– the "begins with" selector
elem[att$="val"] {} //– the "ends with" selector
elem[att*="val"] {} //– the "contains" selector

Select a tags whose hrefs start with http

^ (begin) | $ (ends) | * (contains)

a[href^="http"] {}

Select a title contains "foo"

^ (begin) | $ (ends) | * (contains)

a[title*="foo"] {}

Select a data-name ends with "heisenberg"

a[title$="heisenberg"] {}

Apply the link hover cursor to an element when hovered

Using SASS nesting

a {
    color: blue;
    &:hover {
        cursor: pointer;
    }
}

:before & :after

elem {
    &:before {
        background-color: red;
    }
    &:before {
        background-color: purple;
    }
}

::before & ::after if you are IE9+

Almost exclusively used with content

elem {
    &:before {
        content: "";
        background-color: red;
    }
}

Add three right angle brackets after a link

>>>

a {
    &:before {
        content: "&gt;&gt;&gt;";
    }
}

SVG Images

Scalable Vector Graphics

Which of the Following are true of SVG over Raster?

  1. Smaller File Sizes
  2. Crisp Images when Zoomed
  3. SVG is highly compatible with browsers
  4. Can be easily combined
  5. Scalable

Embed an SVG image

image.svg

<img src="image.svg">

Data URI's

http://jpillora.com/base64-encoder/

li { 
  background: 
    url(data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7)
    no-repeat
    left center;
  padding: 5px 0 5px 25px;
}

Be careful with data URI's

Can get HUGE, FAST!

Tend to be very slow on mobile devices

Gradients

Official CSS Spec:

background: linear-gradient(top, #333333, #00cc0)

Browser Compatibility

Vendor Prefixes FTL

background: -webkit-gradient(linear, left top, left bottom, from(#333333), to(#00cc00));
background: -webkit-linear-gradient(top, #333333, #00cc00);
background: linear-gradient(top, #333333, #00cc00);

Vendor prefixes are going away

Luckily you don't have to worry about them much anymore, they have been abstracted away from typical developement in the recent years.

Vendor Prefixes

Compass / Auto Prefixer do this for you now.

We're going to focus on Compass today

Which of the following will compile with Compass to proper CSS?

  1. background: linear-gradient(top, #333, #000);
  2. background: @include linear-gradient(top left, #333, #0c0);
  3. @include background(linear-gradient(top left, #333, #0c0)); 
  4. @include background(image-url("foo.png"),
             linear-gradient(top left, #333, #0c0)); 
  5. background: url(foo.png),
                linear-gradient(top, #333333, #00cc00);

Compass is just a collection of Mixins

So pull them in using @include's

Browse to compass-style.org

Click Reference

"examples" are your friends.

We'll be using Sassmeister

http://sassmeister.com

Click HTML (may need to refresh page after enabling)

Start by Importing Compass

Your first two lines of a sass file should be:

@charset "UTF-8";
@import "compass";

Div with background image foo.png

background-image: url(foo.png);

Div with background image foo.png &
Linear gradient top left #000 to #fff

Compass images

@include background(image-url("foo.png"),
         linear-gradient(top left, #000, #fff));

text-shadow 3px, box-shadow 5px

@include text-shadow(3px);
@include box-shadow(5px);

Define all link colors in one line

@include link-colors($normal, $hover, $active, $visited, $focus);

Div with box-sizing border-box

@include box-sizing(border-box);

Custom font (2 font types, ttf, woff)

@include font-face("Name", font-files("name.ttf", "name.woff"));

Buuuuuut....

Compass fonts aren't bulletproof

For "Bullet-Proof" we use Nicole Sullivan's technique

Icon Fonts

You can also use Zurb's Icon fonts

Foundation Icon Fonts 3

Fontello is a viable alternative, it also lets you pick and choose fonts and add your own images as fonts

Foundation Icons

Create a button with a Star icon to the left of it

<button><i class="fi-star"></i> Star</button>

Sass & Color

Interactive demo Sass color functions

Make a div have 50% opacity

@include opacity(50);

Only need this for providing Old IE opacity, if not just use "opacity: .5;"

RGBa Color

Opacity affects HEX colors and whatever they contain

rgba(255, 255, 255, 0.5);

Give a div #bada55 background color with 70% opacity

background: rgba(186, 218, 85, 0.7);???
background: rgba(#bada55, 0.7);

Next Time on...

INF 362!

  1. Analytcs
  2. Image Size
  3. Image Sprite
  4. NPM
  5. Grunt
  6. Bower
  7. Linting
  8. Autoprefix
  9. Asset Minification
  10. HTTP request optimization
  11. Asset Concat
  12. Before vs After
  13. JS Perf

For Next Class

  • Midterm due.

Readings for our last unit

  1. Print Stylesheets
  2. Grunt is not Weird or Hard
  3. Optimization Best Practices
  4. Linting your JS
  5. Getting started with Google Analytics
  6. What is Jekyll?
  7. Structure of Jekyll Templates