css_grid 2.2.1 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -156,6 +156,21 @@ You can also pass 'prepend' or 'append as an argument for the '*_span' helpers.
156
156
  </div>
157
157
  ```
158
158
 
159
+ Note that 'prepend' accept negative values
160
+
161
+ ```erb
162
+ <%= four_span :prepend=>-1 do %>
163
+ <!-- some html -->
164
+ <% end %>
165
+ ```
166
+
167
+ ```html
168
+ <div class="four_span minus_one">
169
+ <!-- some html -->
170
+ </div>
171
+ ```
172
+
173
+
159
174
  --
160
175
 
161
176
  If you want to use rows inside *_spans tags, you can use :nested option.
@@ -254,11 +269,13 @@ Here is a list of options you can use. Following exemples.
254
269
  * :class => String or Symbol - set the class attribute for the container.
255
270
  * :nested => :spans - allow to use *_span tags directly inside the block passed by.
256
271
  * :disable => :spans or :container or [:spans, :container] - disable automatic creation of *_spans tags, or container tag, or both, allow you to handle this part manually.
257
- * :spans => Hash (authorized keys are :class, :prepend, :append) - pass by options to automatic created *_spans tags.
258
- * :rows => Hash (authorized keys are :class and :nested) - pass by options to automatic created rows tags.
272
+ * :spans => Hash (authorized keys are :id, :class, :prepend, :append) - pass by options to automatic created *_spans tags.
273
+ * :rows => Hash (authorized keys are :id, :class and :nested) - pass by options to automatic created rows tags.
259
274
 
275
+ Note :
276
+ * You can use procs in :spans/:id, :spans/:class, :rows/:id and :rows/:class
260
277
 
261
- Note that :
278
+ Also :
262
279
  * :nested also accept :container as a value (works the same way as :disable). It allows to use *_col_container inside a *_span tag. :nested_with => Integer must be informed in that case, telling the width of the span you'r in.
263
280
  * the GridHelper automaticly calculate if you are in a nested container and pass options :nested=>:container and :nested_width on his own. So you normaly don't have to care about that.
264
281
 
@@ -268,6 +285,37 @@ Shortcuts :
268
285
  * options :disable and :rows will be ignore, and options :id and :class will be directly applied to the row tag.
269
286
 
270
287
  Examples :
288
+ ```erb
289
+ <%= three_cols_container :collection=>@collection, :rows=>{:id => Proc.new{ |elt| elt[:name].downcase }} do |elt| %>
290
+ <%= four_span do %>
291
+ Class : <%= elt[:name] %><br/>
292
+ Detail : <%= elt[:methods] %>
293
+ <% end %>
294
+ <% end %>
295
+ ```
296
+
297
+ ```html
298
+ <section class="container " id="nested">
299
+ <div class="row " id="enumerable">
300
+ <div class="four_span ">
301
+ Class : Enumerable<br/>
302
+ Detail : 163 methods
303
+ </div>
304
+ <div class="four_span " id="array">
305
+ Class : Array<br/>
306
+ Detail : 178 methods
307
+ </div>
308
+ <div class="four_span " id="string">
309
+ Class : String<br/>
310
+ Detail : 177 methods
311
+ </div>
312
+ </div>
313
+ </section>
314
+ ```
315
+
316
+ --
317
+
318
+
271
319
  ```erb
272
320
  <%= three_cols_container :id=>"nested", :collection=>@collection, :nested=>:spans do |elt| %>
273
321
  <%= two_span do %>
data/lib/assets/.DS_Store CHANGED
Binary file
@@ -42,6 +42,19 @@ $gutter_width: 1.041666666666;
42
42
  .prepend_eleven { @include prepend($grid_width, 11); }
43
43
  .prepend_twelve { @include prepend($grid_width, 12); }
44
44
 
45
+ .minus_one { @include prepend($grid_width, -1) }
46
+ .minus_two { @include prepend($grid_width, -2) }
47
+ .minus_three { @include prepend($grid_width, -3); }
48
+ .minus_four { @include prepend($grid_width, -4); }
49
+ .minus_five { @include prepend($grid_width, -5); }
50
+ .minus_six { @include prepend($grid_width, -6); }
51
+ .minus_seven { @include prepend($grid_width, -7); }
52
+ .minus_eight { @include prepend($grid_width, -8); }
53
+ .minus_nine { @include prepend($grid_width, -9); }
54
+ .minus_ten { @include prepend($grid_width, -10); }
55
+ .minus_eleven { @include prepend($grid_width, -11); }
56
+ .minus_twelve { @include prepend($grid_width, -12); }
57
+
45
58
  .append_one { @include append($grid_width, 1) }
46
59
  .append_two { @include append($grid_width, 2) }
47
60
  .append_three { @include append($grid_width, 3); }
@@ -1,3 +1,3 @@
1
1
  module CssGrid
2
- VERSION = "2.2.1"
2
+ VERSION = "2.3.1"
3
3
  end
data/lib/css_grid.rb CHANGED
@@ -16,7 +16,11 @@ module GridHelper
16
16
  end
17
17
 
18
18
  def grid tag, options = {}, &block
19
- prepend = TWELVE_STRING_INTS_INVERT[options.delete :prepend]
19
+ prepend = if options[:prepend] > 0
20
+ TWELVE_STRING_INTS_INVERT[options.delete :prepend]
21
+ else
22
+ "minus_#{ TWELVE_STRING_INTS_INVERT[options.delete :prepend] }"
23
+ end
20
24
  append = TWELVE_STRING_INTS_INVERT[options.delete :append]
21
25
 
22
26
  warn "WARNING : argument ':nested' is not supported for '#{ tag }'" if options[:nested].present? and tag != :row
@@ -75,7 +79,11 @@ module GridHelper
75
79
  capture(elt, &block)
76
80
 
77
81
  else
78
- grid("#{ span_width }_span".to_sym, options[:spans].clone) do
82
+ spans_options = options[:spans].clone
83
+ spans_options[:id] = spans_options[:id].call elt if spans_options[:id].class == Proc
84
+ spans_options[:class] = spans_options[:class].call elt if spans_options[:class].class == Proc
85
+
86
+ grid("#{ span_width }_span".to_sym, spans_options) do
79
87
  safe_buffer = capture(elt, &block)
80
88
  safe_buffer = grid(:row, :nested=>true){ safe_buffer } if nested.include? :spans
81
89
 
@@ -84,7 +92,11 @@ module GridHelper
84
92
  end
85
93
  end
86
94
 
87
- grid(:row, options[:rows].clone){ cols.reduce(:safe_concat) }
95
+ rows_options = options[:rows].clone
96
+ rows_options[:id] = rows_options[:id].call elt if rows_options[:id].class == Proc
97
+ rows_options[:class] = rows_options[:class].call elt if rows_options[:class].class == Proc
98
+
99
+ grid(:row, rows_options){ cols.reduce(:safe_concat) }
88
100
  end
89
101
 
90
102
  safe_buffer = rows.reduce(:safe_concat)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-05 00:00:00.000000000 Z
12
+ date: 2012-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -70,18 +70,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
70
  - - ! '>='
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
- segments:
74
- - 0
75
- hash: 752044027004310920
76
73
  required_rubygems_version: !ruby/object:Gem::Requirement
77
74
  none: false
78
75
  requirements:
79
76
  - - ! '>='
80
77
  - !ruby/object:Gem::Version
81
78
  version: '0'
82
- segments:
83
- - 0
84
- hash: 752044027004310920
85
79
  requirements: []
86
80
  rubyforge_project:
87
81
  rubygems_version: 1.8.24