How to make really nice buttons

Posted over 2 years back at GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS - Home

buttons

Introduction

Creating buttons is something every web designer deals with, usually on a very regular basis. It can be one of those tasks that becomes tedious and repetitive but with a few tricks you can make pleasing looking buttons that also give the visitor useful feedback and navigational consistency. In this article I’ll be talking about buttons with 3 states – normal, hover, and pressed – and I will be using the sprite based method which places all 3 states in the same image file.

Shapes ‘n Shapes

Achieving the right graphical look is important so that you are able to present your design in the manner you desire – be it rational UI or crazy mystery meat navigation. It’s important to have your choices look deliberate and not haphazardly chosen – it will help you when presenting to the client and in the final UI users will interact with.

Photoshop’s shape tool is a quirky thing with a couple important options to understand before you start working. First there is the choice between creating a vector-based “Shape Layer” or a pixel based “Fill pixels” option. In a nutshell the vector option is versatile but clunky and the pixel option is less flexible (especially when you want to modify the shape later) but it acts predictably in the pixel world. I use pixels simply because the vector tool can be a pain.

Of equal importance is the “snap to pixels” option which is accessible from the hidden menu at the end of the shape option bar (see fig. 2, step 1) when you are using the rounded corner shape. This will prevent your shapes from displaying unpredictable antialiasing which becomes very important as you duplicate shapes and specify heights and widths in CSS. Also make certain if you’re created a rounded corner shape to turn anti-aliaising on (fig. 2, step 3).

(fig. 2) photoshop interface things

Now you can create shapes! Choose a radius for your rounded corners and you’re ready to go.

Button Styles

Button styles have been evolving as long as the web has and there are an infinite number of styles you could use but I am going to demonstrate a sensible approach that is universal and not heavy on character. The following are tips on using Photoshop’s Layer Styles to create a button like the ones used in the examples.

  • Inner Shadow — Pick a bright color, choose the Color Dodge blending mode, bring choke to 100% with a size of 0 and an angle of 90%. This gives a great top edge highlight (tip shout out to Andrew Wilkinson of Metalab Design).
  • Inner Glow — Mirror Inner Shadow’s settings and play with the opacity
  • Gradient Overlay — Choose colors not too far apart on the color wheel, the gradient should be subtle
  • Stroke — A 1px stroke works best. The object is to pick a slightly darker version of your darkest gradient color to “hold things together”.

These are your basic settings for the “normal” state. For the hover state alter the gradient overlay and lighten both colors. The “pressed” state requires a few new styles and a couple adjustments to get that indented look.

  • Inner Shadow
    • Color: black
    • Blend mode: multiply
    • Opacity 75%
    • Distance 4px
    • Choke 4%
    • Size: 13px
  • Bevel and Emboss
    • Style: Outer Bevel
    • Depth: 100%
    • Size: 1px
    • Angle: -90°
    • Highlight Mode: Screen
    • Highlight Opacity: 40%
    • Shadow Opacity: 0%

The CSS behind the buttons

The 3 states of the button are contained in one image so you will use the background-position CSS attribute to control which states are shown for normal, hover and active states. This method is known as sprites and there are many great resources on it. The primary benefit is since all 3 states of the image are loaded in the same file there is no additional loading on hover and active states. The CSS for changing the background image would look something like this:

1
2
3
4
5
6
7
8
#bee_button a {
display: block;
text-indent: -5000px;
width: 136px;
height: 41px;
background-image: url(/images/bee_button.png);
background-repeat: no-repeat;
}
1
2
3
#bee_button a {background-position: 0 0;}
#bee_button a:hover {background-position: 0 -41px;}
#bee button a:active {background-position: 0 -82px;}

bees

Conclusion

You can see buttons like these in action on the Widgetfinger home page and inside both Hoptoad and Thunder Thimble. They provide a tactile experience for the user and an extra bit of visual feedback when a button has been clicked.

How to make really nice buttons

Posted over 2 years back at GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS - Home

buttons

Introduction

Creating buttons is something every web designer deals with, usually on a very regular basis. It can be one of those tasks that becomes tedious and repetitive but with a few tricks you can make pleasing looking buttons that also give the visitor useful feedback and navigational consistency. In this article I’ll be talking about buttons with 3 states – normal, hover, and pressed – and I will be using the sprite based method which places all 3 states in the same image file.

Shapes ‘n Shapes

Achieving the right graphical look is important so that you are able to present your design in the manner you desire – be it rational UI or crazy mystery meat navigation. It’s important to have your choices look deliberate and not haphazardly chosen – it will help you when presenting to the client and in the final UI users will interact with.

Photoshop’s shape tool is a quirky thing with a couple important options to understand before you start working. First there is the choice between creating a vector-based “Shape Layer” or a pixel based “Fill pixels” option. In a nutshell the vector option is versatile but clunky and the pixel option is less flexible (especially when you want to modify the shape later) but it acts predictably in the pixel world. I use pixels simply because the vector tool can be a pain.

Of equal importance is the “snap to pixels” option which is accessible from the hidden menu at the end of the shape option bar (see fig. 2, step 1) when you are using the rounded corner shape. This will prevent your shapes from displaying unpredictable antialiasing which becomes very important as you duplicate shapes and specify heights and widths in CSS. Also make certain if you’re created a rounded corner shape to turn anti-aliaising on (fig. 2, step 3).

(fig. 2) photoshop interface things

Now you can create shapes! Choose a radius for your rounded corners and you’re ready to go.

Button Styles

Button styles have been evolving as long as the web has and there are an infinite number of styles you could use but I am going to demonstrate a sensible approach that is universal and not heavy on character. The following are tips on using Photoshop’s Layer Styles to create a button like the ones used in the examples.

  • Inner Shadow — Pick a bright color, choose the Color Dodge blending mode, bring choke to 100% with a size of 0 and an angle of 90%. This gives a great top edge highlight (tip shout out to Andrew Wilkinson of Metalab Design).
  • Inner Glow — Mirror Inner Shadow’s settings and play with the opacity
  • Gradient Overlay — Choose colors not too far apart on the color wheel, the gradient should be subtle
  • Stroke — A 1px stroke works best. The object is to pick a slightly darker version of your darkest gradient color to “hold things together”.

These are your basic settings for the “normal” state. For the hover state alter the gradient overlay and lighten both colors. The “pressed” state requires a few new styles and a couple adjustments to get that indented look.

  • Inner Shadow
    • Color: black
    • Blend mode: multiply
    • Opacity 75%
    • Distance 4px
    • Choke 4%
    • Size: 13px
  • Bevel and Emboss
    • Style: Outer Bevel
    • Depth: 100%
    • Size: 1px
    • Angle: -90°
    • Highlight Mode: Screen
    • Highlight Opacity: 40%
    • Shadow Opacity: 0%

The CSS behind the buttons

The 3 states of the button are contained in one image so you will use the background-position CSS attribute to control which states are shown for normal, hover and active states. This method is known as sprites and there are many great resources on it. The primary benefit is since all 3 states of the image are loaded in the same file there is no additional loading on hover and active states. The CSS for changing the background image would look something like this:

#bee_button a {
display: block;
text-indent: -5000px;
width: 136px;
height: 41px;
background-image: url(/images/bee_button.png);
background-repeat: no-repeat;
}
#bee_button a {background-position: 0 0;}
#bee_button a:hover {background-position: 0 -41px;}
#bee button a:active {background-position: 0 -82px;}

bees

Conclusion

You can see buttons like these in action on the Widgetfinger home page and inside both Hoptoad and Thunder Thimble. They provide a tactile experience for the user and an extra bit of visual feedback when a button has been clicked.

How are rubies cut?

Posted over 2 years back at ones zeros majors and minors

Master Rubyist Charles Nutter recently posted an entry titled The Rubyists are wrong. Wrong about the way rubies featured in our Ruby logos are cut.

My father has worked in the jewelry business for over 30 years. As soon as I read Charles’ article, I wondered what Pop would think. So, I emailed him.

Here is his response:

[Charles] is close, but he missed it. The diamond part is correct. But in my
experience and having worked with diamonds and color all over the world
there is one common thread in the cutting of any color stone. Diamonds are
cut for brilliance and yield. Any color stone is cut into a shape which will
bring out the color to its upmost beauty and at the same time maximize the
yield of the rough. That is why you see more cushion shapes and ovals in
rubies. But you usually only see those in larger stones. The majority of
the small stones are round. So, I would have to say the round cut is cut the
most. Also, the round cut is different from the diamond brilliant cut.
Faceting is done to bring out the color in the color stones. So, there
really isn’t a facet count on round color like a diamond would have.
Also, all of the Ruby logos are correct. If that was the best way to cut the
rough to maximize the color than it’s possible a cutter would use any of the
shapes, including the JRuby logo. Yes, a lot of color stones are cut off
center or in a nonsymmetrical shape.

Thanks Dad.

Erb Eval

Posted over 2 years back at ones zeros majors and minors

Because I always forget how to do it:

require 'erb'

name = 'bob'
template = 'whatever, <%= name %>'
puts ERB.new(template).result(binding)

Useful for sticking Ruby into config files:

config = YAML.load(ERB.new(IO.read(config_file)).result)

Brutalism

Posted over 2 years back at ones zeros majors and minors



Cocoa Proggin' in Nu

Posted over 2 years back at ones zeros majors and minors

Tim Burks continues to make it easy to dip your toe into Nu via his brilliant guerilla tactics. Case in point: the new Cocoa Programming with Nu repository on GitHub.

For this project, Tim (and the Nu community) has taken Objective-C examples from Aaron Hillegass’ Cocoa Programming for Mac OS X and translated them into Nu.

What’s Nu? It’s an object oriented LISP implemented in Objective-C. As such, simply integrates into your Cocoa apps. Check some of the code to see Nu in action.

I’ve already purchased Hillegass’ book and will be trying out both the Obj-C and Nu examples when I have time. Can’t wait.

The Bang

Posted over 2 years back at ones zeros majors and minors

I was checking out Ryan Lowe’s save_or_raise project today and stumbled upon this quote:

Ruby methods that end with an exclamation point are a signal that they change the object they operate on.

This is not true. A common misconception.

The Ruby stdlib uses bang methods to identify a more dangerous version of a non-bang method. For example, Hash#merge! is the ‘dangerous’ version of Hash#merge – the former affects the receiver while the latter does not.

Hash#update, the bangless alias for Hash#merge!, illustrates the other side of this idiom. No counterpart, no bang.

Two programmers walk into a bar...

Posted over 2 years back at ones zeros majors and minors

One of them says, “My framework couldn’t do what I wanted, so I extended it.”

The other says, “My framework couldn’t do what I wanted, so I implemented the feature in app code.”

Get it?

Love Bank of America

Posted over 2 years back at ones zeros majors and minors

Here’s the story:

I opened a new Bank of America account and, naturally, ordered checks. They never arrived. I went into the bank and asked them for more, and if they could cancel the MIA block. Nope. They can only cancel checks for a certain amount of time, not indefinitely. I needed to open a new bank account.

Okay, that’s fine. But my rent is almost due. If I open the new account today, can I immediately cut a check? “Yes!” Okay, great. As long as my check doesn’t bounce. I love my landlord and would hate to pull a stunt like that.

New account opened, new temporary checks received, and hey, I even get to keep my old check card. Score. I drop off my rent check on time and all is well.

Two days later, I decide to deposit a check I just received. The nice teller asks, “Which account would you like this deposited in?” Well, I only have one account. “Actually, you have three.” What? Okay, put it in the one with all the money in it. I’ll talk to a personal banker and make sure the others are being closed.

Except, nothing is being closed. And no money was transferred. The account with all the money in it is my OLD account. The new account is empty. And no, there’s no transaction pending – the money WAS transferred, then was transferred back. What the hell? (Thanks for the email or phone call letting me know.) The personal banker has no idea why.

I go home and transfer the money online. It’s supposedly instant. Let’s hope the rent doesn’t bounce.

(As far as distributing money goes, I do in fact have a second checking account, but I just emptied that sucker paying taxes. Emptied, of course, because I never had checks for the new Bank of America account.)

So yeah, Bank of America sucks. I think I may be moving back to Wamu or using Patelco, Charles Schwab, or eTrade – all of these were recommended
today. I moved away from Wamu because there is no branch near my apartment, but I think not hating my bank outweighs proximity.

Should?

Posted over 2 years back at ones zeros majors and minors

test "should ping a user" do
  ping user
end

test "pings a user" do
  ping user
end

Tell, don’t ask.

Profiling jQuery Apps

Posted over 2 years back at ones zeros majors and minors

Again, John Resig is the man. Even cooler that his example uses GitHub. Sorry about my crappy JS – now I have no excuse not to optimize it.

Here’s the GitHub example. Run jQuery.displayProfile() in Firebug to see it in action.

The Power of the Toe-Dip

Posted over 2 years back at ones zeros majors and minors

jQuery has jQuery.noConflict(). Just slip jQuery into your existing project and try it out – dip your toe in. There’s no obligation. You can always remove it and go back to Prototype.

Git has git-svn. Just start using Git with your existing SVN repository and try it out – dip your toe in. There’s no obligation. You can always go back to raw SVN.

While not the only cool feature these projects possess, the toe-dip factor is undeniably huge. I started with both jQuery.noConflict() and git-svn. I bet most converts did, too.

Mac Software I Bought

Posted over 2 years back at ones zeros majors and minors

I really wish I could pay for Skitch.

He's such a great blogger

Posted over 2 years back at ones zeros majors and minors

We must be careful to not confuse the prolific with the profound.

Queerer Than We Can Suppose

Posted over 2 years back at ones zeros majors and minors

By far my favorite TED talk. Worth watching every few months to remind us how unique this experience we all share really is.

<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/1APOxsp1VFw&amp;hl=en"></param><embed src="http://www.youtube.com/v/1APOxsp1VFw&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>