SlideShare a Scribd company logo
1 of 75
Download to read offline
Building native
Windows 8 apps
using YUI 3
@tilomitra // YUI Engineer
About this talk
About this talk

 • A bit about Windows 8 and IE10
About this talk

 • A bit about Windows 8 and IE10
 • WinJS
About this talk

 • A bit about Windows 8 and IE10
 • WinJS
 • WinJS + YUI (with Demo)
About this talk

 • A bit about Windows 8 and IE10
 • WinJS
 • WinJS + YUI (with Demo)
 • Questions & Discussion
Not really focussing on...

• In-app purchases
• Packaging and submission process
• Visual Studio (I’m a VS n00b)
Apps. Opportunity.
Apps. Opportunity.
YUI 3.7.3
 We gave ourselves 10 days (which included
 weekends) to get the job done…We were able to
 add support for all these new environments
 very quickly because of YUI’s architecture.

                                       -Eric F.
Windows 8
Win8 vs WinRT
        Can run traditional Windows apps and the
Win8    new Metro apps


        “Windows 8 Lite” designed primarily for
        tablets such as the Surface.
WinRT
        Can only run Metro apps
4 different JS runtimes

• IE10 Desktop
• IE10 Start Screen (Metro)
• Webview inside a C# app
• WinJS
IE10 “Metro”

     • More restrictive than IE10 Desktop
     • Minimal support for plugins (ActiveX,
           Flash, Silverlight, etc.)*

* Metro IE10 does have Flash support but only sites that are on the Compatibility List can play Flash content.
IE10 “Metro”

     • More restrictive than IE10 Desktop
     • Minimal support for plugins (ActiveX,
           Flash, Silverlight, etc.)*

* Metro IE10 does have Flash support but only sites that are on the Compatibility List can play Flash content.
Webview
                    	
  	
  	
  	
  

<WebView Name="wv" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Source="http://yuilibrary.com"/>




   • Similar to web-views on iOS or Android
   • No access to device APIs, limited
       HTML5 support
WinJS
WinJS
• A restricted IE10 runtime with access to
  native APIs
• Allows developers to create WinRT apps
  using HTML/CSS/JS
• All scripts/styles must be available on device
WinJS
• A restricted IE10 runtime with access to
  native APIs
• Allows developers to create WinRT apps
  using HTML/CSS/JS
• All scripts/styles must be available on device
WinJS
What’s different about it?
Overview
Overview

• Uses IE10 to process HTML/CSS/JS
Overview

• Uses IE10 to process HTML/CSS/JS
• Stylesheets and scripts bundled locally
Overview

• Uses IE10 to process HTML/CSS/JS
• Stylesheets and scripts bundled locally
• No JSONP, safe innerHTML
Overview

• Uses IE10 to process HTML/CSS/JS
• Stylesheets and scripts bundled locally
• No JSONP, safe innerHTML
• Access to Windows and WinJS
  namespaces
Injecting HTML

myDiv.innerHTML	
  =	
  ‘<script>function	
  test()	
  {	
  alert("Testing,	
  Testing,	
  
123...");	
  }</script><span	
  onclick="test()">Click	
  Me</span>’

//results	
  in	
  <span>Click	
  me</span>

    List of all filtered elements
A WinJS App
                                      WinJS References


                                            ui.css

              default.html

                                           base.js



                                            ui.js
 default.js             default.css


                                         navigator.js
A WinJS App
                                                       WinJS References
                 Basic Shell
                                       Native styles         ui.css

               default.html

                                        JS Utilities        base.js



                                         UI Views            ui.js
  default.js             default.css


                                        Navigation        navigator.js
App Lifecycle               Media
   Code                    queries
Adding Pages
                        Master View       Detail View


   default.html        masterview.html   detailview.html


WinJS References
                       masterview.css    detailview.css

Other scripts/styles

                        masterview.js     detailview.js
Pages adopt MVC
Each “page” of the app has has it’s own
HTML, CSS, and JS

    View       Defined by page.html and page.css

  Controller          Defined by page.js

                  Defined in default.html and
    Model
                     available in all pages
default.html
                 default.html
                                         <div	
  i
                                         contro
                                         igator
               homepage.html             	
  	
  	
  	
  da
                 homepage.css            pages/
                  homepage.js            </div>




   A “wrapper” around different pages.
default.html
   default.html
                        <div	
  id="contenthost"	
  data-­‐win-­‐
                        control="Application.PageControlNav
                        igator"
  homepage.html         	
  	
  	
  	
  data-­‐win-­‐options="{home:	
  '/
    homepage.css        pages/homepage/homepage'}">
     homepage.js        </div>




     A “wrapper” around different pages.
default.js: Lifecycle events
   activated   When the app is launched.

               After DOMContentLoaded (HTML parsed, resources
    loaded
               not loaded)


    ready      When the app ready for use


               When the user switches away from your app. Good
  checkpoint
               time to save state.


    unload     When app is about to be unloaded
Navigation
   default.html                      default.html




 masterView.html                   detailView.html




   Single page navigation model provided by
 navigator.js through WinJS.Navigation.navigate(...)
Navigation
   default.html




 masterView.html                detailView.html




  This is what happens if you use <a   href=”...”>
Navigation                            Where am I?
                                       Who am i?
                               What is the meaning of life?


   default.html




 masterView.html                  detailView.html




  This is what happens if you use <a    href=”...”>
Navigation
  groupedMaster.js


WinJS.Navigation.navigate("/pages/itemDetail/itemDetail.html",	
  {	
  model:	
  
model});

//the	
  passed	
  object	
  can	
  be	
  retrieved	
  in	
  itemDetail.js




             Use WinJS.Navigation.navigate()
                 instead of location.href
WinJS + YUI
Leveraging YUI to build Win 8 apps
It’s all about reusing code

 • Re-use your existing web code-base
   when making Win 8 apps

 • Use existing concepts - don’t re-invent
   the wheel

 • But what about UI/UX?
Y.Sights.GridView
Y.Sights.GridView




Y.Sights.ShotList
Y.Sights.GridView




Y.Sights.Shot




                Y.Sights.ShotList
Y.Masonry
Y.Sights.GridView
Y.Sights.GridView




Y.Sights.ShotList
Y.Sights.GridView




Y.Sights.Shot




            Y.Sights.ShotList
Y.DetailView
demo
Including YUI
• Pull down necessary modules using the
  Dependency Configurator
• Clone YUI and include build/ and src/
• Clone YUI and include build/
Including YUI
• Pull down necessary modules using the
  Configurator
• Clone YUI and include build/ and src/
• Clone YUI and include build/
Including YUI
       default.html
                            	
  	
  	
  	
  
	
  	
  	
  
	
  	
  	
  <!-­‐-­‐	
  WinJS	
  references	
  -­‐-­‐>
	
  	
  	
  <link	
  href="//Microsoft.WinJS.1.0.RC/css/ui-­‐dark.css"	
  rel="stylesheet"	
  />
	
  	
  	
  <script	
  src="//Microsoft.WinJS.1.0.RC/js/base.js"></script>
	
  	
  	
  <script	
  src="//Microsoft.WinJS.1.0.RC/js/ui.js"></script>	
  
	
  	
  	
  <script>
	
  	
  	
  	
  	
  	
  YUI_config	
  =	
  {
	
  	
  	
  	
  	
  	
  	
  	
  	
  ...
	
  	
  	
  	
  	
  	
  };
	
  	
  	
  </script>
	
  	
  	
  <script	
  src="/js/lib/yui3/build/yui/yui-­‐min.js"></script>
Let’s re-visit MVC

     MVC, you say?
     Reminds me of the YUI App Framework.
Let’s re-visit MVC

   Model      Defined by Y.Model/Y.ModelList

   View             Defined by Y.View

 Controller        Defined by {page}.js
Models

• Should be environment agnostic
• Y.Model/Y.ModelList + Y.YQL
• Work on the browser and on WinJS
Views



  Should we use native WinJS UI Views, or
             leverage Y.View?
Native Views
 Easy to get it to look “right”

 It’s the WinJS way (documentation, code samples, etc.)

 Code can’t be re-used outside this environment
 Need to figure out how to organize native code and
 YUI code
 No performance gain for using native views
Y.View
Code once, re-use in different environments

Works well with YUI

Achieving the look and feel of Win 8 is fairly easy

Need to code and determine markup and styles
Native Views vs.
Y.View
• Depends on the app
• Over the long term, Y.View probably
  offers greater benefits

• Try using both and see what you are
  comfortable with
Controllers

• Haven’t experimented with Y.Router in
  this environment yet

• Page navigation done through
  WinJS.Navigation.navigate(...)

• Navigation history maintained by
  navigator.js
UI/UX

 Won’t user experience suffer if we
 don’t use native APIs?
UI/UX
• Everything is HTML, CSS, and JS, whether it’s
  native or not.
• CSS3 transitions are supported
• Easy to leverage ui-*.css styles to get the
  right look and feel
• Remember, Win 8 UI !== Web UI
Debugging WinJS
apps
• Breakpoints and JavaScript console for
  standard debugging

• Windows Simulator
• View the DOM while the app is running
  with the DOM Explorer
Thanks!
Questions or comments? Fire away.

@tilomitra
http://github.com/tilomitra/Sights

More Related Content

What's hot

Dynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and MobileDynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and Mobile
peychevi
 
Doctype html public
Doctype html publicDoctype html public
Doctype html public
Eddy_TKJ
 
What’s new in WinJS? Windows Phone 8.1 and the road ahead
What’s new in WinJS? Windows Phone 8.1 and the road aheadWhat’s new in WinJS? Windows Phone 8.1 and the road ahead
What’s new in WinJS? Windows Phone 8.1 and the road ahead
Nguyên Phạm
 
jQuery Mobile
jQuery MobilejQuery Mobile
jQuery Mobile
mowd8574
 

What's hot (20)

An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can build
 
JClouds at San Francisco Java User Group
JClouds at San Francisco Java User GroupJClouds at San Francisco Java User Group
JClouds at San Francisco Java User Group
 
Vue.js
Vue.jsVue.js
Vue.js
 
Contextual jQuery
Contextual jQueryContextual jQuery
Contextual jQuery
 
jQuery Comes to XPages
jQuery Comes to XPagesjQuery Comes to XPages
jQuery Comes to XPages
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
Vue JS Intro
Vue JS IntroVue JS Intro
Vue JS Intro
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsVue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.js
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Dynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and MobileDynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and Mobile
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web components
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.js
 
Doctype html public
Doctype html publicDoctype html public
Doctype html public
 
Meet VueJs
Meet VueJsMeet VueJs
Meet VueJs
 
Vue.js Getting Started
Vue.js Getting StartedVue.js Getting Started
Vue.js Getting Started
 
What’s new in WinJS? Windows Phone 8.1 and the road ahead
What’s new in WinJS? Windows Phone 8.1 and the road aheadWhat’s new in WinJS? Windows Phone 8.1 and the road ahead
What’s new in WinJS? Windows Phone 8.1 and the road ahead
 
SEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer ExperienceSEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer Experience
 
Room with a Vue - Introduction to Vue.js
Room with a Vue - Introduction to Vue.jsRoom with a Vue - Introduction to Vue.js
Room with a Vue - Introduction to Vue.js
 
jQuery Mobile
jQuery MobilejQuery Mobile
jQuery Mobile
 

Viewers also liked (7)

YUI3 - IIT Madras HackU
YUI3 - IIT Madras HackU YUI3 - IIT Madras HackU
YUI3 - IIT Madras HackU
 
Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010Understanding progressive enhancement - yuiconf2010
Understanding progressive enhancement - yuiconf2010
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践
 
Preview of YUI3 Treeview
Preview of YUI3 TreeviewPreview of YUI3 Treeview
Preview of YUI3 Treeview
 
Attribute
AttributeAttribute
Attribute
 
Getting started with YUI3 and AlloyUI
Getting started with YUI3 and AlloyUIGetting started with YUI3 and AlloyUI
Getting started with YUI3 and AlloyUI
 
Creating Hybrid mobile apps with YUI
Creating Hybrid mobile apps with YUICreating Hybrid mobile apps with YUI
Creating Hybrid mobile apps with YUI
 

Similar to Building native Win8 apps with YUI

jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
Mark Roden
 
Use html5 to build what you want, where you want it
Use html5 to build what you want, where you want itUse html5 to build what you want, where you want it
Use html5 to build what you want, where you want it
Kevin DeRudder
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
aswapnal
 
openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010
Patrick Lauke
 
Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
Mihail Mateev
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
NAVER D2
 

Similar to Building native Win8 apps with YUI (20)

Going Offline with JS
Going Offline with JSGoing Offline with JS
Going Offline with JS
 
Going offline with JS (DDD Sydney)
Going offline with JS (DDD Sydney)Going offline with JS (DDD Sydney)
Going offline with JS (DDD Sydney)
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. Toolbox
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
Use html5 to build what you want, where you want it
Use html5 to build what you want, where you want itUse html5 to build what you want, where you want it
Use html5 to build what you want, where you want it
 
Developing JavaScript Widgets
Developing JavaScript WidgetsDeveloping JavaScript Widgets
Developing JavaScript Widgets
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Windows 8 for Web Developers
Windows 8 for Web DevelopersWindows 8 for Web Developers
Windows 8 for Web Developers
 
jQuery 1.9 and 2.0 - Present and Future
jQuery 1.9 and 2.0 - Present and FuturejQuery 1.9 and 2.0 - Present and Future
jQuery 1.9 and 2.0 - Present and Future
 
Toronto User groups workshop - 2013-03-10 - HTML5 & Windows 8, friends with b...
Toronto User groups workshop - 2013-03-10 - HTML5 & Windows 8, friends with b...Toronto User groups workshop - 2013-03-10 - HTML5 & Windows 8, friends with b...
Toronto User groups workshop - 2013-03-10 - HTML5 & Windows 8, friends with b...
 
openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010openMIC barcamp 11.02.2010
openMIC barcamp 11.02.2010
 
Developing large scale JavaScript applications
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applications
 
Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
 
Windows 8 app template feedback
Windows 8 app template feedbackWindows 8 app template feedback
Windows 8 app template feedback
 
Mobile app with sencha touch
Mobile app with sencha touchMobile app with sencha touch
Mobile app with sencha touch
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
 
Microsoft PT TechRefresh html win8.1
Microsoft PT TechRefresh html win8.1 Microsoft PT TechRefresh html win8.1
Microsoft PT TechRefresh html win8.1
 
Mobile applications in a new way with React Native
Mobile applications in a new way with React NativeMobile applications in a new way with React Native
Mobile applications in a new way with React Native
 
Mobile applications in a new way with React Native (by Eugene Zharkov) - Hack...
Mobile applications in a new way with React Native (by Eugene Zharkov) - Hack...Mobile applications in a new way with React Native (by Eugene Zharkov) - Hack...
Mobile applications in a new way with React Native (by Eugene Zharkov) - Hack...
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 

Building native Win8 apps with YUI

  • 1.
  • 2. Building native Windows 8 apps using YUI 3 @tilomitra // YUI Engineer
  • 3.
  • 5. About this talk • A bit about Windows 8 and IE10
  • 6. About this talk • A bit about Windows 8 and IE10 • WinJS
  • 7. About this talk • A bit about Windows 8 and IE10 • WinJS • WinJS + YUI (with Demo)
  • 8. About this talk • A bit about Windows 8 and IE10 • WinJS • WinJS + YUI (with Demo) • Questions & Discussion
  • 9. Not really focussing on... • In-app purchases • Packaging and submission process • Visual Studio (I’m a VS n00b)
  • 10.
  • 11.
  • 14. YUI 3.7.3 We gave ourselves 10 days (which included weekends) to get the job done…We were able to add support for all these new environments very quickly because of YUI’s architecture. -Eric F.
  • 16. Win8 vs WinRT Can run traditional Windows apps and the Win8 new Metro apps “Windows 8 Lite” designed primarily for tablets such as the Surface. WinRT Can only run Metro apps
  • 17. 4 different JS runtimes • IE10 Desktop • IE10 Start Screen (Metro) • Webview inside a C# app • WinJS
  • 18. IE10 “Metro” • More restrictive than IE10 Desktop • Minimal support for plugins (ActiveX, Flash, Silverlight, etc.)* * Metro IE10 does have Flash support but only sites that are on the Compatibility List can play Flash content.
  • 19. IE10 “Metro” • More restrictive than IE10 Desktop • Minimal support for plugins (ActiveX, Flash, Silverlight, etc.)* * Metro IE10 does have Flash support but only sites that are on the Compatibility List can play Flash content.
  • 20. Webview         <WebView Name="wv" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Source="http://yuilibrary.com"/> • Similar to web-views on iOS or Android • No access to device APIs, limited HTML5 support
  • 21. WinJS
  • 22. WinJS • A restricted IE10 runtime with access to native APIs • Allows developers to create WinRT apps using HTML/CSS/JS • All scripts/styles must be available on device
  • 23. WinJS • A restricted IE10 runtime with access to native APIs • Allows developers to create WinRT apps using HTML/CSS/JS • All scripts/styles must be available on device
  • 26. Overview • Uses IE10 to process HTML/CSS/JS
  • 27. Overview • Uses IE10 to process HTML/CSS/JS • Stylesheets and scripts bundled locally
  • 28. Overview • Uses IE10 to process HTML/CSS/JS • Stylesheets and scripts bundled locally • No JSONP, safe innerHTML
  • 29. Overview • Uses IE10 to process HTML/CSS/JS • Stylesheets and scripts bundled locally • No JSONP, safe innerHTML • Access to Windows and WinJS namespaces
  • 30. Injecting HTML myDiv.innerHTML  =  ‘<script>function  test()  {  alert("Testing,  Testing,   123...");  }</script><span  onclick="test()">Click  Me</span>’ //results  in  <span>Click  me</span> List of all filtered elements
  • 31. A WinJS App WinJS References ui.css default.html base.js ui.js default.js default.css navigator.js
  • 32. A WinJS App WinJS References Basic Shell Native styles ui.css default.html JS Utilities base.js UI Views ui.js default.js default.css Navigation navigator.js App Lifecycle Media Code queries
  • 33. Adding Pages Master View Detail View default.html masterview.html detailview.html WinJS References masterview.css detailview.css Other scripts/styles masterview.js detailview.js
  • 34. Pages adopt MVC Each “page” of the app has has it’s own HTML, CSS, and JS View Defined by page.html and page.css Controller Defined by page.js Defined in default.html and Model available in all pages
  • 35. default.html default.html <div  i contro igator homepage.html        da homepage.css pages/ homepage.js </div> A “wrapper” around different pages.
  • 36. default.html default.html <div  id="contenthost"  data-­‐win-­‐ control="Application.PageControlNav igator" homepage.html        data-­‐win-­‐options="{home:  '/ homepage.css pages/homepage/homepage'}"> homepage.js </div> A “wrapper” around different pages.
  • 37. default.js: Lifecycle events activated When the app is launched. After DOMContentLoaded (HTML parsed, resources loaded not loaded) ready When the app ready for use When the user switches away from your app. Good checkpoint time to save state. unload When app is about to be unloaded
  • 38. Navigation default.html default.html masterView.html detailView.html Single page navigation model provided by navigator.js through WinJS.Navigation.navigate(...)
  • 39. Navigation default.html masterView.html detailView.html This is what happens if you use <a href=”...”>
  • 40. Navigation Where am I? Who am i? What is the meaning of life? default.html masterView.html detailView.html This is what happens if you use <a href=”...”>
  • 41. Navigation groupedMaster.js WinJS.Navigation.navigate("/pages/itemDetail/itemDetail.html",  {  model:   model}); //the  passed  object  can  be  retrieved  in  itemDetail.js Use WinJS.Navigation.navigate() instead of location.href
  • 42. WinJS + YUI Leveraging YUI to build Win 8 apps
  • 43. It’s all about reusing code • Re-use your existing web code-base when making Win 8 apps • Use existing concepts - don’t re-invent the wheel • But what about UI/UX?
  • 44.
  • 45.
  • 48. Y.Sights.GridView Y.Sights.Shot Y.Sights.ShotList
  • 49.
  • 50.
  • 52.
  • 55. Y.Sights.GridView Y.Sights.Shot Y.Sights.ShotList
  • 56.
  • 58. demo
  • 59. Including YUI • Pull down necessary modules using the Dependency Configurator • Clone YUI and include build/ and src/ • Clone YUI and include build/
  • 60. Including YUI • Pull down necessary modules using the Configurator • Clone YUI and include build/ and src/ • Clone YUI and include build/
  • 61. Including YUI default.html                    <!-­‐-­‐  WinJS  references  -­‐-­‐>      <link  href="//Microsoft.WinJS.1.0.RC/css/ui-­‐dark.css"  rel="stylesheet"  />      <script  src="//Microsoft.WinJS.1.0.RC/js/base.js"></script>      <script  src="//Microsoft.WinJS.1.0.RC/js/ui.js"></script>        <script>            YUI_config  =  {                  ...            };      </script>      <script  src="/js/lib/yui3/build/yui/yui-­‐min.js"></script>
  • 62. Let’s re-visit MVC MVC, you say? Reminds me of the YUI App Framework.
  • 63. Let’s re-visit MVC Model Defined by Y.Model/Y.ModelList View Defined by Y.View Controller Defined by {page}.js
  • 64. Models • Should be environment agnostic • Y.Model/Y.ModelList + Y.YQL • Work on the browser and on WinJS
  • 65. Views Should we use native WinJS UI Views, or leverage Y.View?
  • 66.
  • 67.
  • 68. Native Views Easy to get it to look “right” It’s the WinJS way (documentation, code samples, etc.) Code can’t be re-used outside this environment Need to figure out how to organize native code and YUI code No performance gain for using native views
  • 69. Y.View Code once, re-use in different environments Works well with YUI Achieving the look and feel of Win 8 is fairly easy Need to code and determine markup and styles
  • 70. Native Views vs. Y.View • Depends on the app • Over the long term, Y.View probably offers greater benefits • Try using both and see what you are comfortable with
  • 71. Controllers • Haven’t experimented with Y.Router in this environment yet • Page navigation done through WinJS.Navigation.navigate(...) • Navigation history maintained by navigator.js
  • 72. UI/UX Won’t user experience suffer if we don’t use native APIs?
  • 73. UI/UX • Everything is HTML, CSS, and JS, whether it’s native or not. • CSS3 transitions are supported • Easy to leverage ui-*.css styles to get the right look and feel • Remember, Win 8 UI !== Web UI
  • 74. Debugging WinJS apps • Breakpoints and JavaScript console for standard debugging • Windows Simulator • View the DOM while the app is running with the DOM Explorer
  • 75. Thanks! Questions or comments? Fire away. @tilomitra http://github.com/tilomitra/Sights