CSS theming, magnification, and foot pedals
| development, geek, kaizenI’m working on the stylesheets for a site, which means lots of fiddly little changes.
I decided to make all of my styling changes to my Sass source files instead of editing the attributes in Google Chrome because I found myself forgetting to copy attribute values back from Chrome. Editing the source files directly meant that the changes would be persistent – a slightly slower workflow, but a more reliable one.
I used Chrome to set selected divs to show up with display: block
. This meant that I didn’t have to keep triggering hover behaviours myself. Then I used CSS Reloader to reload the stylesheet. Chrome kept my manual attribute changes, like display: block
, while applying the new styles. Awesome!
I wanted a quick way to update my browser windows after I saved the file. Saving would automatically trigger Compass’ conversion of the Sass files into CSS, but the browser still used the old stylesheet until I trigged CSS Reloader with F9 or the context menu. I didn’t want to refresh the entire page because that would lose the display: block
I’d manually set.
AutoHotkey to the rescue! I wrote a function that saved the current file, waited for Compass to convert the Sass file into CSS, and then used the CSS Reloader shortcut key on all open Chrome windows. This meant that I could have a translucent browser window superimposed on the design PDF for easy comparison (thanks, WinWarden), and an opaque browser window for inspection and navigation.
RefreshStylesheets() { Send, ^x^s Sleep, 2000 SetTitleMatchMode, 2 WinGet, id, list, Chrome current := WinExist("A") Loop, %id% { StringTrimRight, this_id, id%a_index%, 0 WinActivate, ahk_id %this_id% WinWaitActive, ahk_id %this_id%,,2 Send {F9} } WinActivate, ahk_id %current% }
Then I mapped it to my foot pedal, just because I could. I didn’t need to take advantage of the 3-way switch, so I mapped all 6 possible functions to RefreshStylesheets.
+F1::RefreshStylesheets() +F2::RefreshStylesheets() +F3::RefreshStylesheets() +F4::Send, +F1 +F5::Send, +F2 +F6::Send, +F3
To make it even easier to fine-tune tiny differences, I installed Magnifixer. I used the “Fixed” mode to magnify the translucent portion I was working on, and I moved the display next to my code. That meant that I could avoid turning my head all the time. I could simply tweak my code, nudge the pedal with my toes, glance at the display (or use peripheral vision!), get it right, and then check the overall view.
Foot pedals are fun. More fun than mapping the shortcut to something like F9 or F12, which would involve taking my fingers off home row and finding a small key. You can literally stamp out bugs.
All this put me in such a good humour that I ended up getting the homepage almost pixel-matched to the specs, except for the limitations on letter-spacing and the adjustments I made for the inconsistencies in the spec layout.
Whee! I can’t wait to use this idea when developing backend code. I’ve played around with Autotest on a Rails project, and it should be a simple matter to write a shell script running selected tests on any project. Fun!
Foot pedal + second monitor = awesome squared.