css_grid 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -5
- data/README.md +368 -90
- data/css_grid.gemspec +0 -1
- data/lib/assets/.DS_Store +0 -0
- data/lib/assets/images/.DS_Store +0 -0
- data/lib/assets/images/readme/.DS_Store +0 -0
- data/lib/assets/images/readme/disable.png +0 -0
- data/lib/assets/images/readme/menu.png +0 -0
- data/lib/assets/images/readme/multi_nested.png +0 -0
- data/lib/assets/images/readme/nested.png +0 -0
- data/lib/assets/images/readme/normal.png +0 -0
- data/lib/assets/images/readme/one_col_row.png +0 -0
- data/lib/assets/images/readme/prepend.png +0 -0
- data/lib/assets/stylesheets/grid.css.scss +18 -18
- data/lib/css_grid/version.rb +1 -1
- data/lib/css_grid.rb +9 -8
- metadata +13 -20
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
css_grid (2.
|
5
|
-
hash_extend
|
4
|
+
css_grid (2.2.0)
|
6
5
|
railties (>= 3.1.0)
|
7
6
|
|
8
7
|
GEM
|
@@ -24,14 +23,13 @@ GEM
|
|
24
23
|
activesupport (3.2.8)
|
25
24
|
i18n (~> 0.6)
|
26
25
|
multi_json (~> 1.0)
|
27
|
-
builder (3.0.
|
26
|
+
builder (3.0.4)
|
28
27
|
erubis (2.7.0)
|
29
|
-
hash_extend (1.1.0)
|
30
28
|
hike (1.2.1)
|
31
29
|
i18n (0.6.1)
|
32
30
|
journey (1.0.4)
|
33
31
|
json (1.7.5)
|
34
|
-
multi_json (1.3.
|
32
|
+
multi_json (1.3.7)
|
35
33
|
rack (1.4.1)
|
36
34
|
rack-cache (1.2)
|
37
35
|
rack (>= 0.4)
|
data/README.md
CHANGED
@@ -6,10 +6,6 @@ __Grid__ is a 12 column alignment system, based on 1140px width. That fit for 12
|
|
6
6
|
|
7
7
|
__Helpers__ facilitate the use of the grid syntax, to produce correct html markdown. This allow you to pass collections and block, and map the result to insert it into correct html tags.
|
8
8
|
|
9
|
-
## Version
|
10
|
-
|
11
|
-
Current Version is 2.0.0. This doc is about 1.0.0. Update will be realease soon
|
12
|
-
|
13
9
|
## Installation
|
14
10
|
|
15
11
|
Add this line to your application's Gemfile:
|
@@ -104,30 +100,28 @@ You can call 'container', 'row' or '*_span' functions that create the correspond
|
|
104
100
|
|
105
101
|
Code
|
106
102
|
|
107
|
-
erb code
|
108
103
|
```erb
|
109
104
|
<%= container do %>
|
110
105
|
<!-- some html -->
|
111
106
|
<% end %>
|
112
107
|
```
|
113
108
|
|
114
|
-
will produce
|
115
109
|
```html
|
116
110
|
<div class="container">
|
117
111
|
<!-- some html -->
|
118
112
|
</div>
|
119
113
|
```
|
120
114
|
|
115
|
+
--
|
116
|
+
|
121
117
|
You can pass specific html ids or class as arguments
|
122
118
|
|
123
|
-
erb code
|
124
119
|
```erb
|
125
120
|
<%= row :class=>:some_class do %>
|
126
121
|
<!-- some html -->
|
127
122
|
<% end %>
|
128
123
|
```
|
129
124
|
|
130
|
-
will produce
|
131
125
|
```html
|
132
126
|
<div class="row some_class">
|
133
127
|
<!-- some html -->
|
@@ -135,159 +129,443 @@ will produce
|
|
135
129
|
```
|
136
130
|
|
137
131
|
--
|
138
|
-
|
132
|
+
|
133
|
+
You can also pass 'prepend' or 'append as an argument for the '*_span' helpers. Prepend will slide the column to the left. Append will slide the next column to the left.
|
134
|
+
|
139
135
|
```erb
|
140
|
-
<%=
|
136
|
+
<%= four_span :prepend=>2 do %>
|
141
137
|
<!-- some html -->
|
142
138
|
<% end %>
|
143
139
|
```
|
144
140
|
|
145
|
-
will produce
|
146
141
|
```html
|
147
|
-
<div class="
|
142
|
+
<div class="four_span prepend_two">
|
148
143
|
<!-- some html -->
|
149
144
|
</div>
|
150
145
|
```
|
151
146
|
|
152
|
-
You can also pass 'offset' as an argument for the '*_span' helpers. Offset will slide the column to the left. (like you insert a empty *_span before)
|
153
|
-
|
154
|
-
erb code
|
155
147
|
```erb
|
156
|
-
<%= four_span :
|
148
|
+
<%= four_span :append=>1 do %>
|
157
149
|
<!-- some html -->
|
158
150
|
<% end %>
|
159
151
|
```
|
160
152
|
|
161
|
-
will produce
|
162
153
|
```html
|
163
|
-
<div class="four_span
|
154
|
+
<div class="four_span append_one">
|
164
155
|
<!-- some html -->
|
165
156
|
</div>
|
166
157
|
```
|
167
158
|
|
168
159
|
--
|
169
|
-
|
160
|
+
|
161
|
+
If you want to use rows inside *_spans tags, you can use :nested option.
|
162
|
+
|
170
163
|
```erb
|
171
|
-
<%= four_span
|
172
|
-
|
164
|
+
<%= four_span do %>
|
165
|
+
<%= row :nested => true do %>
|
166
|
+
<%= two_span do %>
|
167
|
+
<!-- some html -->
|
168
|
+
<% end %>
|
169
|
+
|
170
|
+
<%= two_span do %>
|
171
|
+
<!-- some other html -->
|
172
|
+
<% end %>
|
173
|
+
<% end %>
|
173
174
|
<% end %>
|
174
175
|
```
|
175
176
|
|
176
|
-
will produce
|
177
177
|
```html
|
178
|
-
<div class="four_span
|
179
|
-
|
178
|
+
<div class="four_span">
|
179
|
+
<div class="row nested">
|
180
|
+
<div class="two_span">
|
181
|
+
<!-- some html -->
|
182
|
+
</div>
|
183
|
+
|
184
|
+
<div class="two_span">
|
185
|
+
<!-- some other html -->
|
186
|
+
</div>
|
187
|
+
</div>
|
180
188
|
</div>
|
181
189
|
```
|
182
190
|
|
183
191
|
#### Collections
|
184
192
|
|
185
|
-
The most interesting part if you ask me!
|
186
193
|
GridHelper allow you to create severals columns in one time. And include them directly into row or container.
|
187
194
|
|
188
|
-
|
189
|
-
```
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
descrption: I love hash, it's so fun !
|
198
|
-
|
199
|
-
string:
|
200
|
-
name: Text
|
201
|
-
description: Just read the text.
|
195
|
+
There is my collection
|
196
|
+
```ruby
|
197
|
+
@collection = [Enumerable, Array, String].inject([]){ |collection, klass|
|
198
|
+
collection << {:name=>klass.name, :methods=>"#{ klass.methods.count } methods"}
|
199
|
+
}
|
200
|
+
|
201
|
+
@large_collection = [Hash, Set, Fixnum, Float, NilClass, TrueClass].inject([]){ |collection, klass|
|
202
|
+
collection << {:name=>klass.name, :methods=>"#{ klass.methods.count } methods"}
|
203
|
+
}
|
202
204
|
```
|
203
205
|
|
204
|
-
I can
|
206
|
+
I can call *_col_container with a :collection option
|
205
207
|
```erb
|
206
|
-
<%=
|
207
|
-
|
208
|
-
|
208
|
+
<%= three_cols_container :collection=>@collection do |elt| %>
|
209
|
+
Class : <%= elt[:name] %><br/>
|
210
|
+
Detail : <%= elt[:methods] %>
|
209
211
|
<% end %>
|
210
212
|
```
|
211
213
|
|
212
|
-
|
213
|
-
So the produced html will be
|
214
|
+
It will create an grid structure using four_spans (three columns on a twelve grid).
|
214
215
|
```html
|
215
|
-
<
|
216
|
-
<div class="row">
|
217
|
-
<div class="
|
218
|
-
<
|
219
|
-
|
216
|
+
<section class="container ">
|
217
|
+
<div class="row ">
|
218
|
+
<div class="four_span ">
|
219
|
+
Class : Enumerable<br>
|
220
|
+
Detail : 163 methods
|
220
221
|
</div>
|
221
|
-
<div class="
|
222
|
-
<
|
223
|
-
|
222
|
+
<div class="four_span ">
|
223
|
+
Class : Array<br>
|
224
|
+
Detail : 178 methods
|
225
|
+
</div>
|
226
|
+
<div class="four_span ">
|
227
|
+
Class : String<br>
|
228
|
+
Detail : 177 methods
|
224
229
|
</div>
|
225
230
|
</div>
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
+
</section>
|
232
|
+
```
|
233
|
+
|
234
|
+
Screenshot
|
235
|
+
![css_grid normal](https://raw.github.com/petrachi/css_grid/master/lib/assets/images/readme/normal.png)
|
236
|
+
|
237
|
+
|
238
|
+
If you'r more comfortable by telling width of spans istead of the nurmber of columns to use, you can use *_span_container the exact same way than *_col_container. To create the same output as previously, call :
|
239
|
+
```erb
|
240
|
+
<%= four_spans_container :collection=>@collection do |elt| %>
|
241
|
+
Class : <%= elt[:name] %><br/>
|
242
|
+
Detail : <%= elt[:methods] %>
|
243
|
+
<% end %>
|
244
|
+
```
|
245
|
+
|
246
|
+
Note that *_col_container and *_span_container can also be called *_cols_container and *_spans_container. They respond to the following regexp :
|
247
|
+
````ruby
|
248
|
+
/^(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)_cols?_container$/
|
249
|
+
/^(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)_spans?_container$/
|
250
|
+
```
|
251
|
+
|
252
|
+
Here is a list of options you can use. Following exemples.
|
253
|
+
* :id => String or Symbol - set the id attribute for the container.
|
254
|
+
* :class => String or Symbol - set the class attribute for the container.
|
255
|
+
* :nested => :spans - allow to use *_span tags directly inside the block passed by.
|
256
|
+
* :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.
|
259
|
+
|
260
|
+
|
261
|
+
Note that :
|
262
|
+
* :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
|
+
* 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
|
+
|
265
|
+
|
266
|
+
Shortcuts :
|
267
|
+
* one_col_row method create a row with a full with span inside (usualy twelve_span, but this can change if you'r in nested container).
|
268
|
+
* options :disable and :rows will be ignore, and options :id and :class will be directly applied to the row tag.
|
269
|
+
|
270
|
+
Examples :
|
271
|
+
```erb
|
272
|
+
<%= three_cols_container :id=>"nested", :collection=>@collection, :nested=>:spans do |elt| %>
|
273
|
+
<%= two_span do %>
|
274
|
+
Class : <%= elt[:name] %>
|
275
|
+
<% end %>
|
276
|
+
|
277
|
+
<%= two_span do %>
|
278
|
+
Detail : <%= elt[:methods] %>
|
279
|
+
<% end %>
|
280
|
+
<% end %>
|
281
|
+
```
|
282
|
+
|
283
|
+
```html
|
284
|
+
<section class="container " id="nested">
|
285
|
+
<div class="row ">
|
286
|
+
<div class="four_span ">
|
287
|
+
<div class="row nested">
|
288
|
+
<div class="two_span ">Class : Enumerable</div>
|
289
|
+
<div class="two_span ">Detail : 163 methods</div>
|
290
|
+
</div>
|
291
|
+
</div>
|
292
|
+
<div class="four_span ">
|
293
|
+
<div class="row nested">
|
294
|
+
<div class="two_span ">Class : Array</div>
|
295
|
+
<div class="two_span ">Detail : 178 methods</div>
|
296
|
+
</div>
|
297
|
+
</div>
|
298
|
+
<div class="four_span ">
|
299
|
+
<div class="row nested">
|
300
|
+
<div class="two_span ">Class : String</div>
|
301
|
+
<div class="two_span ">Detail : 177 methods</div>
|
302
|
+
</div>
|
231
303
|
</div>
|
232
304
|
</div>
|
233
|
-
</
|
305
|
+
</section>
|
234
306
|
```
|
235
307
|
|
236
|
-
|
308
|
+
![css_grid nested](https://raw.github.com/petrachi/css_grid/master/lib/assets/images/readme/nested.png)
|
237
309
|
|
238
310
|
--
|
239
|
-
|
311
|
+
|
312
|
+
|
240
313
|
```erb
|
241
|
-
<%=
|
242
|
-
|
314
|
+
<%= three_cols_container :id=>"disable_spans", :collection=>@collection, :disable=>:spans do |elt| %>
|
315
|
+
<%= two_span do %>
|
316
|
+
Class : <%= elt[:name] %>
|
317
|
+
<% end %>
|
318
|
+
|
319
|
+
<%= two_span do %>
|
320
|
+
Detail : <%= elt[:methods] %>
|
321
|
+
<% end %>
|
243
322
|
<% end %>
|
244
323
|
```
|
245
324
|
|
246
|
-
will use four col per row (so three_span width), will produce
|
247
325
|
```html
|
248
|
-
<
|
249
|
-
<div class="
|
250
|
-
<
|
251
|
-
|
252
|
-
|
253
|
-
<
|
254
|
-
|
255
|
-
|
256
|
-
<
|
326
|
+
<section class="container " id="disable_spans">
|
327
|
+
<div class="row ">
|
328
|
+
<div class="two_span ">Class : Enumerable</div>
|
329
|
+
<div class="two_span ">Detail : 163 methods</div>
|
330
|
+
|
331
|
+
<div class="two_span ">Class : Array</div>
|
332
|
+
<div class="two_span ">Detail : 178 methods</div>
|
333
|
+
|
334
|
+
<div class="two_span ">Class : String</div>
|
335
|
+
<div class="two_span ">Detail : 177 methods</div>
|
257
336
|
</div>
|
258
|
-
|
259
|
-
|
337
|
+
</section>
|
338
|
+
```
|
339
|
+
|
340
|
+
![css_grid disable](https://raw.github.com/petrachi/css_grid/master/lib/assets/images/readme/disable.png)
|
341
|
+
|
342
|
+
--
|
343
|
+
|
344
|
+
|
345
|
+
```erb
|
346
|
+
<%= three_cols_container :id=>"prepend", :collection=>@collection, :spans=>{:prepend=>2} do |elt| %>
|
347
|
+
Class : <%= elt[:name] %><br/>
|
348
|
+
Detail : <%= elt[:methods] %>
|
349
|
+
<% end %>
|
350
|
+
```
|
351
|
+
|
352
|
+
```html
|
353
|
+
<section class="container " id="prepend">
|
354
|
+
<div class="row ">
|
355
|
+
<div class="two_span prepend_two">
|
356
|
+
Class : Enumerable<br>
|
357
|
+
Detail : 163 methods
|
358
|
+
</div>
|
359
|
+
<div class="two_span prepend_two">
|
360
|
+
Class : Array<br>
|
361
|
+
Detail : 178 methods
|
362
|
+
</div>
|
363
|
+
<div class="two_span prepend_two">
|
364
|
+
Class : String<br>
|
365
|
+
Detail : 177 methods
|
366
|
+
</div>
|
260
367
|
</div>
|
261
|
-
</
|
368
|
+
</section>
|
262
369
|
```
|
263
370
|
|
264
|
-
|
371
|
+
![css_grid prepend](https://raw.github.com/petrachi/css_grid/master/lib/assets/images/readme/prepend.png)
|
265
372
|
|
373
|
+
--
|
266
374
|
|
267
|
-
## Future ameliorations
|
268
375
|
|
269
|
-
|
270
|
-
|
376
|
+
```erb
|
377
|
+
<%= one_cols_container :disable=>:spans do %>
|
378
|
+
|
379
|
+
<%= three_span :id=>:menu do %>
|
380
|
+
Menu
|
381
|
+
<% end %>
|
382
|
+
|
383
|
+
<%= nine_span :id=>:content do %>
|
384
|
+
<%= three_cols_container :id=>"nested_container", :collection=>@large_collection do |elt| %>
|
385
|
+
Class : <%= elt[:name] %><br/>
|
386
|
+
Detail : <%= elt[:methods] %>
|
387
|
+
<% end %>
|
388
|
+
<% end %>
|
389
|
+
<% end %>
|
390
|
+
```
|
271
391
|
|
272
392
|
```html
|
273
|
-
<
|
274
|
-
<div class="
|
275
|
-
<
|
393
|
+
<section class="container ">
|
394
|
+
<div class="row ">
|
395
|
+
<div class="three_span " id="menu">Menu</div>
|
396
|
+
|
397
|
+
<div class="nine_span " id="content">
|
398
|
+
<section class="container " id="nested_container">
|
399
|
+
<div class="row nested">
|
400
|
+
<div class="three_span ">
|
401
|
+
Class : Hash<br>
|
402
|
+
Detail : 178 methods
|
403
|
+
</div>
|
404
|
+
<div class="three_span ">
|
405
|
+
Class : Set<br>
|
406
|
+
Detail : 176 methods
|
407
|
+
</div>
|
408
|
+
<div class="three_span ">
|
409
|
+
Class : Fixnum<br>
|
410
|
+
Detail : 174 methods
|
411
|
+
</div>
|
412
|
+
</div>
|
413
|
+
<div class="row nested">
|
414
|
+
<div class="three_span ">
|
415
|
+
Class : Float<br>
|
416
|
+
Detail : 174 methods
|
417
|
+
</div>
|
418
|
+
<div class="three_span ">
|
419
|
+
Class : NilClass<br>
|
420
|
+
Detail : 175 methods
|
421
|
+
</div>
|
422
|
+
<div class="three_span ">
|
423
|
+
Class : TrueClass<br>
|
424
|
+
Detail : 174 methods
|
425
|
+
</div>
|
426
|
+
</div>
|
427
|
+
</section>
|
428
|
+
</div>
|
276
429
|
</div>
|
277
|
-
|
278
|
-
|
430
|
+
</section>
|
431
|
+
```
|
432
|
+
|
433
|
+
![css_grid menu](https://raw.github.com/petrachi/css_grid/master/lib/assets/images/readme/menu.png)
|
434
|
+
|
435
|
+
--
|
436
|
+
|
437
|
+
|
438
|
+
```erb
|
439
|
+
<%= container do %>
|
440
|
+
<%= one_col_row :id=>:one_row do %>
|
441
|
+
shortcut for row + twelve_span
|
442
|
+
<% end %>
|
443
|
+
<% end %>
|
444
|
+
```
|
445
|
+
|
446
|
+
```html
|
447
|
+
<section class="container ">
|
448
|
+
<div class="row " id="one_row">
|
449
|
+
<div class="twelve_span ">shortcut for row + twelve_span</div>
|
279
450
|
</div>
|
280
|
-
</
|
451
|
+
</section>
|
281
452
|
```
|
282
453
|
|
283
|
-
|
454
|
+
![css_grid one_col_row](https://raw.github.com/petrachi/css_grid/master/lib/assets/images/readme/one_col_row.png)
|
455
|
+
|
456
|
+
--
|
457
|
+
|
458
|
+
|
284
459
|
```erb
|
285
|
-
<%=
|
286
|
-
<%=
|
287
|
-
|
460
|
+
<%= one_col_container :id=>"multi_nested", :nested=>:spans do %>
|
461
|
+
<%= four_span :id=>:menu do %>
|
462
|
+
Menu
|
463
|
+
<% end %>
|
464
|
+
|
465
|
+
<%= eight_span do %>
|
466
|
+
<%= two_col_container :collection=>@large_collection do |elt| %>
|
467
|
+
<%= two_col_container(:collection=>elt.values){ |val| val } %>
|
468
|
+
<% end %>
|
469
|
+
<% end %>
|
288
470
|
<% end %>
|
289
471
|
```
|
290
472
|
|
473
|
+
```html
|
474
|
+
<section class="container " id="multi_nested">
|
475
|
+
<div class="row ">
|
476
|
+
<div class="twelve_span ">
|
477
|
+
<div class="row nested">
|
478
|
+
<div class="four_span " id="mena">Menu</div>
|
479
|
+
|
480
|
+
<div class="eight_span ">
|
481
|
+
<section class="container ">
|
482
|
+
<div class="row nested">
|
483
|
+
<div class="four_span ">
|
484
|
+
<section class="container ">
|
485
|
+
<div class="row nested">
|
486
|
+
<div class="two_span ">Hash</div>
|
487
|
+
<div class="two_span ">178 methods</div>
|
488
|
+
</div>
|
489
|
+
</section>
|
490
|
+
</div>
|
491
|
+
<div class="four_span ">
|
492
|
+
<section class="container ">
|
493
|
+
<div class="row nested">
|
494
|
+
<div class="two_span ">Set</div>
|
495
|
+
<div class="two_span ">176 methods</div>
|
496
|
+
</div>
|
497
|
+
</section>
|
498
|
+
</div>
|
499
|
+
</div>
|
500
|
+
<div class="row nested">
|
501
|
+
<div class="four_span ">
|
502
|
+
<section class="container ">
|
503
|
+
<div class="row nested">
|
504
|
+
<div class="two_span ">Fixnum</div>
|
505
|
+
<div class="two_span ">174 methods</div>
|
506
|
+
</div>
|
507
|
+
</section>
|
508
|
+
</div>
|
509
|
+
<div class="four_span ">
|
510
|
+
<section class="container ">
|
511
|
+
<div class="row nested">
|
512
|
+
<div class="two_span ">Float</div>
|
513
|
+
<div class="two_span ">174 methods</div>
|
514
|
+
</div>
|
515
|
+
</section>
|
516
|
+
</div>
|
517
|
+
</div>
|
518
|
+
<div class="row nested">
|
519
|
+
<div class="four_span ">
|
520
|
+
<section class="container ">
|
521
|
+
<div class="row nested">
|
522
|
+
<div class="two_span ">NilClass</div>
|
523
|
+
<div class="two_span ">175 methods</div>
|
524
|
+
</div>
|
525
|
+
</section>
|
526
|
+
</div>
|
527
|
+
<div class="four_span ">
|
528
|
+
<section class="container ">
|
529
|
+
<div class="row nested">
|
530
|
+
<div class="two_span ">TrueClass</div>
|
531
|
+
<div class="two_span ">174 methods</div>
|
532
|
+
</div>
|
533
|
+
</section>
|
534
|
+
</div>
|
535
|
+
</div>
|
536
|
+
</section>
|
537
|
+
</div>
|
538
|
+
</div>
|
539
|
+
</div>
|
540
|
+
</div>
|
541
|
+
</section>
|
542
|
+
```
|
543
|
+
|
544
|
+
![css_grid multi_nested](https://raw.github.com/petrachi/css_grid/master/lib/assets/images/readme/multi_nested.png)
|
545
|
+
|
546
|
+
--
|
547
|
+
|
548
|
+
## To Do
|
549
|
+
|
550
|
+
I made a constant to personalize created elements to fit a different grid stylesheet.
|
551
|
+
Today this variable looks like this
|
552
|
+
```ruby
|
553
|
+
GRID_CONFIG = { :classes => { :container => :container,
|
554
|
+
:row => :row, :nested => :nested,
|
555
|
+
:prepend => :prepend, :append => :append,
|
556
|
+
:one_span => :one_span, :two_span => :two_span, :three_span => :three_span, :four_span => :four_span,
|
557
|
+
:five_span => :five_span, :six_span => :six_span, :seven_span => :seven_span, :eight_span => :eight_span,
|
558
|
+
:nine_span => :nine_span, :ten_span => :ten_span, :eleven_span => :eleven_span, :twelve_span => :twelve_span },
|
559
|
+
:elements => {:container => :section,
|
560
|
+
:row => :div,
|
561
|
+
:one_span => :div, :two_span => :div, :three_span => :div, :four_span => :div,
|
562
|
+
:five_span => :div, :six_span => :div, :seven_span => :div, :eight_span => :div,
|
563
|
+
:nine_span => :div, :ten_span => :div, :eleven_span => :div, :twelve_span => :div}
|
564
|
+
}
|
565
|
+
```
|
566
|
+
|
567
|
+
Need to test it with the most commons versions of grid stylesheets (twitter bootstrap for example) and provide correct config variable.
|
568
|
+
|
291
569
|
## Contributing
|
292
570
|
|
293
571
|
1. Fork it
|
data/css_grid.gemspec
CHANGED
data/lib/assets/.DS_Store
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,20 +1,20 @@
|
|
1
|
+
$gutter_width: 1.041666666666;
|
2
|
+
|
1
3
|
@mixin span($full, $col_num) {
|
2
|
-
width: (($col_num / 12) * 100 -
|
3
|
-
margin: 0 (
|
4
|
+
width: (($col_num / 12) * 100 - $gutter_width * 2) / 100 * $full;
|
5
|
+
margin: 0 ($gutter_width / 100 * $full);
|
4
6
|
float: left; min-height: 1px;
|
5
7
|
}
|
6
8
|
|
7
|
-
@mixin prepend($full, $col_num) { margin-left: (($col_num / 12) * 100 -
|
8
|
-
@mixin append($full, $col_num) { margin-right: (($col_num / 12) * 100 -
|
9
|
-
|
10
|
-
@mixin nested($grid_width){ margin: 0 (-1.74 / 100 * $grid_width); min-width: 0; }
|
9
|
+
@mixin prepend($full, $col_num) { margin-left: (($col_num / 12) * 100 - $gutter_width * 2) / 100 * $full + ($gutter_width * 3 / 100 * $full); }
|
10
|
+
@mixin append($full, $col_num) { margin-right: (($col_num / 12) * 100 - $gutter_width * 2) / 100 * $full + ($gutter_width * 3 / 100 * $full); }
|
11
11
|
|
12
12
|
@mixin grid($grid_width){
|
13
13
|
.container {
|
14
14
|
.row {
|
15
15
|
width: $grid_width; margin: 0 auto; overflow: hidden;
|
16
16
|
|
17
|
-
&.nested{ margin: 0 (
|
17
|
+
&.nested{ margin: 0 (-$gutter_width / 100 * $grid_width); min-width: 0; width: auto; }
|
18
18
|
|
19
19
|
.one_span { @include span($grid_width, 1); } /* 55px */
|
20
20
|
.two_span { @include span($grid_width, 2); } /* 150px */
|
@@ -58,28 +58,28 @@
|
|
58
58
|
}
|
59
59
|
}
|
60
60
|
|
61
|
-
|
61
|
+
/* Screens 1151px to Infinite */
|
62
62
|
@media all {
|
63
|
-
@include grid(
|
64
|
-
|
63
|
+
@include grid(1152px);
|
64
|
+
|
65
65
|
.container {
|
66
66
|
img, object, embed { max-width: 100%; }
|
67
67
|
img { height: auto; }
|
68
68
|
}
|
69
69
|
}
|
70
|
-
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
|
72
|
+
/* Screens 960px to 1151px */
|
73
|
+
@media only screen and (max-width: 1151px) {
|
74
|
+
@include grid(960px);
|
75
75
|
}
|
76
76
|
|
77
77
|
|
78
|
-
/* Screens 768px to
|
79
|
-
@media only screen and (max-width:
|
78
|
+
/* Screens 768px to 959px */
|
79
|
+
@media only screen and (max-width: 959px) {
|
80
80
|
body { font-size: 0.8em; line-height: 1.5em; }
|
81
|
-
|
82
|
-
@include grid(
|
81
|
+
|
82
|
+
@include grid(768px);
|
83
83
|
}
|
84
84
|
|
85
85
|
|
data/lib/css_grid/version.rb
CHANGED
data/lib/css_grid.rb
CHANGED
@@ -7,8 +7,8 @@ module GridHelper
|
|
7
7
|
TWELVE_STRING_INTS_INVERT = TWELVE_STRING_INTS.invert
|
8
8
|
|
9
9
|
|
10
|
-
GRID_CONFIG
|
11
|
-
|
10
|
+
GRID_CONFIG ||= { :classes => Hash.new{ |hash, key| hash[key] = key },
|
11
|
+
:elements => Hash.new(:div).merge(:container => :section) }
|
12
12
|
|
13
13
|
def initialize *args
|
14
14
|
@nested_stack = []
|
@@ -111,13 +111,14 @@ module GridHelper
|
|
111
111
|
cols_container :one, options.merge(:disable=>:container, :rows=>{:id=>options.delete(:id), :class=>options.delete(:class)}), &block
|
112
112
|
end
|
113
113
|
|
114
|
+
TWELVE_FOR_REGEXP = TWELVE_STRING_INTS.keys.join '|'
|
114
115
|
def method_missing method_name, *args, &block
|
115
116
|
case method_name.to_sym
|
116
|
-
when /^(container|row|(
|
117
|
+
when /^(container|row|(#{ TWELVE_FOR_REGEXP })_span)$/
|
117
118
|
self.grid($1.to_sym, *args, &block)
|
118
|
-
when /^(
|
119
|
+
when /^(#{ TWELVE_FOR_REGEXP })_cols?_container$/
|
119
120
|
self.cols_container($1.to_sym, *args, &block)
|
120
|
-
when /^(
|
121
|
+
when /^(#{ TWELVE_FOR_REGEXP })_spans?_container$/
|
121
122
|
self.spans_container($1.to_sym, *args, &block)
|
122
123
|
else super
|
123
124
|
end
|
@@ -125,9 +126,9 @@ module GridHelper
|
|
125
126
|
|
126
127
|
def respond_to? method_name, include_private = false
|
127
128
|
case method_name.to_s
|
128
|
-
when /^(container|row|(
|
129
|
-
/^(
|
130
|
-
/^(
|
129
|
+
when /^(container|row|(#{ TWELVE_FOR_REGEXP })_span)$/,
|
130
|
+
/^(#{ TWELVE_FOR_REGEXP })_cols?_container$/,
|
131
|
+
/^(#{ TWELVE_FOR_REGEXP })_spans?_container$/
|
131
132
|
true
|
132
133
|
else super
|
133
134
|
end
|
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.
|
4
|
+
version: 2.2.0
|
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-
|
12
|
+
date: 2012-11-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -27,22 +27,6 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.1.0
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: hash_extend
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
30
|
description: Provide CSS grid stylesheet and CSS grid helpers
|
47
31
|
email:
|
48
32
|
- thomas.petrachi@vodeclic.com
|
@@ -60,6 +44,15 @@ files:
|
|
60
44
|
- css_grid.gemspec
|
61
45
|
- lib/.DS_Store
|
62
46
|
- lib/assets/.DS_Store
|
47
|
+
- lib/assets/images/.DS_Store
|
48
|
+
- lib/assets/images/readme/.DS_Store
|
49
|
+
- lib/assets/images/readme/disable.png
|
50
|
+
- lib/assets/images/readme/menu.png
|
51
|
+
- lib/assets/images/readme/multi_nested.png
|
52
|
+
- lib/assets/images/readme/nested.png
|
53
|
+
- lib/assets/images/readme/normal.png
|
54
|
+
- lib/assets/images/readme/one_col_row.png
|
55
|
+
- lib/assets/images/readme/prepend.png
|
63
56
|
- lib/assets/stylesheets/.DS_Store
|
64
57
|
- lib/assets/stylesheets/grid.css.scss
|
65
58
|
- lib/css_grid.rb
|
@@ -79,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
72
|
version: '0'
|
80
73
|
segments:
|
81
74
|
- 0
|
82
|
-
hash:
|
75
|
+
hash: 1495507729281846591
|
83
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
77
|
none: false
|
85
78
|
requirements:
|
@@ -88,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
81
|
version: '0'
|
89
82
|
segments:
|
90
83
|
- 0
|
91
|
-
hash:
|
84
|
+
hash: 1495507729281846591
|
92
85
|
requirements: []
|
93
86
|
rubyforge_project:
|
94
87
|
rubygems_version: 1.8.24
|