<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LRBlog &#187; User Interface Design</title>
	<atom:link href="http://blog.lrdesign.com/category/user-interface-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lrdesign.com</link>
	<description>Logical Reality Design: Web Design and Software Development</description>
	<lastBuildDate>Thu, 08 Jul 2010 01:40:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using redirect_to :back to improve user interfaces</title>
		<link>http://blog.lrdesign.com/2008/06/using-redirect_to-back-to-improve-user-interfaces/</link>
		<comments>http://blog.lrdesign.com/2008/06/using-redirect_to-back-to-improve-user-interfaces/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 19:48:37 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[User Interface Design]]></category>
		<category><![CDATA[redirect :back]]></category>
		<category><![CDATA[Search Results]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://blog.lrdesign.com/?p=21</guid>
		<description><![CDATA[It's a scourge that inflicts nearly every website: the dreaded empty page stating "Your search returned no results." Or even worse, the search results page with a header "Search results" and zero content, the footer immediately following the header. This is not only useless, but also confusing to the user, because it takes the reader [...]]]></description>
			<content:encoded><![CDATA[<p>It's a scourge that inflicts nearly every website: the dreaded empty page stating "Your search returned no results."  Or even worse, the search results page with a header "Search results" and zero content, the footer immediately following the header.  This is not only useless, but also confusing to the user, because it takes the reader several seconds to even realize that the search returned no results.</p>
<p>For example, I just got this one on the otherwise lovely <a title="My Profile at WorkingWithRails.com" href="http://workingwithrails.com/person/13192-evan-dorn">workingwithrails.com</a> when I searched for RoR developers in Pasadena, CA:</p>
<p><a href='http://blog.lrdesign.com/wp-content/uploads/2008/06/empty_search_2.png'><img src="http://blog.lrdesign.com/wp-content/uploads/2008/06/empty_search_2-150x150.png" alt="A search results page with no results!" title="empty_search_2" width="150" height="150" class="alignnone size-thumbnail wp-image-32" /></a></p>
<p>This is lame, lame, lame.  A search results page with no results is <strong><em>guaranteed</em></strong> not to be useful to the user! From a user interface perspective, it's akin to redirecting a user to a login page after they try to access some resource, and then sending them back to the front page or a super-lame "thank you for logging in" page afterwards.    The user should <em>always</em> see a useful page, and should never have to waste clicks getting back to what they wanted.</p>
<p>It's not only bad UI, it's also entirely unnecessary, because in Rails you can fix this for good with two lines of code.</p>
<h2>Avoid wasted pages and annoyed users with redirect_to: back</h2>
<p>If your user's search doesn't find anything, don't make them waste their time at a whole page that tells them only that.  Instead just send them straight back to the search page.  Better yet, redirect them back to wherever they came from, since they might well be able to invoke search from any number of different contexts in your application.  You don't need a whole page to tell them the search didn't find anything - a flash notice is more than sufficient:</p>
<h4>Redirecting back with a flash after an empty search:</h4>
<p><code>def search<br />
  @results = YourModel.execute_some_search(params[:some_parameter]);<br />
  if @results.size == 0<br />
    flash[:notice] = "No items found matching '#{params[:some_parameter]}'"<br />
    redirect_to :back<br />
  end<br />
end<br />
</code></p>
<h2>Testing redirect_to :back</h2>
<p>Testing redirect_to :back isn't completely trivial, because of course there's no previous page when you render a page in a test context.  So, when you try to run a controller that redirects back, you'll see an error.   The easiest thing to do is to artificially set a previous page.   I have these two methods in test/test_helper.rb:</p>
<p><code>def fake_referer<br />
    @request.env['HTTP_REFERER'] = 'http://previous_page'<br />
  end</p>
<p>  def assert_redirected_back<br />
    assert_redirected_to 'http://previous_page'<br />
  end<br />
</code></p>
<p>Then anytime I am working on a controller that involves back redirects, I drop fake_referrer in my setup method and then use assert_redirected_back.  For example, in a search controller test (this is from a controller that has an action called 'contents' for searching items by text content - the search itself uses ferret):</p>
<p><code>def setup<br />
    super<br />
    fake_referer<br />
  end</p>
<p>  def test_contents_search_fails<br />
    get :contents, :contents => "some&#038;junk*that(will@never)match$anything"<br />
    assert_not_nil flash[:notice]<br />
    assert_redirected_back<br />
  end<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lrdesign.com/2008/06/using-redirect_to-back-to-improve-user-interfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox Download Day (= display: inline-block day!)</title>
		<link>http://blog.lrdesign.com/2008/06/firefox-download-day-display-inline-block-day/</link>
		<comments>http://blog.lrdesign.com/2008/06/firefox-download-day-display-inline-block-day/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 07:12:54 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML, CSS, and Web Standards]]></category>
		<category><![CDATA[User Interface Design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[inline-block]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://blog.lrdesign.com/?p=26</guid>
		<description><![CDATA[It's Firefox 3 Download Day!   Go get it, please. I am excited about this, but perhaps not for the same reason most other people were. I am excited because Firefox 3 is the first version to implement the CSS rule "display: inline-block". Inline-block allows you to generate chunks of content of rectangular shape that will flow [...]]]></description>
			<content:encoded><![CDATA[<p>It's <a href="http://www.mozilla.com/en-US/firefox/?from=getfirefox">Firefox 3</a> <a href="http://www.spreadfirefox.com/en-US/worldrecord">Download Day</a>!   Go get it, please.</p>
<p>I am excited about this, but perhaps not for the same reason most other people were. I am excited because Firefox 3 is the first version to implement the CSS rule "display: inline-block".  Inline-block allows you to generate chunks of content of rectangular shape that will flow inline in your content (like text, images, or tables) but whose contents act like a block, and whose borders and margins are respected in the flow.</p>
<p>Let's make it clear what I mean.</p>
<h3>The beauty and versatility of display: inline-block</h3>
<p>Setting a CSS element's display: property to inline-block tells the browser to treat the element as a rectangular block, with internal flow just like any other block, and to respect the padding, border, and margins, but to flow that rectangle with other inline content - exactly the way the browser would flow an image.   In addition, you can specify the width and height of inline-block items. This is a crazy useful concept from a layout perspective: it would allow you to make buttons out of text that lay out horizontally, or to layer images on top of each other inside a small span or div.   </p>
<p>Here's an example of a series of list items set with border, padding, and a width and height.  The code first:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;style&gt;
   ul {
	width: 400px;
	border: 2px solid black;
	background: #aaf;
	}
li {
	border: 2px dotted blue;
	padding: 1em;			
	width: 100px;
	height: 35px;
}
ul.inline li {
	display: inline;
}
ul.inline-block li {
	display: inline-block;
}
&lt;/style&gt;
&lt;h2&gt;Padded words wrapped with display: inline;&lt;/h2&gt;
	&lt;p&gt;
		&lt;ul class=&quot;inline&quot;&gt;
		&lt;li&gt;Lorem&lt;/li&gt;
		&lt;li&gt;ipsum&lt;/li&gt;
		&lt;li&gt;dolor&lt;/li&gt;
		&lt;li&gt;sit&lt;/li&gt;		
		&lt;li&gt;amet&lt;/li&gt;
		&lt;li&gt;consectetur&lt;/li&gt;
		&lt;li&gt;adipisicing&lt;/li&gt;
		&lt;li&gt;elit&lt;/li&gt;		
		&lt;li&gt;sed&lt;/li&gt;
		&lt;lido&lt;/li&gt;
		&lt;li&gt;eiusmod&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/p&gt;
&nbsp;
	&lt;h2&gt;Padded words wrapped with display: inline-block;&lt;/h2&gt;
	&lt;p&gt;
		&lt;ul class=&quot;inline-block&quot;&gt;
		&lt;li&gt;Lorem&lt;/li&gt;
		&lt;li&gt;ipsum&lt;/li&gt;
		&lt;li&gt;dolor&lt;/li&gt;
		&lt;li&gt;sit&lt;/li&gt;		
		&lt;li&gt;amet&lt;/li&gt;
		&lt;li&gt;consectetur&lt;/li&gt;
		&lt;li&gt;adipisicing&lt;/li&gt;
		&lt;li&gt;elit&lt;/li&gt;		
		&lt;li&gt;sed&lt;/li&gt;
		&lt;li&gt;do&lt;/li&gt;
		&lt;li&gt;eiusmod&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/p&gt;</pre></div></div>

<h4>Here's how Safari renders the above code (correctly):</h4>
<p><a href='http://blog.lrdesign.com/wp-content/uploads/2008/06/safari-ib.png'><img src="http://blog.lrdesign.com/wp-content/uploads/2008/06/safari-ib.png" alt="" title="safari-ib" width="500" height="330" class="alignnone size-full wp-image-27" /></a></p>
<h4>And here's how Firefox 2 renders it (incorrectly):</h4>
<p><a href='http://blog.lrdesign.com/wp-content/uploads/2008/06/ff2-ib.png'><img src="http://blog.lrdesign.com/wp-content/uploads/2008/06/ff2-ib.png" alt="" title="ff2-ib" width="500" height="321" class="alignnone size-full wp-image-28" /></a></p>
<p>Horrific - FF2 simply ignores inline-block, causing the list elements to render in their default display mode, block.   What's galling about this is that for several years Firefox has been <em>the only browser that gets it wrong</em>!  That's right, even Internet Explorer 6 gets this right ... at least on some elements, specifically those that are natively display: inline, like spans and anchors.   </p>
<p>The Firefox <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=9458">bug report</a> was filed way back in the days of Firefox 1 <em>nine years ago</em>.   Yes, you read that right.   It sat there, unfixed, while every other browser in the world implemented it.   </p>
<p>Anyway, today web developers everywhere can rejoice.  Now, at last, the released version of every major browser supports display: inline block.  So, with only another year or two waiting while FF2 users upgrade to FF3, designers will be able to start using this singularly useful CSS rule (at least in cases where IE supports it as well).</p>
<h3>A parting example</h3>
<p>A parting example of the kind of cool trick you can play with inline-block: text flowing inside a sized box that is itself flowing inside text.</p>
<h4>Code for flowing text inside flowing text:</h4>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div style=&quot;font-size: 250%; width: 600px;&quot;&gt;
	Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 
		&lt;span style=&quot;width: 130px; height: 40px; font-size: 9px; display: inline-block;
			padding: 1em; border: 1px solid black; overflow: hidden;&quot;&gt;
			Duis aute irure dolor in reprehenderit in voluptate velit esse cillum 
			dolore eu fugiat nulla pariatur.
		&lt;/span&gt;	
	incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. 	
	&lt;/div&gt;</pre></div></div>

<h4>How it renders in a compliant browser ... including IE6!*</h4>
<p><a href='http://blog.lrdesign.com/wp-content/uploads/2008/06/flow-in-flow1.png'><img src="http://blog.lrdesign.com/wp-content/uploads/2008/06/flow-in-flow1.png" alt="Tricks with flowing text" title="flow-in-flow1" width="500" height="194" class="alignnone size-full wp-image-30" /></a></p>
<p>*Well, more or less.  IE6 gets it reasonably close.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lrdesign.com/2008/06/firefox-download-day-display-inline-block-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
