Dreamforce 14 : Responsive Design with Visualforce and Twitter Bootstrap

Preview:

DESCRIPTION

Slide deck from my Dreamforce 14 session on Responsive Design with Visualforce and Twitter Bootstrap

Citation preview

Responsive Design with Visualforce and Twitter BootstrapKeir Bowden

CTO, BrightGen

@bob_buzzard

Safe Harbor

Safe harbor statement under the Private Securities Litigation Reform Act of 1995:

This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.

 

The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.

 

Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Keir BowdenCTO, BrightGen

Agenda

What

Why

How

Bootstrap

Demo

What

What is Responsive Design

“Provide an optimal viewing experience – easy reading and navigation with a minimum of resizing, panning and scrolling – across a wide range of devices”

Wikipedia

• Pages respond to device– Viewport size– Orientation

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

Agenda

What

Why

How

Bootstrap

Demo

Why

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

Agenda

What

Why

How

Bootstrap

Demo

How

Cornerstone 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

• user-scalable=no

Cornerstone 2 – Fluid Grid

Reflow

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

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

Phone1

2

3

4

Cornerstone 3 - CSS Media Queries• Expression Limiting Scope of CSS

.sidebar { display: none;}

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

Agenda

What

Why

How

Bootstrap

Demo

Bootstrap

Bootstrap• Responsive Front End Framework

• HTML, CSS and JavaScript

• Mobile First

• Number 1 project on GitHub (forks/stars)

http://getbootstrap.com

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

Visualforce + Bootstrap• Visualforce is container

– Thin wrapper around HTML markup– Provides access to data

• Minimal Page Generation– No <head>, <body> tags– Exclude standard style sheets

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

Agenda

What

Why

How

Bootstrap

DemoDemo

Demo• Blog landing page

– Recent posts– Comments– Search– Social media

• http://bobbuzz.me.uk/SF1RD

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

Code

Post PostPost

SearchAbout

12

Post PostPost

SearchAbout

9 3

Code

Code

Challenge - Images• Desktop images can be large

• Use bandwidth, memory

• In 2012, a survey found that 86% of sites deliver the same content regardless of device:– http://bobbuzz.me.uk/1kMbZs9

Solution - Images• Download and hide

– All images, every device– Only show subset

• Download and shrink– One image, resized – Wasteful

Future Solution - Images• HTML5 Picture element

– Multiple images on server– Client loads best image for device

<picture> <source media="(min-width: 1024px)” src=”large_image”></source> <source media="(min-width: 768px)” src=“medium_image”></source> <source src=“small_image"></source> <img src=“fallback_image"></img></picture>

• http://caniuse.com/#feat=picture– Chrome/Opera – experimental– Firefox – configure preference

Solution - Images• 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=”BlogImage"> <span data-src=”large_image" data-media="(min-width: 1024px)"></span> <span data-src=“medium_image" data-media="(min-width: 768px)"></span> <span data-src=“small_image"></span></span>

• http://bobbuzz.me.uk/RIcMD2