r_kit 0.1.3.1 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWNhOTY5MmMxODU4MWY3MWYwZGQyY2Q0ZjU2ZjZiMzQwYjMyMmE2Mw==
4
+ NWE5MzgxZWIwOWFhYzk0MmYwYTgxMzdiYjZhZTZlYmI4OTljOTQxMQ==
5
5
  data.tar.gz: !binary |-
6
- N2ZhYWI5OWQzYjIyNjczYjg2NWMxYWQ4NjEwZDJiYWZmNTIxNDYwZA==
6
+ ZjMwOWU0ZGFkYmYyZjZlYjk3ZGVmNTllNTA3ZjQxNTEwZGQ1MDU5NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDNjMTIxZWNjZjEzNTc5Y2ZjYWJiMTVlNzAxYzAwOWY0YzExMTFkNThmZjE3
10
- YzJmODhkNWY3MjA3ZWU1MTg2NTZmOTM1MzRjMWVmNjEyYWFhNTQwMTQ4ZWM3
11
- ODI0NDAzMmUyODIyMmYyYzBiYzg3NDRjMDMyN2I1YmRkYjFhYTk=
9
+ NmNhYmQwNjcwZTNiMDY4YTc3ODgxZGVmMDZlZWFhZjgwZmRkZjE4N2NkMmM0
10
+ NzdhMDk0MTQxNzE2YWM4NjI4NTZjNzY5ODljM2UxZmQ1Zjk1OTFmOTNjMzcz
11
+ Y2RkNGI2MjBhODgyMTQzYzkyMTdhZjk2NTc3ZWZjNmMzMDBkYjk=
12
12
  data.tar.gz: !binary |-
13
- MDA5OGExOTVkYWNkNjA4ZmIxMDY3NDYyODRkMTkyNDM0NGU0YTQxNGY3MWJl
14
- OWM0NzRlNmJiYTk5ODE2NWQ4Y2ZhMjBhZmYxZTgyZTc1MzBjNzhlMjJkM2Nj
15
- NmQ0M2QzZGU1MmVhM2QyYTg3ZDI4ZWFlMjJiNjQ0N2UxMDFiNzg=
13
+ NmE1NDMyM2FkMDlmZWZhN2FkOGRmYWQxNjlmY2UzZTQxYTI5OWI0YmEyZWY2
14
+ NzdmMmE3ZmFhOWJiNWUwOWQyZjdhNzA5MGMxNmE0ZWY3MWQ4MjU4ZjBiYTE2
15
+ YmI0NzQ5MzhiYjJhOTM1ZTc1ZjZiNjdlZGRhYmQwZmZmMDY1MDg=
@@ -0,0 +1,32 @@
1
+ @mixin col($base_width, $col_size){
2
+ margin: 0 $base_width;
3
+ width: $base_width * 8 * $col_size - 2 * $base_width;
4
+ flex-shrink: 0;
5
+ }
6
+
7
+ @mixin off($base_width, $off_size){
8
+ margin-left: $base_width * 8 * $off_size + 1 * $base_width;
9
+ }
10
+
11
+ @mixin grid($base_width: 12px){
12
+
13
+ .container{
14
+ margin: auto;
15
+ width: $base_width * 8 * 12 - 2 * $base_width;
16
+
17
+ .row{
18
+ display: flex;
19
+ flex-wrap: wrap;
20
+ align-items: baseline;
21
+
22
+ margin: 0 -#{$base_width};
23
+
24
+ @for $i from 1 through 12 {
25
+ .col-#{$i} { @include col($base_width, $i); }
26
+ .off-#{$i} { @include off($base_width, $i); }
27
+ }
28
+ }
29
+ }
30
+ }
31
+
32
+ @include grid();
@@ -1 +1,2 @@
1
- @import "components/btn";
1
+ @import "components/btn";
2
+ @import "components/grid";
@@ -0,0 +1,82 @@
1
+ module RKit::Grid::ActionViewExtension
2
+ def proc_options instance, options = {}
3
+ (options[:proc_options] || []).each do |key, proc|
4
+ options[key] = proc.call(instance)
5
+ end
6
+ end
7
+
8
+ def html_options options = {}, defaults = {}
9
+ id = options[:id]
10
+ classes = "#{ defaults[:class] } #{ options[:class] }"
11
+ classes += " off-#{ options[:offset] }" if options[:offset]
12
+
13
+ {
14
+ :id => id,
15
+ :class => classes
16
+ }
17
+ end
18
+
19
+
20
+ def container_tag options = {}, &block
21
+ html_options = html_options(options, {class: :container})
22
+ content_tag options[:tag] || :div, html_options, &block
23
+ end
24
+
25
+ def row_tag options = {}, &block
26
+ html_options = html_options(options, {class: :row})
27
+ content_tag options[:tag] || :div, html_options, &block
28
+ end
29
+
30
+ def col_tag options = {}, &block
31
+ proc_options options[:instance], options
32
+ html_options = html_options(options, {class: "col-#{ options[:col_size] }"})
33
+
34
+ content_tag(options[:tag] || :div, html_options){ block.call(options[:instance]) }
35
+ end
36
+
37
+
38
+ def col__tag col_size, options = {}, &block
39
+ col_tag options.merge(col_size: col_size), &block
40
+ end
41
+
42
+ def row__tag col_size, collection, options = {}, &block
43
+ col_options = options[:cols] || {}
44
+
45
+ cols_buffer = collection.inject ActiveSupport::SafeBuffer.new do |safe_buffer, instance|
46
+ safe_buffer.safe_concat send("col_#{ col_size }_tag", col_options.merge(instance: instance), &block)
47
+ end
48
+
49
+ row_tag(options){ cols_buffer }
50
+ end
51
+
52
+ def rows__tag col_size, collection, options = {}, &block
53
+ rows_buffer = collection
54
+ .in_groups_of(12 / col_size, false)
55
+ .inject ActiveSupport::SafeBuffer.new do |safe_buffer, collection|
56
+ safe_buffer.safe_concat send("row_#{ col_size }_tag", collection, options, &block)
57
+ end
58
+ end
59
+
60
+ def container__tag col_size, collection, options = {}, &block
61
+ row_options = options.delete(:rows) || {}
62
+ container_tag(options){ send("rows_#{ col_size}_tag", collection, row_options, &block) }
63
+ end
64
+
65
+ 1.upto 12 do |col_size|
66
+ define_method "col_#{ col_size }_tag" do |options = {}, &block|
67
+ col__tag col_size, options, &block
68
+ end
69
+
70
+ define_method "row_#{ col_size }_tag" do |collection, options = {}, &block|
71
+ row__tag col_size, collection, options, &block
72
+ end
73
+
74
+ define_method "rows_#{ col_size }_tag" do |collection, options = {}, &block|
75
+ rows__tag col_size, collection, options, &block
76
+ end
77
+
78
+ define_method "container_#{ col_size }_tag" do |collection, options = {}, &block|
79
+ container__tag col_size, collection, options, &block
80
+ end
81
+ end
82
+ end
data/lib/r_kit/grid.rb ADDED
@@ -0,0 +1,5 @@
1
+ module RKit::Grid
2
+ require "r_kit/grid/action_view_extension"
3
+
4
+ ActionView::Base.send :include, ActionViewExtension
5
+ end
data/lib/r_kit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RKit
2
- VERSION = "0.1.3.1"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/r_kit.rb CHANGED
@@ -3,4 +3,5 @@ require "r_kit/engine"
3
3
 
4
4
  module RKit
5
5
  require "r_kit/decorator"
6
+ require "r_kit/grid"
6
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Petrachi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-28 00:00:00.000000000 Z
11
+ date: 2014-01-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Library for rails projects
14
14
  email:
@@ -32,6 +32,7 @@ files:
32
32
  - lib/assets/stylesheets/r_kit/animations/fast_load.scss
33
33
  - lib/assets/stylesheets/r_kit/components.scss
34
34
  - lib/assets/stylesheets/r_kit/components/btn.scss
35
+ - lib/assets/stylesheets/r_kit/components/grid.scss
35
36
  - lib/assets/stylesheets/r_kit/css.scss
36
37
  - lib/assets/stylesheets/r_kit/css/alignments.scss
37
38
  - lib/assets/stylesheets/r_kit/css/displays.scss
@@ -52,6 +53,8 @@ files:
52
53
  - lib/r_kit/decorator/active_record_extension.rb
53
54
  - lib/r_kit/decorator/base.rb
54
55
  - lib/r_kit/engine.rb
56
+ - lib/r_kit/grid.rb
57
+ - lib/r_kit/grid/action_view_extension.rb
55
58
  - lib/r_kit/version.rb
56
59
  - r_kit.gemspec
57
60
  homepage: https://github.com/petrachi/r_kit