ui_bibz 0.9.0

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.
Files changed (140) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +44 -0
  3. data/.travis.yml +13 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +171 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +728 -0
  8. data/README.rdoc +0 -0
  9. data/Rakefile +34 -0
  10. data/config/locales/en.yml +14 -0
  11. data/config/locales/fr.yml +14 -0
  12. data/doc/images/alert.png +0 -0
  13. data/doc/images/breadcrumb.png +0 -0
  14. data/doc/images/button.png +0 -0
  15. data/doc/images/button_dropdown.png +0 -0
  16. data/doc/images/button_group.png +0 -0
  17. data/doc/images/button_link.png +0 -0
  18. data/doc/images/button_split_dropdown.png +0 -0
  19. data/doc/images/glyph.png +0 -0
  20. data/doc/images/list.png +0 -0
  21. data/doc/images/nav.png +0 -0
  22. data/doc/images/panel.png +0 -0
  23. data/doc/images/table.png +0 -0
  24. data/doc/images/table_pagination_per_page.png +0 -0
  25. data/doc/images/table_panel.png +0 -0
  26. data/doc/images/table_search_field.png +0 -0
  27. data/doc/images/ui-bibz-logo-without-border.gif +0 -0
  28. data/doc/images/ui-bibz-logo.gif +0 -0
  29. data/lib/tasks/ui_bibz_tasks.rake +4 -0
  30. data/lib/ui_bibz/concerns/models/searchable.rb +93 -0
  31. data/lib/ui_bibz/helpers/meta_helper.rb +27 -0
  32. data/lib/ui_bibz/helpers/ui_helper.rb +108 -0
  33. data/lib/ui_bibz/helpers/utils_helper.rb +9 -0
  34. data/lib/ui_bibz/rails/engine.rb +39 -0
  35. data/lib/ui_bibz/ui/alert.rb +67 -0
  36. data/lib/ui_bibz/ui/breadcrumb/breadcrumb.rb +54 -0
  37. data/lib/ui_bibz/ui/breadcrumb/components/breadcrumb_link.rb +62 -0
  38. data/lib/ui_bibz/ui/button/button.rb +65 -0
  39. data/lib/ui_bibz/ui/button/button_dropdown.rb +56 -0
  40. data/lib/ui_bibz/ui/button/button_group.rb +62 -0
  41. data/lib/ui_bibz/ui/button/button_link.rb +66 -0
  42. data/lib/ui_bibz/ui/button/button_split_dropdown.rb +80 -0
  43. data/lib/ui_bibz/ui/component.rb +137 -0
  44. data/lib/ui_bibz/ui/dropdown/components/dropdown_list.rb +73 -0
  45. data/lib/ui_bibz/ui/dropdown/dropdown.rb +101 -0
  46. data/lib/ui_bibz/ui/glyph.rb +92 -0
  47. data/lib/ui_bibz/ui/grid/components/col.rb +74 -0
  48. data/lib/ui_bibz/ui/grid/components/row.rb +32 -0
  49. data/lib/ui_bibz/ui/grid/grid.rb +108 -0
  50. data/lib/ui_bibz/ui/jumbotron.rb +58 -0
  51. data/lib/ui_bibz/ui/label.rb +58 -0
  52. data/lib/ui_bibz/ui/list/components/list.rb +105 -0
  53. data/lib/ui_bibz/ui/list/list_group.rb +78 -0
  54. data/lib/ui_bibz/ui/nav/components/nav_link.rb +68 -0
  55. data/lib/ui_bibz/ui/nav/nav.rb +65 -0
  56. data/lib/ui_bibz/ui/panel.rb +101 -0
  57. data/lib/ui_bibz/ui/table/components/actions.rb +44 -0
  58. data/lib/ui_bibz/ui/table/components/column.rb +34 -0
  59. data/lib/ui_bibz/ui/table/components/columns.rb +16 -0
  60. data/lib/ui_bibz/ui/table/components/store.rb +67 -0
  61. data/lib/ui_bibz/ui/table/components/table_action.rb +21 -0
  62. data/lib/ui_bibz/ui/table/table.rb +146 -0
  63. data/lib/ui_bibz/ui/table/table_pagination.rb +29 -0
  64. data/lib/ui_bibz/ui/table/table_pagination_per_page.rb +53 -0
  65. data/lib/ui_bibz/ui/table/table_panel.rb +66 -0
  66. data/lib/ui_bibz/ui/table/table_search_field.rb +62 -0
  67. data/lib/ui_bibz/ui/table/ux/actionable.rb +59 -0
  68. data/lib/ui_bibz/ui/table/ux/paginable.rb +35 -0
  69. data/lib/ui_bibz/ui/table/ux/searchable.rb +47 -0
  70. data/lib/ui_bibz/ui/table/ux/sortable.rb +93 -0
  71. data/lib/ui_bibz/ui/ui.rb +14 -0
  72. data/lib/ui_bibz/utils/internationalization.rb +30 -0
  73. data/lib/ui_bibz/version.rb +3 -0
  74. data/lib/ui_bibz.rb +60 -0
  75. data/test/dummy/README.rdoc +28 -0
  76. data/test/dummy/Rakefile +6 -0
  77. data/test/dummy/app/assets/images/.keep +0 -0
  78. data/test/dummy/app/assets/javascripts/application.js +13 -0
  79. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  80. data/test/dummy/app/controllers/application_controller.rb +5 -0
  81. data/test/dummy/app/controllers/concerns/.keep +0 -0
  82. data/test/dummy/app/helpers/application_helper.rb +2 -0
  83. data/test/dummy/app/mailers/.keep +0 -0
  84. data/test/dummy/app/models/.keep +0 -0
  85. data/test/dummy/app/models/concerns/.keep +0 -0
  86. data/test/dummy/app/models/user.rb +5 -0
  87. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  88. data/test/dummy/bin/bundle +3 -0
  89. data/test/dummy/bin/rails +4 -0
  90. data/test/dummy/bin/rake +4 -0
  91. data/test/dummy/bin/setup +29 -0
  92. data/test/dummy/config/application.rb +26 -0
  93. data/test/dummy/config/boot.rb +5 -0
  94. data/test/dummy/config/database.yml +25 -0
  95. data/test/dummy/config/environment.rb +5 -0
  96. data/test/dummy/config/environments/development.rb +41 -0
  97. data/test/dummy/config/environments/production.rb +79 -0
  98. data/test/dummy/config/environments/test.rb +42 -0
  99. data/test/dummy/config/initializers/assets.rb +11 -0
  100. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  101. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  102. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  103. data/test/dummy/config/initializers/inflections.rb +16 -0
  104. data/test/dummy/config/initializers/mime_types.rb +4 -0
  105. data/test/dummy/config/initializers/session_store.rb +3 -0
  106. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  107. data/test/dummy/config/locales/en.yml +23 -0
  108. data/test/dummy/config/routes.rb +57 -0
  109. data/test/dummy/config/secrets.yml +22 -0
  110. data/test/dummy/config.ru +4 -0
  111. data/test/dummy/db/migrate/20150123191721_user.rb +4 -0
  112. data/test/dummy/db/migrate/20150123191805_create_users.rb +12 -0
  113. data/test/dummy/db/schema.rb +25 -0
  114. data/test/dummy/lib/assets/.keep +0 -0
  115. data/test/dummy/log/.keep +0 -0
  116. data/test/dummy/public/404.html +67 -0
  117. data/test/dummy/public/422.html +67 -0
  118. data/test/dummy/public/500.html +66 -0
  119. data/test/dummy/public/favicon.ico +0 -0
  120. data/test/dummy/test/fixtures/users.yml +13 -0
  121. data/test/dummy/test/models/user_test.rb +7 -0
  122. data/test/factories/user.rb +8 -0
  123. data/test/store_test.rb +46 -0
  124. data/test/support/factory_girl.rb +6 -0
  125. data/test/test_helper.rb +23 -0
  126. data/test/ui/button_test.rb +56 -0
  127. data/test/ui/component_test.rb +21 -0
  128. data/test/ui/dropdown_test.rb +18 -0
  129. data/test/ui/glyph_test.rb +23 -0
  130. data/test/ui/grid_test.rb +46 -0
  131. data/test/ui/list_group_test.rb +28 -0
  132. data/test/ui/nav_test.rb +27 -0
  133. data/test/ui/panel_test.rb +52 -0
  134. data/test/ui/table_test.rb +178 -0
  135. data/test/ui_bibz_test.rb +13 -0
  136. data/test/ui_helper_test.rb +44 -0
  137. data/ui_bibz.gemspec +36 -0
  138. data/vendor/assets/javascripts/ui_bibz.js.coffee +24 -0
  139. data/vendor/assets/stylesheets/ui_bibz.sass +46 -0
  140. metadata +398 -0
@@ -0,0 +1,74 @@
1
+ module UiBibz::Ui
2
+
3
+ # Create a col
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ # * +num+ - Integer | 0..12
18
+ # * +offset+ - Integer
19
+ # * +size+ - Integer
20
+ #
21
+ # ==== Signatures
22
+ #
23
+ # UiBibz::Ui::Col.new(content, options = {}, html_options = {}).render
24
+ #
25
+ # UiBibz::Ui::Col.new(options = {}, html_options = {}) do
26
+ # content
27
+ # end.render
28
+ #
29
+ # ==== Examples
30
+ #
31
+ # UiBibz::Ui::Col.new({num: 2, offset: 1, size: 3}, class: 'test') do
32
+ # #content
33
+ # end
34
+ #
35
+ # UiBibz::Ui::Col.new([{num: 2, offset: 1, size: 3}, { num: 3}], class: 'test') do
36
+ # #content
37
+ # end
38
+ #
39
+ class Col < Component
40
+
41
+ def initialize content = nil, options = nil, html_options = nil, &block
42
+ super
43
+ @cols = []
44
+ end
45
+
46
+ def render
47
+ content_tag :div, @content, class_and_html_options(col_classes)
48
+ end
49
+
50
+ private
51
+
52
+ def col_classes
53
+ classes = []
54
+ [@options].flatten.each do |col|
55
+ classes << add_classes("col-#{ size(col) }-#{ num(col) }", offset(col))
56
+ end
57
+ @options = {}
58
+ classes.join(' ')
59
+ end
60
+
61
+ def size col
62
+ col[:size] || :md
63
+ end
64
+
65
+ def num col
66
+ col[:num] || 1
67
+ end
68
+
69
+ def offset col
70
+ "col-offset-#{ col[:offset] }" if col[:offset]
71
+ end
72
+
73
+ end
74
+ end
@@ -0,0 +1,32 @@
1
+ module UiBibz::Ui
2
+
3
+ # Create a row
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Signatures
14
+ #
15
+ # UiBibz::Ui::Row.new(content, options = {}, html_options = {})
16
+ #
17
+ # UiBibz::Ui::Row.new(options = {}, html_options = {}) do
18
+ # #content
19
+ # end
20
+ #
21
+ class Row < Component
22
+
23
+ def initialize content = nil, options = nil, html_options = nil, &block
24
+ super
25
+ end
26
+
27
+ def render
28
+ content_tag :div, @content, class_and_html_options('row')
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,108 @@
1
+ module UiBibz::Ui
2
+
3
+ # Create a Grid
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ #
18
+ # ==== Signatures
19
+ #
20
+ # UiBibz::Ui::Grid.new().tap do |g|
21
+ # ...
22
+ # g.view content = nil, options = nil, html_options = nil, &block
23
+ # ...
24
+ # end
25
+ #
26
+ # ==== Exemples
27
+ #
28
+ # UiBibz::Ui::Grid.new().tap do |g|
29
+ # g.view num: 5, position: :left do
30
+ # 'left'
31
+ # end
32
+ # g.view position: :right do
33
+ # 'right'
34
+ # end
35
+ # g.view({ position: :top}, { class: 'success'}) do
36
+ # 'top'
37
+ # end
38
+ # g.view position: :center do
39
+ # 'center'
40
+ # end
41
+ # g.view position: :bottom do
42
+ # 'bottom'
43
+ # end
44
+ # end.render
45
+ #
46
+ class Grid < Component
47
+
48
+ COL_NUM = 12
49
+
50
+ def initialize content = nil, options = nil, html_options = nil, &block
51
+ super
52
+ @views = {}
53
+ end
54
+
55
+ def view content = nil, options = nil, html_options = nil, &block
56
+ o = content.kind_of?(Hash) ? content : options
57
+ c = UiBibz::Ui::Component.new content, options, html_options, &block
58
+ h = Hash[o[:position], { component: c, num: o[:num]}]
59
+ @views = @views.merge(h)
60
+ end
61
+
62
+ def render
63
+ define_col_nums
64
+ UiBibz::Ui::Row.new(class: 'grid') do
65
+ # top
66
+ concat top_view unless @views[:top].nil?
67
+ # left
68
+ concat left_view unless @views[:left].nil?
69
+ # center
70
+ concat center_view unless @views[:center].nil?
71
+ # right
72
+ concat right_view unless @views[:right].nil?
73
+ # bottom
74
+ concat bottom_view unless @views[:bottom].nil?
75
+ end.render
76
+ end
77
+
78
+ def view_by_num c, num, item_class
79
+ UiBibz::Ui::Col.new(c.content, c.options.merge({ num: num }), c.class_and_html_options(['col', item_class])).render
80
+ end
81
+
82
+ def top_view
83
+ view_by_num @views[:top][:component], COL_NUM, 'grid-top'
84
+ end
85
+
86
+ def bottom_view
87
+ view_by_num @views[:bottom][:component], COL_NUM, 'grid-bottom'
88
+ end
89
+
90
+ def left_view
91
+ view_by_num @views[:left][:component], @left_val, 'grid-left'
92
+ end
93
+
94
+ def center_view
95
+ view_by_num @views[:center][:component], COL_NUM-@left_val-@right_val, 'grid-center'
96
+ end
97
+
98
+ def right_view
99
+ view_by_num @views[:right][:component], @right_val, 'grid-right'
100
+ end
101
+
102
+ def define_col_nums
103
+ @left_val = @views[:left].nil? ? 0 : (@views[:left][:num] || 1)
104
+ @right_val = @views[:right].nil? ? 0 : (@views[:right][:num] || 1)
105
+ end
106
+
107
+ end
108
+ end
@@ -0,0 +1,58 @@
1
+ module UiBibz::Ui
2
+
3
+ # Create a jumbotron
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ # * +full_with+ - Boolean to render jumbotron in fullscreen
18
+ #
19
+ # ==== Signatures
20
+ #
21
+ # UiBibz::Ui::Jumbotron.new(content, options = nil, html_options = nil)
22
+ #
23
+ # UiBibz::Ui::Jumbotron.new(options = nil, html_options = nil) do
24
+ # content
25
+ # end
26
+ #
27
+ # ==== Examples
28
+ #
29
+ # UiBibz::Ui::Jumbotron.new(content, full_width: true).render
30
+ #
31
+ # UiBibz::Ui::Jumbotron.new() do
32
+ # #content
33
+ # end.render
34
+ #
35
+ class Jumbotron < Component
36
+
37
+ def initialize content = nil, options = nil, html_options = nil, &block
38
+ super
39
+ end
40
+
41
+ def render
42
+ content_tag :div, class_and_html_options('jumbotron') do
43
+ if full_width
44
+ content_tag :div, @content, class: 'container'
45
+ else
46
+ @content
47
+ end
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def full_width
54
+ @options[:full_width]
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,58 @@
1
+ module UiBibz::Ui
2
+
3
+ # Create a label
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ # * +state+ - State of élement with symbol value:
18
+ # (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
19
+ # * +glyph+ - Add glyph with name or hash options
20
+ # * +name+ - String
21
+ # * +size+ - Integer
22
+ # * +type+ - Symbol
23
+ #
24
+ # ==== Signatures
25
+ #
26
+ # UiBibz::Ui::Label.new(content, options = nil, html_options = nil)
27
+ #
28
+ # UiBibz::Ui::Label.new(options = nil, html_options = nil) do
29
+ # content
30
+ # end
31
+ #
32
+ # ==== Examples
33
+ #
34
+ # UiBibz::Ui::Label.new(content, type: :success).render
35
+ #
36
+ # UiBibz::Ui::Label.new() do
37
+ # #content
38
+ # end.render
39
+ #
40
+ class Label < Component
41
+
42
+ def initialize content = nil, options = nil, html_options = nil, &block
43
+ super
44
+ end
45
+
46
+ def render
47
+ content_tag :span, glyph_and_content_html, class_and_html_options('label')
48
+ end
49
+
50
+ private
51
+
52
+ def state
53
+ sym = @options[:state] || :default
54
+ "label-#{ states[sym] }"
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,105 @@
1
+ module UiBibz::Ui
2
+
3
+ # Create a list
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ # * +status+ - State of élement with symbol value:
18
+ # (+:active+, +:disable+)
19
+ # * +url+
20
+ # * +tap+ - Boolean to add header and body
21
+ # * +state+ - State of élement with symbol value:
22
+ # (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
23
+ # * +glyph+ - Add glyph with name or hash options
24
+ # * +name+ - String
25
+ # * +size+ - Integer
26
+ # * +type+ - Symbol
27
+ #
28
+ # ==== Signatures
29
+ #
30
+ # UiBibz::Ui::List.new(tap: true) do |l|
31
+ # l.header content = nil, options = nil, html_options = nil, &block
32
+ # l.body content = nil, options = nil, html_options = nil, &block
33
+ # end
34
+ #
35
+ # UiBibz::Ui::List.new content, options = nil, html_options = nil
36
+ #
37
+ # UiBibz::Ui::List.new options = nil, html_options = nil do
38
+ # content
39
+ # end
40
+ #
41
+ # ==== Examples
42
+ #
43
+ # UiBibz::Ui::List.new('Test', state: :success, url: '#test').render
44
+ #
45
+ # UiBibz::Ui::List.new(state: :primary) do
46
+ # 'Test 2'
47
+ # end.render
48
+ #
49
+ # UiBibz::Ui::List.new(tap: true, status: :active) do |l|
50
+ # l.header 'My title', nil, class: 'my-title'
51
+ # l.body do
52
+ # 'My content'
53
+ # end
54
+ # end.render
55
+ #
56
+ class List < Component
57
+
58
+ def initialize content = nil, options = nil, html_options = nil, &block
59
+ super
60
+ end
61
+
62
+ def render
63
+ content_tag tag, class_and_html_options('list-group-item') do
64
+ concat glyph_and_content_html if @content
65
+ concat header_html if @body
66
+ concat body_html if @body
67
+ concat badge_html if @options[:badge]
68
+ end
69
+ end
70
+
71
+ def header content = nil, options = nil, html_options = nil, &block
72
+ @header = Component.new content, options, html_options, &block
73
+ end
74
+
75
+ def body content = nil, options = nil, html_options = nil, &block
76
+ @body = Component.new content, options, html_options, &block
77
+ end
78
+
79
+ private
80
+
81
+ def header_html
82
+ content_tag :h4, @header.render, @header.class_and_html_options('list-group-item-heading')
83
+ end
84
+
85
+ def body_html
86
+ content_tag :p, @body.render, @body.class_and_html_options('list-group-item-text')
87
+ end
88
+
89
+ def tag
90
+ is_link_type? ? :a : :li
91
+ end
92
+
93
+ def is_link_type?
94
+ @html_options[:href] = @options[:url] if @options[:url]
95
+ @options[:type] == :link || @html_options[:type] == :link
96
+ end
97
+
98
+ def state
99
+ unless @options[:state].nil?
100
+ "list-group-item-#{ states[@options[:state]] }"
101
+ end
102
+ end
103
+
104
+ end
105
+ end
@@ -0,0 +1,78 @@
1
+ require "ui_bibz/ui/list/components/list"
2
+ module UiBibz::Ui
3
+
4
+ # Create a list group
5
+ #
6
+ # This element is an extend of UiBibz::Ui::Component.
7
+ #
8
+ # ==== Attributes
9
+ #
10
+ # * +content+ - Content of element
11
+ # * +options+ - Options of element
12
+ # * +html_options+ - Html Options of element
13
+ #
14
+ # ==== Options
15
+ #
16
+ # You can add HTML attributes using the +html_options+.
17
+ # You can pass arguments in options attribute:
18
+ # * +type+ - Type of list (default: :list)
19
+ # (+:link+, +:list+)
20
+ #
21
+ # ==== Signatures
22
+ #
23
+ # UiBibz::Ui::ListGroup.new().tap |lg|
24
+ # ...
25
+ # lg.list content = nil, options = nil, html_options = nil, &block
26
+ # ...
27
+ # end
28
+ #
29
+ # ==== Examples
30
+ #
31
+ # UiBibz::Ui::ListGroup.new().tap do |d|
32
+ # d.list 'Test', state: :success
33
+ # d.list 'Test2', state: :primary
34
+ # end.render
35
+ #
36
+ # UiBibz::Ui::ListGroup.new(type: :link).tap do |d|
37
+ # d.list 'Test', state: :success, url: '#test'
38
+ # d.list(state: :primary) do
39
+ # 'Test 2'
40
+ # end
41
+ # d.list(tap: true, status: :active) do |l|
42
+ # l.header 'My title', nil, class: 'my-title'
43
+ # l.body do
44
+ # 'My content'
45
+ # end
46
+ # end
47
+ # end.render
48
+ #
49
+ class ListGroup < Component
50
+
51
+ def initialize content = nil, options = nil, html_options = nil, &block
52
+ super
53
+ @lists = []
54
+ end
55
+
56
+ def render
57
+ content_tag type, @lists.join().html_safe, class_and_html_options("list-group")
58
+ end
59
+
60
+ def list content = nil, options = {} , html_options = nil, &block
61
+ is_tap = (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
62
+ options = options.merge({ type: :link }) if @options[:type] == :link
63
+
64
+ if is_tap
65
+ @lists << List.new(content, options, html_options).tap(&block).render
66
+ else
67
+ @lists << List.new(content, options, html_options, &block).render
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def type
74
+ @options[:type] == :link ? :div : :ul
75
+ end
76
+
77
+ end
78
+ end
@@ -0,0 +1,68 @@
1
+ module UiBibz::Ui
2
+
3
+ # Create a NavLink
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ # * +status+ - State of élement with symbol value:
18
+ # (+:active+)
19
+ # * +url+ - String
20
+ # * +badge+ - String
21
+ #
22
+ # ==== Signatures
23
+ #
24
+ # UiBibz::Ui::NavLink.new(content, options = nil, html_options = nil)
25
+ #
26
+ # UiBibz::Ui::NavLink.new(options = nil, html_options = nil) do
27
+ # content
28
+ # end
29
+ #
30
+ # ==== Examples
31
+ #
32
+ # UiBibz::Ui::NavLink.new(content, { badge: 15, url: '/', status: :active },{ class: 'test' }).render
33
+ #
34
+ # UiBibz::Ui::NavLink.new({glyph: { name: 'eye', size: 3 }, { class: 'test' }) do
35
+ # 'Home'
36
+ # end.render
37
+ #
38
+ class NavLink < Component
39
+
40
+ def initialize content = nil, options = nil, html_options = nil, &block
41
+ super
42
+ end
43
+
44
+ def render
45
+ content_tag :li, content_htm, class_and_html_options.merge({ role: 'presentation' })
46
+ end
47
+
48
+ private
49
+
50
+ # content_htm and not content_html for haml bug
51
+ def content_htm
52
+ link_to @options[:url], link_html_options do
53
+ concat glyph_and_content_html
54
+ concat badge_html if @options[:badge]
55
+ end
56
+ end
57
+
58
+ def link_html_options
59
+ lho = @options[:link_html_options] || {}
60
+ if @options[:nav_type] == :tabs
61
+ lho.merge({ "aria-controls" => @options[:selector], "role" => "tab", "data-toggle" => "tab" })
62
+ else
63
+ lho
64
+ end
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,65 @@
1
+ require 'ui_bibz/ui/nav/components/nav_link'
2
+ module UiBibz::Ui
3
+
4
+ # Create a nav
5
+ #
6
+ # This element is an extend of UiBibz::Ui::Component.
7
+ #
8
+ # ==== Attributes
9
+ #
10
+ # * +content+ - Content of element
11
+ # * +options+ - Options of element
12
+ # * +html_options+ - Html Options of element
13
+ #
14
+ # ==== Options
15
+ #
16
+ # You can add HTML attributes using the +html_options+.
17
+ # You can pass arguments in options attribute:
18
+ # * +type+ - Symbol
19
+ # (+:pills+, +:tab+)
20
+ #
21
+ # ==== Signatures
22
+ #
23
+ # UiBibz::Ui::Button.new(content, options = nil, html_options = nil)
24
+ #
25
+ # UiBibz::Ui::Button.new(options = nil, html_options = nil).tap do |d|
26
+ # ...
27
+ # d. content = nil, options = nil, html_options = nil, block
28
+ # ...
29
+ # end
30
+ #
31
+ # ==== Examples
32
+ #
33
+ # UiBibz::Ui::Nav.new(type: :pills).tap do |d|
34
+ # d.link 'Test', url: '#test'
35
+ # d.link 'Test2', url: '#test2', status: :active
36
+ # end.render
37
+ #
38
+ class Nav < Component
39
+
40
+ def initialize content = nil, options = nil, html_options = nil, &block
41
+ super
42
+ @links = []
43
+ end
44
+
45
+ def render
46
+ content_tag :ul, @links.join().html_safe, class_and_html_options(["nav", "nav-#{ type }", position])
47
+ end
48
+
49
+ def link content = nil, options = {}, html_options = nil, &block
50
+ @links << NavLink.new(content, options.merge({ nav_type: type }), html_options, &block).render
51
+ end
52
+
53
+ private
54
+
55
+ # tabs or pills
56
+ def type
57
+ @options[:type] || :tabs
58
+ end
59
+
60
+ def position
61
+ "nav-#{ @options[:position] }" unless @options[:position].nil?
62
+ end
63
+
64
+ end
65
+ end