salesforce world tour 2016 : lightning out : components on any platform

24
Lightning Out: Components on Any Platform London | May 19, 2016

Upload: andyinthecloud

Post on 09-Apr-2017

900 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Lightning Out: Components on Any PlatformLondon | May 19, 2016

Page 2: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Speaker

Andrew FawcettCTO, FinancialForce

Salesforce MVP, Certified Developer and Advanced Developer

@andyinthecloudandyinthecloud.com

Page 3: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Agenda

▪Components, Containers and Events▪Address Finder Components▪Components in Lightning Experience! *NEW*▪Components on Any Platform aka “Lightning Out” *NEW*

▪Components in Google App Add-ons▪Google App Script Tips and Tricks▪Resources and Q&A

Page 4: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Component Container- Loads Components- Ask each Component render- Manages Events

Lightning Components Overview

Component- Renders- Attributes- Methods- Events

Page 5: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

▪Application vs Component Events

▪Component events within containment hierarchy

Lightning Components Publish and Subscribe

Component B- Handles event

Component C- Handles event

Event- MyAppEvent

MyAppEvent

Component A- Registers the event- Fires event

Page 6: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Address Finder in Lightning Experience

Separation of Concerns between searching and how addresses are displayed

AddressInfo Event

AddressFinder.cmp

Address.cmp

Page 7: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

DemoCustomising Lightning Experience

with Lightning Components

Page 8: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Enabling for Lightning App Builder and Pages

General steps to enable for Lightning App Builder and Pages.

● Enable My Domain in Your Org● Add a New Interface/s to Your Component● Add a Design Resource to Your Component Bundle● Optional: Add an SVG Resource to Your Component Bundle

More information can be found in the documentation.

Page 9: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Lightning Out, Components on Any Platform

Page 10: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Lightning Out Requirements

▪Lightning Components should be GLOBAL▪Lightning “Dependency” App

– Only top level components you intend to use▪Container Page supports <SCRIPT> import

– Import lightning.out.js library into the page▪Authentication is handled by the “container” or you!

– Session ID is available (e.g Visualforce page,)– Or implements oAuth

Page 11: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Lightning Out: Components on Any Platform

Page 12: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

What about Google App Add-ons?

Page 13: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

DemoIntegrating Lightning Components

in Google Documents via Google App Add-ons

Page 14: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Address Finder in Google Documents

Separation of Concerns means that the Address Finder component knows nothing of how the AddressInfo event will be handled. In this case by some Google App Script!AddressFinder.cmp

AddressInfo Event

Page 15: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

What just happened?

ComponentA

https://mydomain.lightning.force.com/lightning

<html><body><div id=”mycontainer”>

</div><script src=”./lightning.out.js”></script><script>$Lightning.use( “LightningOutApp” ... “ComponetA”... “mycontainer”);</script></div>...

https://*.googleusercontent.com

LightingOutApp

ComponentB

ComponentChild

1

2CORS

3Component A

4

Page 16: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

CORS, Cross-Origin Resource Sharing?

https://...lightning.force.com

Resources /some/api/resource - GET, POST, UPDATE, PATCH ...

https://*.googleusercontent.com

<script>XMLHttpRequest….. send(...)</script>

Page 17: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Exposing your Components Lightning Out

Note: Inclusion of SLDS css file in Lightning “Dependency” App. Must be absolute path.

Page 18: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Using the Lightning Out JavaScript API

Note: Notice the class=”slds” being applied to the containing <div> element. Currently styles defined by the container are not imported by Lightning Out. Hence must be explicitly imported via the Lightning “Dependency” App.

Page 19: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Using the Lightning Out JavaScript API

Disclosure: $A.eventService is not presently documented. Follow source code link for an update on this code following this presentation.. Callback approach?

Page 20: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Google App Script and Lightning Out

▪oAuth is supported, but the user experience is not great

– See https://github.com/googlesamples/apps-script-oauth2

Page 21: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Google App Script Document API’s

▪Rich API’s for working with document content

Page 22: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

▪Rich UI’s in HTML pose a challenge to traditional accessibility tools

▪Accessible Rich Internet Applications (Aria)– Research it and find out more at

https://www.w3.org/WAI/intro/aria.php ▪Lightning Design System

Examples adopting Aria!

Global Accessibility Awareness Day

Page 23: Salesforce World Tour 2016 : Lightning Out : Components on any Platform

Resources and Q&A▪Source Code in GitHub Stash

– https://gist.github.com/afawcett/6a38c589e3ae18ad2d16d4ee98e00b17

▪ Lightning Components Developer Guide– https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/l

ightning▪Quickstart: Add-on for Google Docs

– https://developers.google.com/apps-script/quickstart/docs#set_it_up

▪Google App Script oAuth2 Library– https://github.com/googlesamples/apps-script-oauth2

▪My Twitter and Blog– @andyinthecloud http://andyinthecloud.com

Page 24: Salesforce World Tour 2016 : Lightning Out : Components on any Platform