Andrew Colclough

Web Design & Dev., Liberty, Economics, Football

Sublime: ...A Color Picker like Textmate?

Yeah, another feature that I (a CSS designer/dev) cannot live without. If you have no idea what I am talking about, here's the skinny:

Usually, as I am working on rapid development - I need to quickly pick colors - and test how they mesh with my design. Well, I don't know about you - but I don't do instant Hex or RGBa color conversions in my head too quickly. So, one of my favorite features of TextMate is the command "Insert Color" - Invoked by hitting Command+Shift+C. This launches the Apple color wheel picker that I use to adjust ranges of color -> which then spits out a Hex or RGBa value into my CSS code. 

Colorpicker

Sublime Text 2 doesn't have anything like this (as of yet...), and for me - that really could slow down my workflow. However - I found a decent solution until (or if) Sublime gets something like this. 

First: Nab the application version of the Apple Color Picker

This will allow you to keep open the color picker while you are working.

Second: Download and install either or both:

Colors

Simply drop these plugin files into Library > ColorPickers (create this dir/ if it doesn't exist). Then restart the Color Picker Application - and you have a way to easily grap Hex or RGBa values and dump them into Sublime. Win!

Note - Obviously, this is for OSX users. If you are on Windows, you will have to hunt around for windows variations of these little apps. 

Also - the TextMate command is just a ruby script...so if anyone has the know-how to convert it to something Sublime could understand...

Insertcolor
And if you had the same question I did about the above screenshot...

Burlywood

Filed under  //   Color Picker   Sublime Text 2   Textmate   burlywood   coding   css   hex   tips  

Sublime Text Editor - Shell Alias for Opening dir/ or File

Edit_side_by_side_in_widescreen

So on Noonat's advice I have been checking out Sublime Text Editor as an alternate for Textmate

So far, I am very impressed - though there was one thing I absolutely missed from Textmate: The abulity to simply open any directory or file from Terminal via a shell alias:

mate dir/

Well, with Noonat's help, here is a simpe way to set one up for Sublime:

Add the following to your .bashrc file:

alias slime='open -a "/Applications/Sublime Text 2.app"'

You can name the alias (I chose "slime") whatever you want - but make sure that you point to the application and you need to have the extension .app on the end.

It is enjoyable to be able to open a repo with Sublime via:

slime /projectName

;)

Filed under  //   .bashrc   Sublime   Textmate   alias   code   programming   shell   text editor   tips  

Behold - the awesome power of Sass Mixins

In case you missed this post, I have started using the Compass and Sass CSS frameworks on a new project. I wanted to share a little magical Sass action that I came across while working on a new site.

A Browser-wide Opacity Mixin

Probably the most outstanding feature of Sass is the ability to create "mixins." A mixin is nothing more than a small block of styling code that you create once - and then simply call out later (similar to calling a function in javascript). Sass' Mixin's can preform many actions that you would expect from a normal programming  language such as accepting parameters, variables, and even preforming those 'hard' maths. I happened to create a simple mixin that uses all three of these features to render a desired opacity across all browsers (hat-tip: Chris Coyier for the cross-browser opacity code). 

As Chris pointed out, each browser accepts opacity styles in a slightly different way. (I know, you're shocked...shocked!!) With regular CSS - you have two options: 

1) Create a .transparent_class and apply this to all html elements you wish to apply the opacity shift to. While this works, it is somewhat undesirable - because you are adding specific style information into your markup. In effect, to add/remove a design aspect you would need to alter your markup - when the ultimate goal is to separate the markup/structure from the style/design.

2) Apply all 4 opacity style rules to each individual element you select through CSS. This is technically better, but obviously a pain in the butt, and can really muck up your CSS. Unless you use a code editor such as Textmate which supports code snippets - you will be failing to keep your code DRY (Don't Repeat Yourself).  

As a side note, don't feel bad if you happen to use either of these methods. Coding ideals are just that: ideals. Coding ideals are often nice (though lofty) goals that will spare you headaches over time. However, in my experience - the difficulty and time involved coding rises exponentially the more rigidly you attempt to adhere to a coding ideal. 

But there is good news. The Sass Framework can greatly help in this department.

Here is the Sass Mixin I created for opacity:

Declaring the Mixin:

Mixin

Explanation:
The first line is the mixin name that you will refer to later, followed by the actual opacity parameter variable.
The next several lines are each of the 4 browser opacity style rule variations. Each one refers to the !opacity variable that you will pass the mixin. Because Internet Explorer takes the parameter in a different format (e.g. IE: 50, Others: 0.5 ) - I use a little simple math to calculate the value. Zing!

(By the way - the strange format is just one of the ways to write Sass code. You can read more about that on the Sass website.)

Calling the Mixin:

Mixincall

Explanation:
To call the mixin, all I have to do is add +opacity rule and pass the actual value I want inside the parentheses.  (note: the +shadow line is calling another mixin I created that accepts many parameters)

Sass code is then compiled to CSS (in this case, automatically by compass anytime I save a change) and adds...

filter: alpha(opacity= !opacity * 100); -moz-opacity: 0.7; -khtml-opacity: 0.7; opacity: 0.7;

...to the class .book-shadow, or anyplace else I call +opacity.

With Sass - it allows me to have the best of methods 1 and 2, which I mentioned above. I don't have to add design specific classes into my markup, as in method #1. Also - if I want a different opacity value, I don't have to create a separate .transparency_lighter_class, for example. I simply pass a different value. Sass also cuts out the suck of method #2, because I only have to repeat the one rule +opacity(howMuch) to any element.

Now - you do still end up with repetitive rules in your CSS files anytime you call +opacity - but you don't have to deal with them. Plus, Sass can be told to compile your CSS into a variety of modes, from expanded - to compact, which will trim down the size of your CSS, if you want it to.

Mixins are just one of the many great features of Sass. So far, my workflow has been greatly enhanced, and that's a Win in my book. 

Happy coding.

-Adc

Filed under  //   Chris Coyier   DRY   coding   compass   css   framework   mixin   opacity   sass   tips  

Tip: Be Findable on Facebook by your Maiden Name without showing it.

Here's a tip for the recently married ladies on Facebook. In the 'Settings' area under 'Names', Facebook allows you to put in an alternate name - such as your Maiden Name.  People who know you by your maiden name can then find you on Facebook BUT, since lots of institutions like banks use maiden names as security - you can elect to NOT display your maiden name to all your friends (or acquaintances) on Facebook.

Ishot-146

For instance, those friends who may only know me by one of my alter egos: El Pistolero, Jar-Jar Desecrator, or Whitetrash Grandma ...(don't ask...) -they can find me on Facebook without me displaying these names to the world. ;)

Filed under  //   facebook   names   tips  

jQuery Visual Cheat Sheet

Awesome JQuery resource. Hat-Tip to Dave Merwin for picking this up! (Also for tipping me off to Posterous)
Media_httplh3ggphtcomtqpdhmaewtmsrtuwc0tv2iaaaaaaaafse5vekq2vogj4sjvcs66jpg_ejftxacwqhgrlvh

Making happy designers and developers...

Filed under  //   cheat-sheet   jquery   tips   web developement  

Curious about CSS?

Mastering CSS Coding: Getting Started « Smashing Magazine
Media_httpmedia1smashingmagazinecomwpcontentuploads2009096bjpg_xjedigkgcwurewi

Whether you are a total n00b, or teh 7337 h4XX0rz - this is a great intro article covering most of the basics of Cascading Style Sheets.

Filed under  //   css   tips   web design   web developement