ui_bibz 2.0.0.alpha32 → 2.0.0.beta2

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 (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +111 -87
  4. data/app/assets/javascripts/form.coffee +24 -8
  5. data/app/assets/javascripts/ui_bibz.coffee +3 -2
  6. data/app/assets/stylesheets/bootstrap-switch.sass +17 -8
  7. data/app/assets/stylesheets/fix-dropdown-select.sass +1 -1
  8. data/app/assets/stylesheets/table.sass +1 -1
  9. data/app/assets/stylesheets/ui_bibz.sass +60 -22
  10. data/app/inputs/ui_bibz_form/ui_bibz_form_builder.rb +35 -0
  11. data/app/inputs/ui_bibz_inputs/auto_complete_field_input.rb +14 -0
  12. data/app/inputs/{custom_inputs → ui_bibz_inputs}/base_input.rb +7 -1
  13. data/app/inputs/{custom_inputs → ui_bibz_inputs}/collection_input.rb +6 -3
  14. data/app/inputs/{custom_inputs → ui_bibz_inputs}/string_input.rb +5 -1
  15. data/app/inputs/ui_bibz_inputs/ui_auto_complete_field_input.rb +14 -0
  16. data/app/inputs/ui_bibz_inputs/ui_button_choices_input.rb +20 -0
  17. data/app/inputs/{custom_inputs/date_picker_field_input.rb → ui_bibz_inputs/ui_date_picker_field_input.rb} +2 -2
  18. data/app/inputs/{custom_inputs/dropdown_select_field_input.rb → ui_bibz_inputs/ui_dropdown_select_field_input.rb} +2 -2
  19. data/app/inputs/{custom_inputs/formula_field_input.rb → ui_bibz_inputs/ui_formula_field_input.rb} +2 -2
  20. data/app/inputs/{custom_inputs/markdown_editor_field_input.rb → ui_bibz_inputs/ui_markdown_editor_field_input.rb} +2 -2
  21. data/app/inputs/{custom_inputs/multi_column_field_input.rb → ui_bibz_inputs/ui_multi_column_field_input.rb} +2 -2
  22. data/app/inputs/ui_bibz_inputs/ui_multi_select_field_input.rb +9 -0
  23. data/app/inputs/{custom_inputs/radio_field_input.rb → ui_bibz_inputs/ui_radio_field_input.rb} +2 -2
  24. data/app/inputs/{custom_inputs/select_field_input.rb → ui_bibz_inputs/ui_select_field_input.rb} +2 -2
  25. data/app/inputs/{custom_inputs/switch_field_input.rb → ui_bibz_inputs/ui_switch_field_input.rb} +2 -2
  26. data/app/inputs/ui_bibz_inputs/ui_text_field_input.rb +13 -0
  27. data/config/initializers/ui_bibz.rb +7 -0
  28. data/lib/ui_bibz/helpers/ui/core/cards_helper.rb +42 -0
  29. data/lib/ui_bibz/helpers/ui/core/dropdowns_helper.rb +21 -0
  30. data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +148 -0
  31. data/lib/ui_bibz/helpers/ui/core/layouts_helper.rb +27 -0
  32. data/lib/ui_bibz/helpers/ui/core/lists_helper.rb +11 -0
  33. data/lib/ui_bibz/helpers/ui/core/navs_helper.rb +27 -0
  34. data/lib/ui_bibz/helpers/ui/core/paths_helper.rb +16 -0
  35. data/lib/ui_bibz/helpers/ui/core/windows_helper.rb +11 -0
  36. data/lib/ui_bibz/helpers/ui/core_helper.rb +89 -0
  37. data/lib/ui_bibz/helpers/{ui_ux_helper.rb → ui/ux_helper.rb} +8 -18
  38. data/lib/ui_bibz/helpers/utils_helper.rb +22 -1
  39. data/lib/ui_bibz/rails/engine.rb +6 -2
  40. data/lib/ui_bibz/ui/base.rb +4 -0
  41. data/lib/ui_bibz/ui/core/{tag.rb → badge.rb} +10 -10
  42. data/lib/ui_bibz/ui/core/cards/card.rb +37 -13
  43. data/lib/ui_bibz/ui/core/cards/components/{block/card_block_link.rb → body/card_body_link.rb} +6 -6
  44. data/lib/ui_bibz/ui/core/cards/components/{block/card_block_text.rb → body/card_body_text.rb} +6 -6
  45. data/lib/ui_bibz/ui/core/cards/components/{block/card_block_title.rb → body/card_body_title.rb} +6 -6
  46. data/lib/ui_bibz/ui/core/cards/components/{card_block.rb → card_body.rb} +17 -13
  47. data/lib/ui_bibz/ui/core/cards/components/card_footer.rb +5 -1
  48. data/lib/ui_bibz/ui/core/cards/components/card_header.rb +5 -1
  49. data/lib/ui_bibz/ui/core/cards/components/card_image.rb +3 -2
  50. data/lib/ui_bibz/ui/core/component.rb +8 -6
  51. data/lib/ui_bibz/ui/core/dropdowns/dropdown.rb +21 -5
  52. data/lib/ui_bibz/ui/core/forms/buttons/button.rb +37 -8
  53. data/lib/ui_bibz/ui/core/forms/buttons/button_choice.rb +17 -29
  54. data/lib/ui_bibz/ui/core/forms/buttons/button_group.rb +51 -11
  55. data/lib/ui_bibz/ui/core/forms/buttons/button_link.rb +18 -5
  56. data/lib/ui_bibz/ui/core/forms/buttons/button_refresh.rb +13 -4
  57. data/lib/ui_bibz/ui/core/forms/buttons/button_toolbar.rb +90 -0
  58. data/lib/ui_bibz/ui/core/forms/buttons/components/choice.rb +116 -0
  59. data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +21 -8
  60. data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +22 -9
  61. data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +17 -5
  62. data/lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb +36 -16
  63. data/lib/ui_bibz/ui/core/forms/numbers/formula_field.rb +20 -19
  64. data/lib/ui_bibz/ui/core/forms/selects/abstract_select.rb +99 -0
  65. data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +16 -16
  66. data/lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb +8 -13
  67. data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +17 -18
  68. data/lib/ui_bibz/ui/core/forms/selects/select_field.rb +8 -20
  69. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_addon.rb +25 -0
  70. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button.rb +16 -0
  71. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_group.rb +16 -0
  72. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_link.rb +16 -0
  73. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_refresh.rb +16 -0
  74. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_checkbox_field.rb +16 -0
  75. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_dropdown.rb +16 -0
  76. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_radio_field.rb +16 -0
  77. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_switch_field.rb +16 -0
  78. data/lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb +153 -0
  79. data/lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb +13 -38
  80. data/lib/ui_bibz/ui/core/forms/texts/text_field.rb +81 -0
  81. data/lib/ui_bibz/ui/core/glyph.rb +1 -1
  82. data/lib/ui_bibz/ui/core/layouts/col.rb +10 -2
  83. data/lib/ui_bibz/ui/core/layouts/row.rb +7 -1
  84. data/lib/ui_bibz/ui/core/lists/components/list/list_body.rb +4 -2
  85. data/lib/ui_bibz/ui/core/lists/components/list/list_header.rb +5 -2
  86. data/lib/ui_bibz/ui/core/lists/components/list.rb +35 -14
  87. data/lib/ui_bibz/ui/core/lists/list_group.rb +4 -4
  88. data/lib/ui_bibz/ui/core/navs/components/navbar_form.rb +7 -2
  89. data/lib/ui_bibz/ui/core/navs/components/navbar_nav.rb +4 -0
  90. data/lib/ui_bibz/ui/core/navs/components/navbar_text.rb +1 -1
  91. data/lib/ui_bibz/ui/core/navs/components/pagination_link.rb +60 -0
  92. data/lib/ui_bibz/ui/core/navs/nav.rb +31 -3
  93. data/lib/ui_bibz/ui/core/navs/navbar.rb +32 -22
  94. data/lib/ui_bibz/ui/core/navs/pagination.rb +97 -0
  95. data/lib/ui_bibz/ui/core/{alert.rb → notifications/alert.rb} +23 -11
  96. data/lib/ui_bibz/ui/core/notifications/components/alert_body.rb +50 -0
  97. data/lib/ui_bibz/ui/core/notifications/components/alert_header.rb +67 -0
  98. data/lib/ui_bibz/ui/core/{progress.rb → progresses/components/bar.rb} +21 -28
  99. data/lib/ui_bibz/ui/core/progresses/progress_bar.rb +115 -0
  100. data/lib/ui_bibz/ui/core/windows/components/modal_header.rb +1 -1
  101. data/lib/ui_bibz/ui/{core → extensions/core}/component/glyph_extension.rb +2 -2
  102. data/lib/ui_bibz/ui/{core → extensions/core}/component/klass_extension.rb +1 -2
  103. data/lib/ui_bibz/ui/extensions/core/forms/connect_extension.rb +31 -0
  104. data/lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb +48 -0
  105. data/lib/ui_bibz/utils/internationalization.rb +9 -0
  106. data/lib/ui_bibz/version.rb +1 -1
  107. data/lib/ui_bibz.rb +23 -7
  108. data/test/simple_form_test.rb +58 -41
  109. data/test/ui/core/badge_test.rb +19 -0
  110. data/test/ui/core/cards/card_test.rb +34 -35
  111. data/test/ui/{component_test.rb → core/component_test.rb} +0 -1
  112. data/test/ui/core/dropdowns/dropdown_test.rb +5 -5
  113. data/test/ui/core/forms/buttons/button_choice_test.rb +23 -7
  114. data/test/ui/core/forms/buttons/button_group_test.rb +35 -17
  115. data/test/ui/core/forms/buttons/button_link_test.rb +74 -4
  116. data/test/ui/core/forms/buttons/button_refresh_test.rb +1 -2
  117. data/test/ui/core/forms/buttons/button_test.rb +66 -3
  118. data/test/ui/core/forms/choices/checkbox_field_test.rb +1 -2
  119. data/test/ui/core/forms/choices/radio_field_test.rb +1 -2
  120. data/test/ui/core/forms/choices/switch_field_test.rb +0 -1
  121. data/test/ui/core/forms/dates/date_picker_field_test.rb +2 -3
  122. data/test/ui/core/forms/numbers/formula_field_test.rb +1 -2
  123. data/test/ui/core/forms/selects/dropdown_select_field_test.rb +1 -2
  124. data/test/ui/core/forms/selects/multi_column_field_test.rb +0 -1
  125. data/test/ui/core/forms/selects/multi_select_field_test.rb +1 -2
  126. data/test/ui/core/forms/selects/select_field_test.rb +1 -2
  127. data/test/ui/core/forms/surrounds/surround_field_test.rb +58 -0
  128. data/test/ui/core/forms/textareas/markdown_editor_field_test.rb +0 -1
  129. data/test/ui/core/forms/texts/auto_complete_field_test.rb +21 -4
  130. data/test/ui/core/forms/texts/text_field_test.rb +25 -0
  131. data/test/ui/{glyph_test.rb → core/glyph_test.rb} +5 -5
  132. data/test/ui/core/jumbotron_test.rb +20 -0
  133. data/test/ui/core/layouts/col_test.rb +31 -0
  134. data/test/ui/core/layouts/container_test.rb +13 -0
  135. data/test/ui/core/layouts/row_test.rb +24 -0
  136. data/test/ui/core/lists/list_group_test.rb +5 -4
  137. data/test/ui/core/navs/nav_test.rb +4 -5
  138. data/test/ui/core/navs/navbar_test.rb +39 -0
  139. data/test/ui/core/notifications/alert_test.rb +22 -0
  140. data/test/ui/core/paths/breadcrumb_test.rb +15 -4
  141. data/test/ui/core/progress_test.rb +14 -0
  142. data/test/ui/{star_test.rb → core/star_test.rb} +6 -7
  143. data/test/ui/core/windows/modal_test.rb +20 -0
  144. data/test/ui/ux/tables/table_test.rb +2 -3
  145. data/ui_bibz.gemspec +2 -1
  146. data/vendor/assets/javascripts/bootstrap-select.min.js +8 -7
  147. data/vendor/assets/stylesheets/awesome-bootstrap-checkbox.scss +62 -42
  148. data/vendor/assets/stylesheets/bootstrap-multiselect.min.css +1 -1
  149. data/vendor/assets/stylesheets/bootstrap-select.min.css +3 -3
  150. data/vendor/assets/stylesheets/bootstrap-theme.min.css +1 -1
  151. metadata +105 -44
  152. data/app/inputs/custom_inputs/auto_complete_field_input.rb +0 -16
  153. data/app/inputs/custom_inputs/multi_select_field_input.rb +0 -9
  154. data/app/inputs/custom_inputs/surround_field_input.rb +0 -10
  155. data/lib/ui_bibz/helpers/ui_core_helper.rb +0 -347
  156. data/lib/ui_bibz/ui/core/connected_component.rb +0 -87
  157. data/lib/ui_bibz/ui/core/forms/texts/surround_field.rb +0 -87
  158. data/test/ui/core/forms/texts/surround_field_test.rb +0 -26
  159. data/test/ui/grid_test.rb +0 -31
  160. data/test/ui_helper_test.rb +0 -109
@@ -2,8 +2,29 @@ module UiBibz::Helpers::UtilsHelper
2
2
 
3
3
  # Same method like I18n.translate but accept
4
4
  # strings in default argument
5
- def translatize translation, options
5
+ def ui_translatize translation, options
6
6
  UiBibz::Utils::Internationalization.new(translation, options).translate
7
7
  end
8
8
 
9
+ def ui_form_for object, *args, &block
10
+ options = args.extract_options!
11
+ simple_form_for(object, *(args << new_options(options)), &block)
12
+ end
13
+
14
+ private
15
+
16
+ def new_options options
17
+ if options[:html].nil?
18
+ options[:html] = { class: options[:class] }
19
+ else
20
+ if options[:html][:class].nil?
21
+ options[:html] = options[:html].merge({ class: options[:class] })
22
+ else
23
+ options[:html][:class] = options[:html][:class] + (options[:class] || "")
24
+ end
25
+ end
26
+ options.merge(builder: UiBibzForm::UiBibzFormBuilder)
27
+ end
28
+
29
+
9
30
  end
@@ -1,5 +1,7 @@
1
1
  # to load pagination in rails app
2
2
  require 'will_paginate'
3
+ require 'jquery-rails'
4
+ require 'popper_js'
3
5
  require 'bootstrap'
4
6
  require "font-awesome-sass"
5
7
 
@@ -17,10 +19,12 @@ module UiBibz
17
19
  class Engine < ::Rails::Engine
18
20
 
19
21
  initializer "ui_bibz.helpers" do
20
- ActionView::Base.send :include, UiBibz::Helpers::UiCoreHelper
21
- ActionView::Base.send :include, UiBibz::Helpers::UiUxHelper
22
22
  ActionView::Base.send :include, UiBibz::Helpers::UtilsHelper
23
23
  end
24
+ initializer "ui_bibz.helpers.ui" do
25
+ ActionView::Base.send :include, UiBibz::Helpers::Ui::CoreHelper
26
+ ActionView::Base.send :include, UiBibz::Helpers::Ui::UxHelper
27
+ end
24
28
 
25
29
  end
26
30
  end
@@ -15,5 +15,9 @@ module UiBibz::Ui
15
15
  def inject_url url, record
16
16
  url.gsub(/(\/id\/?)/, "/#{ record.id }/")
17
17
  end
18
+
19
+ def generate_id name = nil
20
+ "#{ name || 'id' }-#{ Random.new_seed }"
21
+ end
18
22
  end
19
23
  end
@@ -1,6 +1,6 @@
1
1
  module UiBibz::Ui::Core
2
2
 
3
- # Create a tag
3
+ # Create a badge
4
4
  #
5
5
  # This element is an extend of UiBibz::Ui::Core::Component.
6
6
  # The helper use 'etiquette' method to avoid conflict with Rails.
@@ -22,21 +22,21 @@ module UiBibz::Ui::Core
22
22
  # * +size+ - Integer
23
23
  # * +type+ - Symbol
24
24
  # * +type+ - Symbol
25
- # (+pill+)
25
+ # (+:pill+, +:square+)
26
26
  #
27
27
  # ==== Signatures
28
28
  #
29
- # UiBibz::Ui::Core::Tag.new(content, options = nil, html_options = nil)
29
+ # UiBibz::Ui::Core::Badge.new(content, options = nil, html_options = nil)
30
30
  #
31
- # UiBibz::Ui::Core::Tag.new(options = nil, html_options = nil) do
31
+ # UiBibz::Ui::Core::Badge.new(options = nil, html_options = nil) do
32
32
  # content
33
33
  # end
34
34
  #
35
35
  # ==== Examples
36
36
  #
37
- # UiBibz::Ui::Core::Tag.new(content, status: :success, type: :pill).render
37
+ # UiBibz::Ui::Core::Badge.new(content, status: :success, type: :pill).render
38
38
  #
39
- # UiBibz::Ui::Core::Tag.new() do
39
+ # UiBibz::Ui::Core::Badge.new() do
40
40
  # #content
41
41
  # end.render
42
42
  #
@@ -48,7 +48,7 @@ module UiBibz::Ui::Core
48
48
  # content
49
49
  # end
50
50
  #
51
- class Tag < Component
51
+ class Badge < Component
52
52
 
53
53
  # See UiBibz::Ui::Core::Component.initialize
54
54
  def initialize content = nil, options = nil, html_options = nil, &block
@@ -63,15 +63,15 @@ module UiBibz::Ui::Core
63
63
  private
64
64
 
65
65
  def component_html_classes
66
- ['tag', type]
66
+ ['badge', type]
67
67
  end
68
68
 
69
69
  def status
70
- "tag-#{ @options[:status] || :default }"
70
+ "badge-#{ @options[:status] || :default }"
71
71
  end
72
72
 
73
73
  def type
74
- "tag-pill" if @options[:type] == :pill
74
+ "badge-pill" if @options[:type] == :pill
75
75
  end
76
76
 
77
77
  end
@@ -1,6 +1,6 @@
1
1
  require 'ui_bibz/ui/core/cards/components/card_header'
2
2
  require 'ui_bibz/ui/core/cards/components/card_footer'
3
- require 'ui_bibz/ui/core/cards/components/card_block'
3
+ require 'ui_bibz/ui/core/cards/components/card_body'
4
4
  require 'ui_bibz/ui/core/cards/components/card_image'
5
5
  require 'ui_bibz/ui/core/cards/components/card_list_group'
6
6
  module UiBibz::Ui::Core::Cards
@@ -73,9 +73,9 @@ module UiBibz::Ui::Core::Cards
73
73
  # content
74
74
  # end
75
75
  #
76
- # p.block(content, options = {}, html_options = {})
76
+ # p.body(content, options = {}, html_options = {})
77
77
  # # or
78
- # p.block(options = {}, html_options = {}) do
78
+ # p.body(options = {}, html_options = {}) do
79
79
  # content
80
80
  # end
81
81
  #
@@ -91,26 +91,29 @@ module UiBibz::Ui::Core::Cards
91
91
  # See UiBibz::Ui::Core::Component.initialize
92
92
  def initialize content = nil, options = nil, html_options = nil, &block
93
93
  super
94
- @items = [@content]
94
+ @items = @content.nil? ? [] : [UiBibz::Ui::Core::Cards::Components::CardBody.new(@content).render]
95
95
  end
96
96
 
97
97
  # Add Header which is a component
98
98
  def header content = nil, options = nil, html_options = nil, &block
99
- @items << UiBibz::Ui::Core::Cards::Components::CardHeader.new(content, options, html_options, &block).render
99
+ options, content = inherit_options(content, options, block)
100
+ @header = UiBibz::Ui::Core::Cards::Components::CardHeader.new(content, options, html_options, &block).render
100
101
  end
101
102
 
102
- # Add Block div which is a component
103
- def block content = nil, options = nil, html_options = nil, &block
103
+ # Add Body div which is a component
104
+ def body content = nil, options = nil, html_options = nil, &block
105
+ options, content = inherit_options(content, options, block)
104
106
  if is_tap(content, options)
105
- @items << UiBibz::Ui::Core::Cards::Components::CardBlock.new(content, options, html_options).tap(&block).render
107
+ @items << UiBibz::Ui::Core::Cards::Components::CardBody.new(content, options, html_options).tap(&block).render
106
108
  else
107
- @items << UiBibz::Ui::Core::Cards::Components::CardBlock.new(content, options, html_options, &block).render
109
+ @items << UiBibz::Ui::Core::Cards::Components::CardBody.new(content, options, html_options, &block).render
108
110
  end
109
111
  end
110
112
 
111
113
  # Add Footer which is a component
112
114
  def footer content = nil, options = nil, html_options = nil, &block
113
- @items << UiBibz::Ui::Core::Cards::Components::CardFooter.new(content, options, html_options, &block).render
115
+ options, content = inherit_options(content, options, block)
116
+ @footer = UiBibz::Ui::Core::Cards::Components::CardFooter.new(content, options, html_options, &block).render
114
117
  end
115
118
 
116
119
  # Add List group which is a component
@@ -125,17 +128,34 @@ module UiBibz::Ui::Core::Cards
125
128
 
126
129
  # Render html tag
127
130
  def render
128
- content_tag :div, @items.join.html_safe, html_options
131
+ content_tag :div, html_structure, html_options
129
132
  end
130
133
 
131
134
  protected
132
135
 
136
+ def html_structure
137
+ [@header, @items.join, @footer].compact.join.html_safe
138
+ end
139
+
140
+ def inherit_options content, options, block
141
+ if block.nil?
142
+ options = (options || {}).merge({ outline: @options[:outline] , status: @options[:status] })
143
+ else
144
+ content = (content || {}).merge({ outline: @options[:outline], status: @options[:status] })
145
+ end
146
+ [options, content]
147
+ end
148
+
133
149
  def component_html_classes
134
- ["card", text, card_block, type, tab_pane]
150
+ ["card", text, type, tab_pane, outline]
135
151
  end
136
152
 
137
153
  def status
138
- "card-#{ @options[:status] }" unless @options[:status].nil?
154
+ unless @options[:status].nil?
155
+ output = @options[:outline] ? ["border-#{ @options[:status] }"] : ["bg-#{ @options[:status] }"]
156
+ output << "text-white" if @options[:status] != :light && @options[:status] != :warning
157
+ output.join(' ')
158
+ end
139
159
  end
140
160
 
141
161
  def text
@@ -154,5 +174,9 @@ module UiBibz::Ui::Core::Cards
154
174
  "tab-pane" if @options[:tab]
155
175
  end
156
176
 
177
+ def outline
178
+ "bg-transparent" if @options[:outline]
179
+ end
180
+
157
181
  end
158
182
  end
@@ -1,4 +1,4 @@
1
- module UiBibz::Ui::Core::Cards::Components::Block
1
+ module UiBibz::Ui::Core::Cards::Components::Body
2
2
 
3
3
  # Create a card block title
4
4
  #
@@ -15,21 +15,21 @@ module UiBibz::Ui::Core::Cards::Components::Block
15
15
  #
16
16
  # ==== Signatures
17
17
  #
18
- # UiBibz::Ui::Core::Cards::CardBlockLink.new(content, options = nil, html_options = nil)
18
+ # UiBibz::Ui::Core::Cards::CardBodyLink.new(content, options = nil, html_options = nil)
19
19
  #
20
- # UiBibz::Ui::Core::Cards::CardBlockLink.new(options = nil, html_options = nil) do
20
+ # UiBibz::Ui::Core::Cards::CardBodyLink.new(options = nil, html_options = nil) do
21
21
  # content
22
22
  # end
23
23
  #
24
24
  # ==== Examples
25
25
  #
26
- # UiBibz::Ui::Core::Cards::CardBlockLink.new.render
26
+ # UiBibz::Ui::Core::Cards::CardBodyLink.new.render
27
27
  #
28
- # UiBibz::Ui::Core::Cards::CardBlockLink.new do
28
+ # UiBibz::Ui::Core::Cards::CardBodyLink.new do
29
29
  # 'Exemple'
30
30
  # end.render
31
31
  #
32
- class CardBlockLink < UiBibz::Ui::Core::Component
32
+ class CardBodyLink < UiBibz::Ui::Core::Component
33
33
 
34
34
  # See UiBibz::Ui::Core::Component.initialize
35
35
  def initialize content = nil, options = nil, html_options = nil, &block
@@ -1,4 +1,4 @@
1
- module UiBibz::Ui::Core::Cards::Components::Block
1
+ module UiBibz::Ui::Core::Cards::Components::Body
2
2
 
3
3
  # Create a card block title
4
4
  #
@@ -15,21 +15,21 @@ module UiBibz::Ui::Core::Cards::Components::Block
15
15
  #
16
16
  # ==== Signatures
17
17
  #
18
- # UiBibz::Ui::Core::Cards::CardBlockText.new(content, options = nil, html_options = nil)
18
+ # UiBibz::Ui::Core::Cards::CardBodyText.new(content, options = nil, html_options = nil)
19
19
  #
20
- # UiBibz::Ui::Core::Cards::CardBlockText.new(options = nil, html_options = nil) do
20
+ # UiBibz::Ui::Core::Cards::CardBodyText.new(options = nil, html_options = nil) do
21
21
  # content
22
22
  # end
23
23
  #
24
24
  # ==== Examples
25
25
  #
26
- # UiBibz::Ui::Core::Cards::CardBlockText.new.render
26
+ # UiBibz::Ui::Core::Cards::CardBodyText.new.render
27
27
  #
28
- # UiBibz::Ui::Core::Cards::CardBlockText.new do
28
+ # UiBibz::Ui::Core::Cards::CardBodyText.new do
29
29
  # 'Exemple'
30
30
  # end.render
31
31
  #
32
- class CardBlockText < UiBibz::Ui::Core::Component
32
+ class CardBodyText < UiBibz::Ui::Core::Component
33
33
 
34
34
  # See UiBibz::Ui::Core::Component.initialize
35
35
  def initialize content = nil, options = nil, html_options = nil, &block
@@ -1,4 +1,4 @@
1
- module UiBibz::Ui::Core::Cards::Components::Block
1
+ module UiBibz::Ui::Core::Cards::Components::Body
2
2
 
3
3
  # Create a card block title
4
4
  #
@@ -15,21 +15,21 @@ module UiBibz::Ui::Core::Cards::Components::Block
15
15
  #
16
16
  # ==== Signatures
17
17
  #
18
- # UiBibz::Ui::Core::Cards::CardBlockTitle.new(content, options = nil, html_options = nil)
18
+ # UiBibz::Ui::Core::Cards::CardBodyTitle.new(content, options = nil, html_options = nil)
19
19
  #
20
- # UiBibz::Ui::Core::Cards::CardBlockTitle.new(options = nil, html_options = nil) do
20
+ # UiBibz::Ui::Core::Cards::CardBodyTitle.new(options = nil, html_options = nil) do
21
21
  # content
22
22
  # end
23
23
  #
24
24
  # ==== Examples
25
25
  #
26
- # UiBibz::Ui::Core::Cards::CardBlockTitle.new.render
26
+ # UiBibz::Ui::Core::Cards::CardBodyTitle.new.render
27
27
  #
28
- # UiBibz::Ui::Core::Cards::CardBlockTitle.new do
28
+ # UiBibz::Ui::Core::Cards::CardBodyTitle.new do
29
29
  # 'Exemple'
30
30
  # end.render
31
31
  #
32
- class CardBlockTitle < UiBibz::Ui::Core::Component
32
+ class CardBodyTitle < UiBibz::Ui::Core::Component
33
33
 
34
34
  # See UiBibz::Ui::Core::Component.initialize
35
35
  def initialize content = nil, options = nil, html_options = nil, &block
@@ -1,9 +1,9 @@
1
- require 'ui_bibz/ui/core/cards/components/block/card_block_text'
2
- require 'ui_bibz/ui/core/cards/components/block/card_block_title'
3
- require 'ui_bibz/ui/core/cards/components/block/card_block_link'
1
+ require 'ui_bibz/ui/core/cards/components/body/card_body_text'
2
+ require 'ui_bibz/ui/core/cards/components/body/card_body_title'
3
+ require 'ui_bibz/ui/core/cards/components/body/card_body_link'
4
4
  module UiBibz::Ui::Core::Cards::Components
5
5
 
6
- # Create a card block
6
+ # Create a card body
7
7
  #
8
8
  # ==== Attributes
9
9
  #
@@ -18,21 +18,21 @@ module UiBibz::Ui::Core::Cards::Components
18
18
  #
19
19
  # ==== Signatures
20
20
  #
21
- # UiBibz::Ui::Core::Cards::CardBlock.new(content, options = nil, html_options = nil)
21
+ # UiBibz::Ui::Core::Cards::CardBody.new(content, options = nil, html_options = nil)
22
22
  #
23
- # UiBibz::Ui::Core::Cards::CardBlock.new(options = nil, html_options = nil) do
23
+ # UiBibz::Ui::Core::Cards::CardBody.new(options = nil, html_options = nil) do
24
24
  # content
25
25
  # end
26
26
  #
27
27
  # ==== Examples
28
28
  #
29
- # UiBibz::Ui::Core::Cards::CardBlock.new.render
29
+ # UiBibz::Ui::Core::Cards::CardBody.new.render
30
30
  #
31
- # UiBibz::Ui::Core::Cards::CardBlock.new do
31
+ # UiBibz::Ui::Core::Cards::CardBody.new do
32
32
  # 'Exemple'
33
33
  # end.render
34
34
  #
35
- class CardBlock < UiBibz::Ui::Core::Component
35
+ class CardBody < UiBibz::Ui::Core::Component
36
36
 
37
37
  # See UiBibz::Ui::Core::Component.initialize
38
38
  def initialize content = nil, options = nil, html_options = nil, &block
@@ -46,21 +46,25 @@ module UiBibz::Ui::Core::Cards::Components
46
46
  end
47
47
 
48
48
  def title content = nil, options = nil, html_options = nil, &block
49
- @items << UiBibz::Ui::Core::Cards::Components::Block::CardBlockTitle.new(content, options, html_options, &block).render
49
+ @items << UiBibz::Ui::Core::Cards::Components::Body::CardBodyTitle.new(content, options, html_options, &block).render
50
50
  end
51
51
 
52
52
  def link content = nil, options = nil, html_options = nil, &block
53
- @items << UiBibz::Ui::Core::Cards::Components::Block::CardBlockLink.new(content, options, html_options, &block).render
53
+ @items << UiBibz::Ui::Core::Cards::Components::Body::CardBodyLink.new(content, options, html_options, &block).render
54
54
  end
55
55
 
56
56
  def text content = nil, options = nil, html_options = nil, &block
57
- @items << UiBibz::Ui::Core::Cards::Components::Block::CardBlockText.new(content, options, html_options, &block).render
57
+ @items << UiBibz::Ui::Core::Cards::Components::Body::CardBodyText.new(content, options, html_options, &block).render
58
58
  end
59
59
 
60
60
  private
61
61
 
62
62
  def component_html_classes
63
- "card-block"
63
+ ["card-body", outline]
64
+ end
65
+
66
+ def outline
67
+ "text-#{ @options[:status] }" if @options[:outline]
64
68
  end
65
69
 
66
70
  end
@@ -48,7 +48,11 @@ module UiBibz::Ui::Core::Cards::Components
48
48
  end
49
49
 
50
50
  def component_html_classes
51
- ["card-footer", muted]
51
+ ["card-footer", muted, outline]
52
+ end
53
+
54
+ def outline
55
+ "text-#{ @options[:status] } border-#{ @options[:status] } bg-transparent" if @options[:outline]
52
56
  end
53
57
 
54
58
  end
@@ -44,7 +44,11 @@ module UiBibz::Ui::Core::Cards::Components
44
44
  private
45
45
 
46
46
  def component_html_classes
47
- "card-header"
47
+ ["card-header", outline]
48
+ end
49
+
50
+ def outline
51
+ "text-#{ @options[:status] } border-#{ @options[:status] } bg-transparent" if @options[:outline]
48
52
  end
49
53
 
50
54
  end
@@ -40,7 +40,8 @@ module UiBibz::Ui::Core::Cards::Components
40
40
 
41
41
  # Render html tag
42
42
  def render
43
- image_tag asset_path("assets/#{content}"), html_options
43
+ #image_tag asset_path("assets/#{content}"), html_options
44
+ image_tag content, html_options
44
45
  end
45
46
 
46
47
  private
@@ -50,7 +51,7 @@ module UiBibz::Ui::Core::Cards::Components
50
51
  end
51
52
 
52
53
  def position
53
- "card-img-#{ @options[:position] }" unless @options[:position].nil?
54
+ "card-img-#{ @options[:position] || :top }"
54
55
  end
55
56
 
56
57
  end
@@ -1,6 +1,6 @@
1
1
  require 'haml'
2
- require 'ui_bibz/ui/core/component/klass_extension'
3
- require 'ui_bibz/ui/core/component/glyph_extension'
2
+ require 'ui_bibz/ui/extensions/core/component/klass_extension'
3
+ require 'ui_bibz/ui/extensions/core/component/glyph_extension'
4
4
  module UiBibz::Ui::Core
5
5
 
6
6
  # Creates a component of the given +name+ using options created by the set of +options+.
@@ -72,10 +72,6 @@ module UiBibz::Ui::Core
72
72
  glyph_and_content_html
73
73
  end
74
74
 
75
- def tag_html
76
- UiBibz::Ui::Core::Tag.new(options[:tag], class: 'pull-right', type: :pill, status: (options[:tag_status] || :default)).render
77
- end
78
-
79
75
  # Know if component is tapped or not
80
76
  def is_tap content, options
81
77
  (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
@@ -86,6 +82,7 @@ module UiBibz::Ui::Core
86
82
  # Override this method to add html classes
87
83
  # Accept Array or String
88
84
  def component_html_classes
85
+ []
89
86
  end
90
87
 
91
88
  # Override this method to add html data
@@ -104,6 +101,11 @@ module UiBibz::Ui::Core
104
101
  {}
105
102
  end
106
103
 
104
+ # Override this method to add html classes to wrapper
105
+ def component_wrapper_html_classes
106
+ []
107
+ end
108
+
107
109
  # Add html data arguments
108
110
  def add_html_data name, value = true
109
111
  html_options[:data] = {} if html_options[:data].nil?
@@ -99,10 +99,14 @@ module UiBibz::Ui::Core::Dropdowns
99
99
  @items << content
100
100
  end
101
101
 
102
+ def id
103
+ @id ||= html_options[:id] || generate_id("dropdown")
104
+ end
105
+
102
106
  protected
103
107
 
104
108
  def component_html_classes
105
- [type, "btn-group", open]
109
+ [type, open, inline]
106
110
  end
107
111
 
108
112
  def button_content
@@ -110,19 +114,27 @@ module UiBibz::Ui::Core::Dropdowns
110
114
  end
111
115
 
112
116
  def button_html
113
- content_tag :button, button_content, class: join_classes("btn", button_status, state, size, "dropdown-toggle"), type: 'button', "data-toggle" => 'dropdown', "aria-haspopup" => true, "aria-expanded" => false
117
+ if options[:tag] == :a
118
+ content_tag dropdown_tag, button_content, class: join_classes("btn", button_status, state, size, "dropdown-toggle"), href: '#', role: 'button', "data-toggle" => 'dropdown', "aria-haspopup" => true, "aria-expanded" => false, "id" => id
119
+ else
120
+ content_tag dropdown_tag, button_content, class: join_classes("btn", button_status, state, size, "dropdown-toggle"), type: 'button', "data-toggle" => 'dropdown', "aria-haspopup" => true, "aria-expanded" => false, "id" => id
121
+ end
114
122
  end
115
123
 
116
124
  def ul_html
117
- content_tag :div, @items.join.html_safe, class: "dropdown-menu dropdown-menu-#{ position }"
125
+ content_tag :div, @items.join.html_safe, class: join_classes("dropdown-menu", position, open), "arial-labelledby" => id
118
126
  end
119
127
 
120
128
  def caret
121
129
  content_tag :span, '', class: 'caret'
122
130
  end
123
131
 
132
+ def dropdown_tag
133
+ options[:tag] || :button
134
+ end
135
+
124
136
  def position
125
- @options[:position] || 'left'
137
+ "dropdown-menu-#{ @options[:position] }" unless @options[:position].nil?
126
138
  end
127
139
 
128
140
  def type
@@ -130,7 +142,11 @@ module UiBibz::Ui::Core::Dropdowns
130
142
  end
131
143
 
132
144
  def open
133
- "open" if @options[:open]
145
+ "show" if @options[:open]
146
+ end
147
+
148
+ def inline
149
+ "btn-group" if @options[:inline]
134
150
  end
135
151
 
136
152
  def button_status
@@ -44,12 +44,12 @@ module UiBibz::Ui::Core::Forms::Buttons
44
44
  #
45
45
  # ==== Helper
46
46
  #
47
- # button(content, options = {}, html_options = {})
47
+ # ui_button(content, options = {}, html_options = {})
48
48
  #
49
- # button(options = {}, html_options = {}) do
49
+ # ui_button(options = {}, html_options = {}) do
50
50
  # content
51
51
  # end
52
- class Button < UiBibz::Ui::Core::ConnectedComponent
52
+ class Button < UiBibz::Ui::Core::Component
53
53
 
54
54
  # See UiBibz::Ui::Core::Component.initialize
55
55
  def initialize content = nil, options = nil, html_options = nil, &block
@@ -58,22 +58,32 @@ module UiBibz::Ui::Core::Forms::Buttons
58
58
 
59
59
  # Render html tag
60
60
  def render
61
- content_tag :button, glyph_and_content_html, html_options
61
+ button_html_tag
62
62
  end
63
63
 
64
64
  protected
65
65
 
66
+ def button_html_tag
67
+ content_tag :button, html_options do
68
+ concat glyph_and_content_html(options[:text].nil? ? @content : ' ')
69
+ concat badge_html unless options[:badge].nil?
70
+ end
71
+ end
72
+
66
73
  def component_html_classes
67
- ['btn', size, type]
74
+ super << ['btn', size, type, without_text]
68
75
  end
69
76
 
70
77
  def component_html_options
71
- options[:toggle].nil? ? {} : { "data-toggle" => 'button', "aria-pressed" => false, "autocomplete" => "off" }
78
+ opts = super
79
+ opts = opts.merge(toggle) unless options[:toggle].nil?
80
+ opts = opts.merge(active_html_options) if options[:state] == :active
81
+ opts = opts.merge({ disabled: 'disabled' }) if options[:state] == :disabled
82
+ opts
72
83
  end
73
84
 
74
85
  def status
75
- s = options[:status] || :primary
76
- ["btn", outline, s].compact.join('-')
86
+ ["btn", outline, options[:status]].compact.join('-')
77
87
  end
78
88
 
79
89
  def outline
@@ -81,12 +91,31 @@ module UiBibz::Ui::Core::Forms::Buttons
81
91
  end
82
92
 
83
93
  def toggle
94
+ { "data-toggle" => 'button', "aria-pressed" => false, "autocomplete" => "off" }
95
+ end
96
+
97
+ def active_html_options
98
+ { "aria-pressed" => true }
84
99
  end
85
100
 
86
101
  def type
87
102
  "btn-block" if options[:type] == :block
88
103
  end
89
104
 
105
+ def without_text
106
+ "without-text" unless options[:text].nil?
107
+ end
108
+
109
+ def badge_html
110
+ if options[:badge].kind_of? Hash
111
+ options[:badge][:status] = options[:status] || :secondary
112
+ UiBibz::Ui::Core::Badge.new(options[:badge].delete(:content), options[:badge]).render
113
+
114
+ else
115
+ UiBibz::Ui::Core::Badge.new(options[:badge], status: (options[:status] || :secondary)).render
116
+ end
117
+ end
118
+
90
119
  # :lg, :sm or :xs
91
120
  def size
92
121
  "btn-#{ options[:size] }" if options[:size]