Some more flexing of the opportunities provided by dynamic CSS

03Dec06

By Josh Adams.

So I’ve got my RcssController handling all my css files these days (so I can make sweeping color changes, or per-user stylesheet config settings), and I just added my first helper function. You use it like this, to generate shadows on a given element:


div.trip .package{
 width: 16em;
 padding: 1em;
 margin-right: 1em;
 background-color: #282828;
 float: left;
 <%= shadow :color => "#1b1b1b", :width => 0.5 -%>
}

And here’s the helper itself:


module RcssHelper
  def shadow options = { :width => 0.5, :color => "#222" }
    <<-END
      border-width: 0 #{options[:width]}em #{options[:width]}em 0;
      border-color: #{options[:color]};
      border-style: solid;
    END
  end
end

Advertisements


No Responses Yet to “Some more flexing of the opportunities provided by dynamic CSS”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: