At work, all our new sites share a common .css file that provides structure as well as default black/white/gray values. Each site then has a .css file loaded in afterward, which specifies the colors and background images that make redding.com look different than knoxnews.com.
The process of making each new site involves using a previous site’s .css file as a starting point, and modifying its colors values to match the new skin. I’m sure this is a process common to many theming-related workflows. Using TextMate as my editor of choice, I’m not aware of any way to see color values contained in my .css files, and wound up finding (and fixing) a couple stray Redding colors in Knoxnews ‘ .css file after it launched. I decided this shouldn’t happen again.
So today I’m launching CSS Prism, a CSS color spectrum inspector. Input the path to any .css file, and it’ll output an easy to scan display of all hex colors from the file. Unwanted colors can be edited via a Photoshop-like color picker (using the jQuery color picker) and the resulting .css file can be downloaded for your convenience.
This project, built of course with Django, has been fun challenge to improve both my jQuery ability and my regular expression comprehension. It also led me to write my first bookmarklet.
The CSS Prism Bookmarklet will insert links to any webpage’s linked .css files just inside the body tag.
CSS Prism will be quite helpful to me as I build more sites at work. And if anyone else finds it useful, that’ll make it even more worthwhile.
Awesome work! My first pony is being able to point to an HTML file and you detecting the CSS link from that
Thanks, James! That's certainly a good idea to implement on the site itself. Right now, that's basically the functionality of the bookmarklet - hit it from any page, and it detects the css links.
I hope to support file uploads in the future, too.
DAMMIT, BERG!! This is freakin sweet. Can't wait to use it on the Texas sites. :)
Nice! Looking forward to checking this out.
I have been using FF Web Developer Toolbar:
Information >> View Color Information
Nice work!
Cool.
The only problem I faced immediately that it assumes one color value per line. So when you have a compressed stylesheet with everything in just one line, it will only came up with one color value.
Micky - Well, shit. Looks like I just spent three weeks building something I basically already have installed in my browser. I never thought to look under the "Information" menu.
Looks like the Web Developer functionality is better in that it can get multiple CSS files at once, and won't be tripped up by firewalls. CSS Prism has the advantage of an interface for editing/replacing color values.
Thanks for pointing that out! facepalm
Slink - Yeah, inability to get all the colors from a compressed stylesheet is an unfortunate limitation of the first working draft codebase.
Assuming there's enough interest in continued development, the first item on my todo list is to overhaul the css parsing to not be dependent on having one property per line.
Ryan: I actually prefer the single CSS color method, but probably because I use a single common CSS file to style my overall site structure and then separate CSS files for individual section design. Very handy!
This would be really cool as a reusable application that will then let users of /admin/ modify a CSS file's colors and then save the file automatically.
Hy Ryan,
You're not alone. I once spent a good chunk of time re-implementing firefox's "web search" contextmenu option.
I run colr.org, and I think CSS Prism is fantastic. The edit / replace / re-download functionality is really well done.
Lloyd, sometimes it's fun just trying to make a better wheel. Even when you aren't yet aware of the wheel's existence.
Hi Ryan,
You've created a fantastic tool! Thanks for making it public.
This'll be useful for dealing with picky designers that want to change site colors halfway through a project: "Just send me the updated CSS file!"
This looks like a great tool for web designers.
Pretty neat Ryan - you might want to consider sorting the colors by hamming distance.
Thanks everyone for checking out CSS Prism and passing the link along. I never expected this level of attention and kind words for a project I initially created to solve a specific workflow issue at work. It's good to know there are others finding CSS Prism as useful as I have.
Chris - I take it once the colors were converted to 6 digits and sorted by hamming distance, the output would be a more gradual shift in color from start to finish?
Nice Idea. Please extend to support "real world" stylesheets.
You might want to consider using a "real" css parser instead of regexes. There is a relatively easy to use python library to do that: http://code.google.com/p/cssutils/
Ulrich - The lack of support for compressed stylesheets (and @imported stylsheets) comes from an early decision based on my original use case for CSS Prism. Obviously, the product has grown since then and CSS parsing needs a major upgrade.
This week I've been experimenting with cssutils as you mentioned, but also more robust regexes. cssutils has certainly been easy to parse with, but I'm curious to see if it would introduce more memory overhead compared to using regexes.
Ryan, guess what's worse than getting told that an app like the one you just launched got built before ...
Beeing in the middle of building one and reading about someone else launching. ;/ I finished mine anyway, since it was my first python project.
Yours looks pretty neat and the color replacement thing is very useful. Although I have built my own I will probably be passing around your link aswell. :)
SaturnPolly - I just checked out your app - pretty cool stuff! Your default 'grid' view for colors is similar to another view I've been wanting to present on CSS Prism, and the hue-grouped, value-sorted view is freaking awesome.
You're also rockin' on the support for multiple styesheets, links, @import, etc. Aside from a little js quirkiness, it's working really well. Great stuff!
Comments are disabled for this item
© 2007-2008 Ryan Berg // Built with Django // Hosted on WebFaction
Discussion