29
Responsive Design With Visualforce Pages May 22, 2014

Responsive Web Design with Visualforce

Embed Size (px)

DESCRIPTION

Slide deck from my Salesforce1 World Tour talk on Responsive Design.

Citation preview

Page 1: Responsive Web Design with Visualforce

Responsive DesignWith Visualforce PagesMay 22, 2014

Page 2: Responsive Web Design with Visualforce

Keir BowdenCTO, BrightGen@bob_buzzard

Page 3: Responsive Web Design with Visualforce

What

Why

How

Bootstrap

Demo

AgendaWhat

Page 4: Responsive Web Design with Visualforce

Demo Page

Page 5: Responsive Web Design with Visualforce

What is Responsive Design?

Pages respond to device– Viewport size

– Orientation

Term coined by Ethan Marcotte– http://bobbuzz.me.uk/1hI879K

Page 6: Responsive Web Design with Visualforce

TL;DL

Page 7: Responsive Web Design with Visualforce

What

Why

How

Bootstrap

Demo

Agenda

Why

Page 8: Responsive Web Design with Visualforce

Why Use Responsive Design?

One site to rule them all– DRY

– Visitor Tracking

– Would need many m. sites

Google’s Recommended Approach (SEO)– Easier to crawl

– Better for the link algorithm

– http://bobbuzz.me.uk/1g7G3wV

Page 9: Responsive Web Design with Visualforce

What

Why

How

Bootstrap

Demo

Agenda

How

Page 10: Responsive Web Design with Visualforce

Pillar 1 – Viewport Meta Tag

Viewport Meta Tag <meta name="viewport” content="width=device-width, initial-scale=1.0”> </meta>

width=device-width– Report actual size of device

initial-scale=1.0– Display page actual size

Page 11: Responsive Web Design with Visualforce

Pillar 2 - Fluid Grid

Page 12: Responsive Web Design with Visualforce

Reflow

1 2 3 4 5 6 7 8 9 10 11 12

1 2 3 4 5 6 7 8 9 10 11 12

Desktop

3

1

2

Phone1 2 3 4 5 6 7 8 9

10

11

12

1 2 3 4 5 6 7 8 910

11

12

Tablet

Page 13: Responsive Web Design with Visualforce

Pillar 3 - CSS Media Queries

Expression Limiting Scope of CSS.sidebar { display: none;}

@media (min-width: 1024px) { .sidebar { display: block; }}

Page 14: Responsive Web Design with Visualforce

What

Why

How

Bootstrap

Demo

Agenda

Bootstrap

Page 15: Responsive Web Design with Visualforce

Bootstrap

Responsive Front End Framework

HTML, CSS and JavaScript

Mobile First

Number 1 project on GitHub (forks/stars)

http://getbootstrap.com

Page 16: Responsive Web Design with Visualforce

Fluid Grid

12 column default

4 Breakpoints– Large > 1200px

– Medium > 992px

– Small > 768px

– Extra Small < 768x

Column Span Style Classes– col-md-6

– col-xs-12

Page 17: Responsive Web Design with Visualforce

Visualforce + Bootstrap

Visualforce is container– Thin wrapper around HTML markup

– Provides access to data

Minimal Page Generation– No <head>, <body> tags

– Exclude standard style sheeets

Page 18: Responsive Web Design with Visualforce

Visualforce + Bootstrap

Avoid Most Standard Components – No <apex:pageblock /> – not responsive

– <apex:includeScript>, <apex:stylesheet/>

– <apex:outputText>

– <apex:repeat />

Forms versus Remoting– Remoting = fast

– Forms + rerender = DOM manipulation

Page 19: Responsive Web Design with Visualforce

What

Why

How

Bootstrap

Demo

Agenda

Demo

Page 20: Responsive Web Design with Visualforce

Demo

Blog landing page– Recent posts

– Comments

– Search

– Social media

http://bobbuzz.me.uk/SF1RD

Github : http://bobbuzz.me.uk/SF1GH

Page 21: Responsive Web Design with Visualforce

Code

Post PostPost

SearchAbout

12

Post PostPost

SearchAbout

9 3

Page 22: Responsive Web Design with Visualforce

Code

Page 23: Responsive Web Design with Visualforce

Code

Page 24: Responsive Web Design with Visualforce

Challenges - Tables

Tables are wide

Columns wrap when narrow

Rows need to remain consistent

Page 25: Responsive Web Design with Visualforce

Tables - Solutions

Hide Columns– Bad idea

– Punishes mobile

– Allow add back

Scrolling table

Transform to list– No row/column comparison

http://demos.jquerymobile.com/1.4.2/table-reflow/

Page 26: Responsive Web Design with Visualforce

Challenges - Images

Desktop images can be large

Use bandwidth, memory

86% of sites deliver the same content regardless of device– http://bobbuzz.me.uk/1kMbZs9

Page 27: Responsive Web Design with Visualforce

Images - Solutions

Download and hide– All images, every device

– Only show subset

Download and shrink– One image, resized

– Wasteful

Page 28: Responsive Web Design with Visualforce

Images - Solutions

Picturefill, by Scott Jehl– Multiple images on server

– Client loads best image for device

– Uses JavaScript – image loaded after DOM ready<span data-picture="1" data-alt=”BlogLImage"> <span data-src=“small_image"></span> <span data-src=“medium_image" data-media="(min-width: 46em)"></span> <span data-src=”large_image" data-media="(min-width: 64em)"></span></span>

http://bobbuzz.me.uk/RIcMD2

Page 29: Responsive Web Design with Visualforce

Thank You