Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/technicalpickles/blueprint-layout
Rails helpers to generate Blueprint CSS-based structures
https://github.com/technicalpickles/blueprint-layout
Last synced: about 1 month ago
JSON representation
Rails helpers to generate Blueprint CSS-based structures
- Host: GitHub
- URL: https://github.com/technicalpickles/blueprint-layout
- Owner: technicalpickles
- License: mit
- Created: 2009-11-13T06:52:48.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2009-11-13T06:53:20.000Z (about 15 years ago)
- Last Synced: 2024-10-14T21:52:56.398Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 74.2 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
- License: MIT-LICENSE
Awesome Lists containing this project
README
h1. BlueprintLayout
Not for the faint of heart, this plugin is used to build HTML structures with the appropriate Blueprint classes for a grid-based layout.
The purpose of this is to reduce the number of span-#'s littered throughout the views. I don't typically use Blueprint's semantic classes, so it's especially important to me that I not have to deal with all these when a layout changes.
Math is done on the fly, but it's still pretty snappy. If the calculations don't come out to nice, even numbers, when stepping back up the number is not affected. For example, let's say you define a @column 11@, then have two @column :half@s within that. After the second is rendered, we step back out to 11 (the real width) instead of the multiple based on previous width (5 * 1/:half)
h2. Examples
You're going to want to wrap your content in a @container@ block.
From there, use symbols (underscored, as fractions) or numbers to define the width of your columns. I prefer the fractions (less actual math I have to do, and fractions can change and still have the page not look like complete junk).
<% container do %>
<% column :three_fourths do %>
<% column :half do %>
<% end %>
<% column :one_third, prepend_one_sixth, :last do %>
<% column :half do %>
<% end %>
<% column :half, :last do %>
<% end %>
<% end %>
<% end %>
<% column :one_fourth, :last do %>
<% column 5 do %>
<% end %>
<% column 1, :last do %>
<% end %>
<% end %>
<% end %>h2. Caveats
h3. Currently Only Works with Rails 2.2.2+!
This is because the way views have been handled in previous versions are wonky, and I don't want to write a bunch of conditionals to handle older versions of Rails (yet).
Ambitious? Fork this puppy and patch it. I'll point you to the right direction even: within @lib/view_helpers.rb@, the problem area is introduced after the constant @BLOCK_CALLED_FROM_ERB@. Good luck!
h3. Very Beta
This needs a lot of lovin'. There's a nice hack to get AJAX-loaded partials to play together properly (since, when partials are loaded with AJAX, we don't know how deep within the div stack they are). I use session to keep track of that and cache partials' depth (and clear the cache with every new request that's not xhr).
I also abuse @method_missing@ to allow for calls like @prepend_one_third@ or @append_one_eigth@. Again, it may not be the _best_ thing ever, but boy is it handy.
Copyright (c) 2008 - 2009 Joshua Clayton, released under the MIT license