Goodbye Tucson – Hello Seattle

I had been throwing around the idea of leaving Tucson for the past year or so and was pretty set on moving to the Bay Area in late 2013. However after returning to Tucson from a weekend trip to San Diego I made a hasty decision to move to Seattle instead. It’s been 12 years since I’ve lived in Seattle and thought it would be nice to be closer to family. I normally enjoy Tucson summers and especially the monsoon season, but temperatures this June were out of my comfort zone. I chose to move to Seattle instead of the Bay Area because I have family there and figured housing would be easier to come by.

It took me a month and a half, but I eventually found an apartment close to downtown on Capitol Hill and am now comfortably situated and very well caffeinated.

Seattle has been for the most part dry, pleasant, and in the 80’s. Perfect for bike rides if you’re comfortable going up and down hills (I had to swap out the chain ring on my fixed gear to accommodate these). Clouds and rainy systems have been rolling in more frequently lately, but they’re a welcome addition to the mix in my mind, especially after 5 years of basically non-stop sunshine courtesy of Tucson in all it’s subtle, yet nevertheless-summer-like seasons.

I’m looking forward to cooler weather, fall colors, and being a little more aware of the tides.

Using LESS with CodeKit to compile multiple CSS files

For the past month or so I have been using LESS in combination with CodeKit to author my CSS.

LESS adds a lot features that CSS lacks. It also allows structuring CSS in ways that aren’t practical for a production website or application and I think it’s going to play a large role in the future of web design. CodeKit makes working with LESS a breeze. CodeKit is also compatible with Sass, Stylus, CoffeeScript and Haml (if you’re into that level of abstraction).

LESS and CodeKit for mobile-first, responsive web design

There are two main approaches to building mobile-first, responsive websites. One method is to use multiple linked stylesheets with media queries called directly in the markup. Another is to use a single stylesheet with multiple media queries within it. (Of course with both of these approaches you will need to use a polyfill for old versions of IE or provide a link to a separate IE stylesheet). I prefer the using a single stylesheet because I want to keep HTTP requests to a minimum so our websites are as fast as possible. The drawback to using such an approach is that you may end up having a rather large CSS file which can make editing and debugging more difficult than it needs to be.

Having your cake and eating it too – Compiling multiple LESS files into one with CodeKit

Let’s start by creating a default mobile stylesheet. Since I primarily work with WordPress, I call this file style.less, and keep it in a folder called “less”. If you’re using WordPress, you need to compile it to style.css in the main template directory, otherwise you can place these files wherever you would like.

From within this file, we can import some helper LESS files (also kept in the less directory) near the top of the document. After my requisite WordPress stylesheet header, I have something similar to the following:

@import 'mixins.less'; // Mixins to use in our other LESS files
@import 'normalize.less'; // A reset stylesheet

Mixins are basically predefined styles that you can drop in anywhere in your LESS file. If you’re often using vendor prefixed declarations, they will save you loads of time. Dmitry Fadeyev was nice enough to share his set of mixins, but you can easily make your own. Andy Clarke has also recently released a set of mixins as part of his 320 and Up HTML5 Boilerplate extension which I highly recommend checking out.

The normalize file is basically a CSS reset and you can read more about Normalize.css here. Basically these are files I’m not going to change often and don’t want to be part of my main CSS files. It’s also important to note that if you’re coding a WordPress site, you will need to use LESS rather than CSS as the file extension even if you’re not using any LESS code. This is because CodeKit imports these files above your WordPress stylesheet header which will break your theme. It’s still in beta, so this may be fixed in the future.

After you have your helper LESS files imported, you can begin coding your mobile-first style after these @import calls. When your site is looking good on mobile and you’re ready to work your way up, simply import your media queries like so:

@import url("480.less");
@import url("600.less");
@import url("768.less");
@import url("992.less");
@import url("1382.less");
@import url("2x.less");

From within each LESS file, make your media query calls. In the 480.less file, you would want to put the following to target browsers with a minimum width of 480 pixels :

@media only screen and (min-width: 480px) {
body {
// Put your styles for the body element here
}
} /* end 480 */

Now every time you save a LESS file, CodeKit will compile it all into one CSS file. You now have the flexibility of authoring multiple CSS (LESS) files while serving just one CSS file to your server.

Remembering Steve Vihel

Steve Vihel, photo via Michael McKisson (http://tucsonvelo.com/blog/well-miss-you-steve/10943)

Before I met Steve, I heard about him from several friends recommending I stop by his bike shop, There and Back Bikes. When we did finally meet, I was floored by how sincere, and insanely nice he was.

It’s the type of niceness or friendliness that I find really hard to describe—possibly because it’s something I rarely encounter—but at any rate, Steve readily shared that with me the first time we met and it left a deep impression on me. I feel incredibly privileged to have known him and deeply saddened that he’s no longer with us, but he will always have a place in my heart.

More on Steve’s life here.

Hiding the iPhone URL bar

It’s a common practice to hide the URL bar for iOS and android devices. The reason for this is pretty straight forward: it takes up screen real estate.

An iPhone with the URL bar visible.

This is one very common approach that’s being used now:

addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
  function hideURLbar(){
  window.scrollTo(0,1);
}

The above javascript simply scrolls the page to the top and in the process the iOS URL bar is scrolled off of the screen after the page loads. This works great, but it has a big usability problem that I ran into this weekend after some mobile web browsing over 2g. Namely, if you’ve loaded up a page that uses this function, and you then begin scrolling down the page to read or browse through the loaded content, you’re abruptly taken back to the top of the page when the function fires.

I’ve noticed this behavior on sites like TechCrunch and engadget, and it’s really annoying. I’m guilty myself of adding this code to websites myself, but will be avoiding it in the future. This isn’t something you would need to worry about if you load all of the content after the JS executes, but unfortunately that’s generally not the quickest way to load the page. I’d be interested in hearing any solutions to this problem, but for now I’ll just have to be content with a URL bar.