yui introduction to build hack interfaces

51
The Yahoo User Interface Library (YUI) Christian Heilmann | http://wait-till-i.com | http://scriptingenabled.org Delhi, India, University Hack Day, January 2009

Upload: christian-heilmann

Post on 06-May-2015

2.853 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: YUI introduction to build hack interfaces

The Yahoo User Interface Library

(YUI)

Christian Heilmann | http://wait-till-i.com | http://scriptingenabled.org

Delhi, India, University Hack Day, January 2009

Page 2: YUI introduction to build hack interfaces

Let’s take a walk...

...on the client side

Page 3: YUI introduction to build hack interfaces

The client side is where strange things happen.

Page 4: YUI introduction to build hack interfaces

Browsers render in fascinating and totally wrong

ways.

Page 5: YUI introduction to build hack interfaces

Random code from dubious sources interferes with your

godlike, clean and high quality code.

Page 6: YUI introduction to build hack interfaces

...and you fix more than you develop.

Page 7: YUI introduction to build hack interfaces

The web is a total mess!

Page 8: YUI introduction to build hack interfaces

The reason is that things seemingly work.

Page 9: YUI introduction to build hack interfaces

However, you are not the web and neither is your

computer.

Page 10: YUI introduction to build hack interfaces

To make things work for Yahoo we needed to find a

way to abstract these issues away from us.

Page 11: YUI introduction to build hack interfaces

And this is why we built the YUI.

Page 12: YUI introduction to build hack interfaces

YUI is a framework to build working web applications.

Page 13: YUI introduction to build hack interfaces

It includes CSS solutions to create layouts that work

across browsers and allow for predictable typography.

Page 14: YUI introduction to build hack interfaces

And it takes the pain out of writing JavaScript.

Page 15: YUI introduction to build hack interfaces

Last but very much not least it allows you to create

applications using tested and working widgets that extend

what HTML gives us.

Page 16: YUI introduction to build hack interfaces

AutoComplete

Button

Calendar

Charts

Container

DataTable

Layout

Menu

Rich Text

TabView

Interface W

idg

ets

Page 17: YUI introduction to build hack interfaces
Page 18: YUI introduction to build hack interfaces

Everything is fully documented.

Page 20: YUI introduction to build hack interfaces

And there are almost 300 examples to look at.

Page 22: YUI introduction to build hack interfaces

The controls are driven by custom events to allow for extending and monitoring

them.

Page 23: YUI introduction to build hack interfaces
Page 24: YUI introduction to build hack interfaces

Say for example you want to make sure to securely chain

animation sequences...

Page 25: YUI introduction to build hack interfaces

//This is the first animation; this one will //fire when the button is clicked. var move = new YAHOO.util.Anim("animator", { left: {from:0, to:75} }, 1); //This is the second animation; it will fire //when the first animation is complete. var changeColor = new YAHOO.util.ColorAnim( "animator", { backgroundColor: {from:"#003366", to:"#ff0000"} }, 1); //Here's the chaining glue: We subscribe to the //first animation's onComplete event, and in //our handler we animate the second animation: move.onComplete.subscribe(function() { changeColor.animate(); });

Page 26: YUI introduction to build hack interfaces

//Here we set up our YUI Button and subcribe to //its click event. When clicked, it will //animate the first animation: var start = new YAHOO.widget.Button("startAnim"); start.subscribe("click", function() { //reset the color value to the start so that //the animation can be run multiple times: YAHOO.util.Dom.setStyle("animator", "backgroundColor", "#003366"); move.animate(); });

Page 27: YUI introduction to build hack interfaces

//You can also make use of the onStart and onTween //custom events in Animation; here, we'll log all //of changeColor's custom events and peek at their //argument signatures: changeColor.onStart.subscribe(function() { YAHOO.log("changeColor animation is starting.", "info", "example"); }); changeColor.onTween.subscribe(function(s, o) { YAHOO.log("changeColor onTween firing with these arguments: " + YAHOO.lang.dump(o), "info", "example"); }); changeColor.onComplete.subscribe(function(s, o) { YAHOO.log("changeColor onComplete firing with these arguments: " + YAHOO.lang.dump(o), "info", "example"); });

Page 28: YUI introduction to build hack interfaces

All YUI components come as a debug version which log

everything that is going on to the logger.

Page 29: YUI introduction to build hack interfaces

All in all YUI allows you to build web interfaces without having to know all the pain that goes on in the browser

world.

Page 30: YUI introduction to build hack interfaces

Built on agreed standards

Separated into modules each dealing with one task

Constant reporting of what is going on

Own Debugging environment

Page 31: YUI introduction to build hack interfaces

Let’s hack using YUI!

Page 32: YUI introduction to build hack interfaces

Step 1: Get the page structure built for you.

Page 34: YUI introduction to build hack interfaces

Step 2: Get some nice data, for example photos from

Delhi.

Page 36: YUI introduction to build hack interfaces

Step 3: Find a nice way to display it – for example a

Carousel

Page 38: YUI introduction to build hack interfaces

Step 4: Add tabs for more content

Page 40: YUI introduction to build hack interfaces

Step 5: Add a menu for other pages

Page 42: YUI introduction to build hack interfaces

Step 6: Add a Map!

Page 44: YUI introduction to build hack interfaces

And...

FAIL

Page 46: YUI introduction to build hack interfaces

After you fixed that:

Page 48: YUI introduction to build hack interfaces

Of course this is a mashup, not a hack.

Page 49: YUI introduction to build hack interfaces

It is also not creative at all and has been done to death!

Page 50: YUI introduction to build hack interfaces

But it shows you how you can build a working interface

Page 51: YUI introduction to build hack interfaces

Christian Heilmann

http://wait-till-i.com

http://scriptingenabled.org

http://twitter.com/codepo8

THANKS!