GirlieMac!

Archive for the ‘Dev’

CSS3 Box-Shadow with Inset Values – The Aqua Button ReReVisited!

February 04, 2010 By: admin Category: CSS, Dev, Firefox, Opera, Sandbox, WebKit 10 Comments →

Screenshot ot CSS Aqua buttons

This is my third article on CSS3 No Image Aqua Buttons. The previous articles include:

  1. CSS3 Gradients: No Image Aqua Button
  2. CSS3 Aqua Button – Revisited for Firefox 3.6
  3. And this one – Read on!

Since Smashing Magazine has selected the original Aqua button demo for their article, “50 Brilliant CSS3/JavaScript Coding Techniques”, I have had so much more visitors to my blog.

This resulted quality developers leave useful comments and tips for me – thank you, Zoley for suggesting using box-shadow with the inset value, and a big thank you to Jim for actually re-writing the Aqua button with the technique!!!

So, now the CSS3 Aqua button is revised with semantic markup (no more “glare” div! Yes, I complained it by myself before!) and shorter CSS.
And this time, no CSS gradients! – use CSS box-shadow property with multiple inset values to draw layers of inner-shadows to create the visual effect.

Syntax

(-moz-)box-shadow: none | <shadow> [,<shadow>]* where <shadow> is defined as: inset? && [ <offset-x> <offset-y> <blur-radius>? <spread-radius>? && <color>? ]

Values

from Mozilla Developer Center:

inset (optional)
If not specified (default), the shadow is assumed to be a drop shadow (as if the box were raised above the content).
The presence of the inset keyword changes the shadow to one inside the frame (as if the content was depressed inside the box). Inset shadows are drawn above background, but below border and content.

<color> (optional)
If not specified, the color depends on the browser. In Gecko (Firefox), the value of the color property is used. Safari’s shadow is transparent and therefore useless if <color> is omitted.

<offset-x> <offset-y> (required)
This are two <length> values to set the shadow offset. <offset-x> specifies the horizontal distance. Negative values place the shadow to the left of the element. <offset-y> specifies the vertical distance. Negative values place the shadow above the element.
If both values are 0, the shadow is placed behind the element (and may generate a blur effect if <blur-radius> and/or <spread-radius> is set).

<blur-radius> (optional)
This is a third <length> value. The higher this value, the bigger the blur, so the shadow becomes bigger and lighter. If not specified, it will be 0.

<spread-radius> (optional)
This is a fourth <length> value. Positive values will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink. If not specified, it will be 0 (the shadow will be the same size as the element).

Note – The box-shadow property has been removed from W3C CSS3 Background Candidate recommendation document.

The Entire Code!

Use -moz and -webkit prefix for box-shodow to support these browsers. For Opera, there’s no need to add -o.

Also, notice there are three inset values are defined for detailed visual effects!


<input type="button" class="new-aqua" value="Login"/>


input[type=button].new-aqua {
  width: 155px;
  height: 35px;
  background: #cde;
  border: 2px solid #ccc;
  border-color: #8ba2c1 #5890bf #4f93ca #768fa5;
  font: 600 16px/1 Lucida Sans, Verdana, sans-serif;
  color: #fff;
  text-shadow: rgba(10, 10, 10, 0.5) 1px 2px 2px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  border-radius: 16px; -moz-border-radius: 16px; -webkit-border-radius: 16px;
  box-shadow: 0 10px 16px rgba(66, 140, 240, 0.5), inset 0 -8px 12px 0 #6bf, inset 0 -8px 0 8px #48c, inset 0 -35px 15px -10px #7ad;
  -moz-box-shadow: 0 10px 16px rgba(66, 140, 240, 0.5), inset 0 -8px 12px 0 #6bf, inset 0 -8px 0 8px #48c, inset 0 -35px 15px -10px #7ad;
  -webkit-box-shadow: 0 10px 16px rgba(66, 140, 240, 0.5), inset 0 -8px 12px 0 #6bf, inset 0 -8px 0 8px #48c, inset 0 -35px 15px -10px #7ad;
}
.new-aqua:hover {
  text-shadow: rgb(255, 255, 255) 0px 0px 5px;
}


View the live demo page! This new aqua button works on FF 3.6, Webkit 4 (the current Safari 4 doesn’t support inset box-shadow yet), Chrome 4 and Opera 10. (But fails on 10.1 on Mac).

* Edited on Feb.5 – Opera 10.1 fail and Safari4 (I noticed this works only on Webkit Nightly after published this!)

And again, a huge thanks to Jim Green for the revised CSS!

References

CSS3 Aqua Button – Revisited for Firefox 3.6

January 28, 2010 By: admin Category: CSS, Dev, Firefox, Sandbox 13 Comments →

This is an update for the Aqua button tutorial. This update will add a support for Firefox 3.6. If you haven’t seen the article, please go read it before proceeding here.


Screenshot ot CSS Aqua buttons

On the end of November last year, Mozilla Hacks announced the support for CSS gradient in a background on upcoming Firefox 3.6 (which final version has just released recently).

As already been supported on WebKit, FF does support both linear and radial gradient, however, Mozilla has implemented differently –
Most noticeably, Mozilla separate linear and radial gradient as -moz-linear-gradient and -moz-radial-gradient, while on WebKit, the syntax goes -webkit-gradient and you specify linear or radial.

Also the specification of each value is different too.
If you want a linear gradient starting from red on top to ending at bottom in white, you need to define –

WebKit:
background: -webkit-gradient(linear, left top, right bottom, from(red), to(white)))
Firefox:
background: -moz-linear-gradient(top, red, white);

The Aqua Button Redefined

Let’s re-create the aqua button, by adding -moz prefixed gradient definitions:

The button:


.aqua{
  background-color: rgba(60, 132, 198, 0.8);
  border-top-color: #8ba2c1;
  border-right-color: #5890bf;
  border-bottom-color: #4f93ca;
  border-left-color: #768fa5;
  -webkit-box-shadow: rgba(66, 140, 240, 0.5) 0px 10px 16px;
  -moz-box-shadow: rgba(66, 140, 240, 0.5) 0px 10px 16px;
  background-image: -webkit-gradient(linear, 0% 0%, 0% 90%, from(rgba(28, 91, 155, 0.8)), to(rgba(108, 191, 255, .9)));
/* for FF 3.6 */
  background-image: -moz-linear-gradient(rgba(28, 91, 155, 0.8) 0%, rgba(108, 191, 255, .9) 90%);
}

and the glare:


.button .glare {
  position: absolute;
  top: 0;
  left: 5px;
  -webkit-border-radius: 8px;
  -moz-border-radius: 8px;
  height: 1px;
  width: 142px;
  padding: 8px 0;
  background-color: rgba(255, 255, 255, 0.25);
  background-image: -webkit-gradient(linear, 0% 0%, 0% 95%, from(rgba(255, 255, 255, 0.7)), to(rgba(255, 255, 255, 0)));
  /* for FF 3.6 */
  background-image: -moz-linear-gradient(rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 95%);
}

This is the actual html page. Open it on Firefox 3.6 and see!

More Info on Mozilla CSS Gradients

I Can Has iPhone App on App Store

December 29, 2009 By: admin Category: App, GirlieMac! News, iPhone, iPod No Comments →

Finally, I have my app, called iCanHasLOL published on App Store!
Actually the app was reviewed within 24 hours by Apple, although I’ve heard it would usually take 2 weeks.

I mentioned that I had been writing an iPhone app using Appcelerator before, and an app was almost ready to go. However, I was not able to publish it with the particular contents so I re-wrote the app and re-created some graphics to finish up this brand-new app.

This is free of charge also ad-free (for now, at least!) so get your copy now!

iPhone Cocoa App development with JavaScript

December 05, 2009 By: admin Category: App, Dev, Event, SDK, iPhone 1 Comment →

Hello, I have neglected my blog since September although there have been some blog-worthy events like N900 meetup (plus Droid experience and new Fennec demo. See the videos by Tnkgrl from the link!), California Data Camp, release of Net2Streams Pro (the streaming radio app for Palm WebOS I helped writing) etc… Well, I keep microblogging on Twitter almost daily basis so follow me if you’d like!

One of the interesting I have been independently doing is that writing an app for iPhone with JavaScript, and this time, not an web app but a “native” Cocoa app. Yes I said a native iPhone app in JavaScript! But how? -I used this excellent open-source platform, called Titanium by Appcelerator! Without bothering Obj.C or Java, Titanium allows developers to write iPhone and Android apps with the familiar web technology.

So, as a test run, I have created the iCuteoverload app for iPhone again. (Originally, I made the web app for iPhone, using iUI in 2007)
I will not release this app on AppStore -not because of the technical issue but the agreement with the business decision. (Yes, this app contents are not mine and copyrighted!) But I should be able to show the video capture as a demo to tell you what Titanium can do for web devs like me!

Classification of Mobile Browsers

September 22, 2009 By: admin Category: Dev, Firefox, Google, Nokia, Opera, Palm, WAP, WebKit, WinMo, iPhone 1 Comment →

Today, I am not going to post some CSS3 tricks on Webkit, or stuff like that. Instead, I post a list mobile browsers, since I am often asked about mobile / WAP browsers by engineers, product managers, and mobile-curious or mobile-newbie people.

I gathered 30+ major browsers I have worked with (plus a few I have never even seen), and categorize by the markup that browsers can render – WML, CHTML, XHTML-MP, and HTML4.

So, here you go. If you find some mistakes, let me know!

WML Browsers (WAP 1.x)
Openwave earliy browsers 4.x  
Early Nokia browser  
Early Obigo browser  
CHTML Browsers (Common in Japan)
CHTML browsers Compact-HTML browsers
Compact NetFront
i-mode browsers (CHTML / XHTML) NTT Docomo
XHTML Browsers (WAP 2.x – XHTML-MP / WML)
WebKit Nokia S40
Nokia S60 – earlier versions, or “Services” browser
NetFront by Access Palm Blazer 3.x -
Sony Ericsson WAP browser
Blazer by Handspring original browsers before accured by Palm
Openwave 6.x Siemens
Sharp
Sanyo
Motorola
Toshiba
Blackberry by RIM Blackberry browser- earlier version ~4.3? (*)
Obigo by Teleca
Polaris by InfraWare
Helio
Motorola MIB
HTML Browsers
WebKit Nokia S60 3rd gen., “Web” Mini-map browser
Apple Mobile Safari
Google Android
Palm WebOS
Iris, by Torch Mobile (now RIM)
Bitstream Bolt (Proxy)
MOTOMAGX (Motorola Linux devices)
Gecko Mozilla Minimo (dead?)
Mozilla Fennec
Maemo (aka MicroB)
Skyfire
Opera (proxy) Opera Mobile
Opera Mini
Nintendo DSi
Nintendo Wii
Blackberry by RIM Blackberry browser ver.4.6+ (I am not sure about 4.4 and 4.5)
Microsoft Internet Explorer (was Microsoft Pocket IE) (earlier versions do not support CSS?)
NetFront 3.x ? Sony Ericsson browsers
Sony PlayStation / PSP browsers
Palm Blazer 4.x
Amazon Kindle
Teleca Teleca Browser V3.x ? (LG Voyager)
Danger (now by Microsoft) Sidekick

I have categorized only with the markup type, and did not sub-categorize these browsers. However, if I would, I may want to grade XHTML-MP devices with page memory size (=”deck size”, yes I said deck size), and screen resolution for UI design purpose.

To grade full-HTML browsers, you need to spend massive time and effort on testing rendering capability with CSS, and Javascript DOM compatibility, events, etc. Actually, PPK has done excellent work on mobile browser testing, so you can simply visit Quirksmode.org!

Webkit CSS 3D + Local DB Demo

September 03, 2009 By: admin Category: CSS, Dev, Sandbox, WebKit, iPhone 8 Comments →

css 3D screenshot

Ever since I heard of Snow Loepard’s hardware-accelerated CSS, I wanted try some cool CSS animation for Safari 4.

So after installing Snow Leopard, I spent about a day and half to try creating my first 3D animation with Flickr API.
Honestly, I wasn’t sure where to get started to make some cool 3D effect, so what I did was I tried to reproduce the one on webkit.org example and modify a lot by trial and error approach.
Also, I have been freqently asked about how I did with “My Favorites” feature on my Palm Pre app (which is also a WebKit-based), so I throw the HTML5’s local storage demo with this 3D demo.

So here, you can try my CSS 3D and Local DB Demo!!!
Be sure to view this demo on Safari 4, iPhone Safari, or WebKit Nightly! This doesn;t seem to work on other Webkit-based browsers such as Chrome and Palm.

I am not going to write a whole tutorial how to replicate this animation but I try to explain some examples.

Spin a Wheel!

Look at one of the flicke photo wheel on my demo. This is a combination of a few different animation.
Let’s focus on the small wheel inside. This is the snippet of HTML of the wheel:



<div id="gallery">
  <div id="pic01"><img src="..."/></div>
  <div id="pic02"><img src="..."/></div>
  ... (10 more imgs)
</div>	


3D Cood
OK, for now, let’s ignore how each photo is rendered to form a loop, and just focus on the animation of one div, #gallery (= a wheel). A band of photos is ratating clockwise around Y-axis.
This means the animation starts as -webkit-transform: rotateY(0); and goes around an circle for a whole 360 degree. -webkit-transform: rotateY(-360deg);.
Use positive if you want to rotate in opposite direction.
I set the whole circle completion span as 60 seconds in linier motion and the animation goes infinite.

This diagram from Apple’s Safari Reference Library explains coordinates.

So the css for this movement is defined as:


#gallery {
  -webkit-transform-style: preserve-3d;
  -webkit-animation: spinY 60s linear infinite;
}


@-webkit-keyframes spinY {
  from { -webkit-transform: rotateY(0);}
  to   { -webkit-transform: rotateY(-360deg);}
}

Use 3D style, -webkit-transform-style: preserve-3d;to give 3D illusion. I set the initial perspective in its parent div as -webkit-perspective: 380;.
It gives you an illusion of the depth. You can make the value lower to make it look more up-close to you.
The unit of perspective should be “px”, but it looks like you’d better remove it for iPhone.

perspective 200 perspective 400
perspective 500 perspective 0

To figure out how to render each photo in loop, also other animations, please look at the source code of my demo.

Also, I will write about how to use HTML 5’s local storage sometimes later!

References

PREtty Cute Suite -Another Cute app for Pre from me!

August 29, 2009 By: admin Category: App, GirlieMac! News, Palm, WebKit 3 Comments →

Can’t have enough cute!
Instead of upgrading my previous app, iCuteOverload for Palm, I have created this power-up version of cute app called, PREtty Cute Suite.

This app is more offensively and obnoxiously cute with more cute-related rss feed and flickr pics.
Included feeds are:

  1. Cute Overload
  2. I Can Has Cheezburger
  3. Cute Obssesion
  4. Epicute
  5. Super Cute Kawaii
  6. Cupcakes Take Tha Cake

Also, a bunch of cute picture streams from Flickr.


This app allows you to save the pix/feeds you like as your favorites, also share the links via email.

Currently available as a “Homebew” app on PreCentral.net for free.
I have no plan to submit this to the Palm official app store in this moment, at least for this version 0.9.

My First WebOS App – iCuteOverload for Palm v1.0

August 11, 2009 By: admin Category: App, Dev, Girlie Stuff, GirlieMac! News, Palm, SDK, WebKit 6 Comments →

As a front-end web developer, also a mobile-web developer, the Palm’s new WebOS SDK for Pre sounds very attractive, and I could not wait to create some applications although I am still a iPhone user and haven’t been convinced to switch a service provider.

Then I felt like, I already got this web app, iCuteoverload for iPhone but yeah why not for Pre? So I decide to re-create the same app from scratch. Sure, the existing app is a web app that wrote with JavaScript framework iUI and PHP, does run fine on Pre’s web browser since Pre is based on Webkit browser. However, I wanted to make this app a standalone client with Mojo framework so I needed to code from scratch.

Anyway, here it is, iCO for Palm is now available at PreCentral. The official store is not yet open, so the installing the app may require a bit of geeky skills, but if you happen to be a Pre user and would like to try, follow this tutorial on how to install homebrew apps on Pre for Mac users (And this is for Windows users instruction).

By the way, I keep this app name begins with i, because I already have named so for iPhone and wanted to keep it for consistency. However, in Pre community, this seems to be a pretty bad thing to do. People see me as a clueless Apple fan :-(

iPhone App – MuniApp for San Francisco Muni riders!

August 08, 2009 By: admin Category: App, GirlieMac! News, UI/UX, iPhone, iPod 3 Comments →

Ta-da, finally there’s an app for that! – I mean an iPhone native app that I involved is available on App Store!

This app is called, MuniApp, and this gives you access to San Francisco’s MUNI transit system on the go with real time predictions for buses, metro and cable cars.

I have worked on some UI and icons, while my friend Alberto has coded all the Obj.C. We are both SF residents and rely on MUNI pretty frequently and we do use this app on daily basis. Honestly, this is really simple and useful app :-)

The official website for MuniApp is at www.obapp.com/muniapp

To directly go to App Store on iTunes, go to this link!

Finally, the official Mojo SDK for all!

July 16, 2009 By: admin Category: Dev, Palm, SDK, WebKit 1 Comment →

After I was rejected for the early access then struggled with the “leaked” version of Palm Mojo SDK without a documentation, today Palm finally made the official SDK available for all!!!

I haven’t playing around with it long enough to blog much about it, so I just post my “cheat sheet” that I keep on Stickies.

Emulator Key for Mac

  • Esc – acts as “Back”
  • Left / Right arrows – Switch between applications

Emulator Navigation

“Host” = Right Ctrl in Virtual Box

  • Host + F – Toggle full screen view on/off
  • Host + N – Display session info
  • Host + S – Take a snapshot (will be placed the Snapshot tab of VirtualBox)
  • Host + Q – Close the emulator

Commands

Create a package (.ipk file)

$ cd palm-package myapp

Install the .ipk file on emulator

$ palm-install com.yourdomain.app.myapp_1.0.0_all.ipk

Launch the app on emulator

$ palm-launch com.yourdomain.app.myapp

Launch the inspector with the app

$ palm-launch -i com.yourdomain.app.myapp

Then, open Palm Inspector app (comes with SDK) from your Application by double-clicking the icon. This should open the Safari inspector.