ui_bibz 2.0.0.alpha32 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -18,6 +18,13 @@ module UiBibz::Ui::Core::Navs
18
18
  # You can pass arguments in options attribute:
19
19
  # * +type+ - Symbol
20
20
  # (+:pills+, +:tab+)
21
+ # * +position+ - Symbol
22
+ # (+:left+, +:right+, +:center+)
23
+ # * +stacked+ - Boolean
24
+ # * +tag+ - Symbol
25
+ # (+:a+, +:li)
26
+ # * +justify+ - Boolean
27
+ # * +fill+ - Boolean
21
28
  #
22
29
  # ==== Signatures
23
30
  #
@@ -90,7 +97,7 @@ module UiBibz::Ui::Core::Navs
90
97
  private
91
98
 
92
99
  def component_html_classes
93
- ["nav", type, position, stacked]
100
+ ["nav", type, position, stacked, justify, fill]
94
101
  end
95
102
 
96
103
  # tabs or pills
@@ -99,11 +106,32 @@ module UiBibz::Ui::Core::Navs
99
106
  end
100
107
 
101
108
  def position
102
- "pull-#{ @options[:position] }" unless @options[:position].nil?
109
+ case @options[:position]
110
+ when :center
111
+ "justify-content-center"
112
+ when :right
113
+ "justify-content-end"
114
+ else
115
+ nil
116
+ end
117
+ end
118
+
119
+ def justify
120
+ if @options[:justify]
121
+ if type == "nav-links"
122
+ "nav-justified"
123
+ else
124
+ "nav-fill"
125
+ end
126
+ end
127
+ end
128
+
129
+ def fill
130
+ "nav-fill" if @options[:fill]
103
131
  end
104
132
 
105
133
  def stacked
106
- "nav-stacked" unless @options[:stacked].nil?
134
+ "flex-column" if @options[:stacked]
107
135
  end
108
136
 
109
137
  def tag
@@ -25,6 +25,8 @@ module UiBibz::Ui::Core::Navs
25
25
  # (+:secondary+, +:primary+, +:info+, +:warning+, +:danger+, +inverse+)
26
26
  # * +position+ - Symbol
27
27
  # (+:top+, +:bottom+)
28
+ # * +position_type+ - Symbol
29
+ # (+:fixed+, +:sticky+)
28
30
  # * +title+ - String
29
31
  #
30
32
  # ==== Signatures
@@ -55,13 +57,15 @@ module UiBibz::Ui::Core::Navs
55
57
  #
56
58
  # ==== Helper
57
59
  #
58
- # navbar(options = { tap: true }, html_options = {}) do |nb|
60
+ # ui_navbar(options = { tap: true }, html_options = {}) do |nb|
59
61
  # nb.nav(options = { tap: true }, html_options = {}) do |n|
60
62
  # n.link(content, options = {}, html_options = {})
61
63
  # n.link(options = {}, html_options = {}) do
62
64
  # content
63
65
  # end
64
66
  # end
67
+ # nb.brand content
68
+ # nb.link 'toto', "#"
65
69
  # end
66
70
  #
67
71
  class Navbar < UiBibz::Ui::Core::Component
@@ -75,10 +79,10 @@ module UiBibz::Ui::Core::Navs
75
79
  # Render html tag
76
80
  def render
77
81
  content_tag :nav, html_options do
78
- content_tag :div, class: 'container-fluid' do
79
- concat header_html
80
- concat body_html
81
- end
82
+ concat title if brand_position == :left
83
+ concat navbar_toggle_button_html
84
+ concat title if brand_position == :right
85
+ concat body_html
82
86
  end
83
87
  end
84
88
 
@@ -98,24 +102,22 @@ module UiBibz::Ui::Core::Navs
98
102
  # Not use !!!!!
99
103
  # Add navbar text items
100
104
  # See UiBibz::Ui::Core::NavbarText
101
- #def text content = nil, options = nil, html_options = nil, &block
102
- #@items << UiBibz::Ui::Core::NavbarText.new(content, options, html_options, &block).render
103
- #end
105
+ def text content = nil, options = nil, html_options = nil, &block
106
+ @items << UiBibz::Ui::Core::Navs::NavbarText.new(content, options, html_options, &block).render
107
+ end
104
108
 
105
109
  def brand content = nil, options = nil, html_options = nil, &block
106
110
  @brand = UiBibz::Ui::Core::Navs::NavbarBrand.new(content, options, html_options, &block).render
107
111
  end
108
112
 
113
+ def id
114
+ @id ||= generate_id("navbar-id")
115
+ end
116
+
109
117
  private
110
118
 
111
119
  def component_html_classes
112
- ['navbar', type, position]
113
- end
114
-
115
- def header_html
116
- content_tag :div, class: 'navbar-header' do
117
- concat navbar_toggle_button_html
118
- end
120
+ ['navbar', type, position, expand_size]
119
121
  end
120
122
 
121
123
  def title
@@ -127,22 +129,30 @@ module UiBibz::Ui::Core::Navs
127
129
  end
128
130
 
129
131
  def body_html
130
- content_tag :div, class: "collapse navbar-toggleable-xs", id: id do
131
- concat title
132
+ content_tag :div, class: "collapse navbar-collapse", id: id do
132
133
  concat @items.join.html_safe
133
134
  end
134
135
  end
135
136
 
136
- def id
137
- @id ||= "navbar-collapse-#{ Random.new_seed }"
138
- end
139
-
140
137
  def navbar_toggle_button_html
141
138
  content_tag :button, "☰", class: 'navbar-toggler hidden-sm-up', type: :button, data: { toggle: 'collapse', target:"##{ id }" }
142
139
  end
143
140
 
141
+ def expand_size
142
+ "navbar-expand-#{ @options[:expand_size] || :lg }" #unless @options[:expand_size].nil?
143
+ end
144
+
144
145
  def position
145
- "navbar-fixed-#{ @options[:position] }" unless @options[:position].nil?
146
+ "#{ position_type }-#{ @options[:position] }" unless @options[:position].nil?
147
+ end
148
+
149
+ def brand_position
150
+ @options[:brand_position] || :left
151
+ end
152
+
153
+ # fixed || sticky
154
+ def position_type
155
+ @options[:position_type] || "fixed"
146
156
  end
147
157
 
148
158
  def type
@@ -0,0 +1,97 @@
1
+ require 'ui_bibz/ui/core/navs/components/pagination_link'
2
+ module UiBibz::Ui::Core::Navs
3
+
4
+ # Create a Pagination
5
+ #
6
+ # This element is an extend of UiBibz::Ui::Core::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
+ # * +position+ - Symbol
19
+ # (+:left+, +:right+, +:center+)
20
+ # * +size+
21
+ # (+:sm+, +:lg+)
22
+ #
23
+ # ==== Signatures
24
+ #
25
+ # UiBibz::Ui::Core::Navs::Pagination.new(content, options = nil, html_options = nil)
26
+ #
27
+ # UiBibz::Ui::Core::Navs::Pagination.new(options = nil, html_options = nil).tap do |n|
28
+ # ...
29
+ # n.link content = nil, options = nil, html_options = nil, block
30
+ # n.link content = nil, options = nil, html_options = nil, block
31
+ # n.dropdown content = nil, options = nil, html_options = nil, block
32
+ # ...
33
+ # end
34
+ #
35
+ # ==== Examples
36
+ #
37
+ # UiBibz::Ui::Core::Navs::Pagination.new(type: :pills).tap do |n|
38
+ # n.link 'Test', url: '#test'
39
+ # n.link 'Test2', url: '#test2', state: :active
40
+ # n.dropdown('Action') do |d|
41
+ # d.list content = nil, options = nil, html_options = nil, &block
42
+ # end
43
+ # end.render
44
+ #
45
+ # ==== Helper
46
+ #
47
+ # ui_pagination(options = { tap: true }, html_options = {}) do |n|
48
+ # n.link(content, options = {}, html_options = {})
49
+ # n.link(options = {}, html_options = {}) do
50
+ # content
51
+ # end
52
+ # end
53
+ #
54
+ class Pagination < UiBibz::Ui::Core::Component
55
+
56
+ # See UiBibz::Ui::Core::Component.initialize
57
+ def initialize content = nil, options = nil, html_options = nil, &block
58
+ super
59
+ @items = []
60
+ end
61
+
62
+ # Render html tag
63
+ def render
64
+ content_tag :nav do
65
+ content_tag :ul, @items.join.html_safe, html_options
66
+ end
67
+ end
68
+
69
+ # Add nav link items
70
+ # See UiBibz::Ui::Core::Navs::NavLink
71
+ def link content = nil, options = {}, html_options = nil, &block
72
+ @items << PaginationLink.new(content, options, html_options, &block).render
73
+ end
74
+
75
+ private
76
+
77
+ def component_html_classes
78
+ ["pagination", position, size]
79
+ end
80
+
81
+ def position
82
+ case @options[:position]
83
+ when :center
84
+ "justify-content-center"
85
+ when :right
86
+ "justify-content-end"
87
+ else
88
+ nil
89
+ end
90
+ end
91
+
92
+ def size
93
+ "pagination-#{ @options[:size] }" if @options[:size]
94
+ end
95
+
96
+ end
97
+ end
@@ -1,4 +1,6 @@
1
- module UiBibz::Ui::Core
1
+ require 'ui_bibz/ui/core/notifications/components/alert_header'
2
+ require 'ui_bibz/ui/core/notifications/components/alert_body'
3
+ module UiBibz::Ui::Core::Notifications
2
4
 
3
5
  # Create an alert
4
6
  #
@@ -45,21 +47,38 @@ module UiBibz::Ui::Core
45
47
  # content
46
48
  # end
47
49
  #
48
- class Alert < Component
50
+ class Alert < UiBibz::Ui::Core::Component
49
51
 
50
52
  # See UiBibz::Ui::Core::Component.initialize
51
53
  def initialize content = nil, options = nil, html_options = nil, &block
52
54
  super
55
+ header(@content) if @options[:tap].nil?
53
56
  end
54
57
 
55
58
  # Render html tag
56
59
  def render
57
60
  content_tag :div, html_options do
58
- concat glyph_and_content_html
59
- concat close_html if options[:closable]
61
+ concat @header
62
+ concat @body unless @body.nil?
60
63
  end
61
64
  end
62
65
 
66
+ # Add Header which is a component
67
+ def header content = nil, options = nil, html_options = nil, &block
68
+ if block.nil?
69
+ options = @options.merge(options || {})
70
+ else
71
+ content = @options.merge(content || {})
72
+ end
73
+
74
+ @header = UiBibz::Ui::Core::Notifications::Components::AlertHeader.new(content, options, html_options, &block).render
75
+ end
76
+
77
+ # Add Body which is a component
78
+ def body content = nil, options = nil, html_options = nil, &block
79
+ @body = UiBibz::Ui::Core::Notifications::Components::AlertBody.new(content, options, html_options, &block).render
80
+ end
81
+
63
82
  private
64
83
 
65
84
  def component_html_classes
@@ -70,13 +89,6 @@ module UiBibz::Ui::Core
70
89
  { role: 'alert'}
71
90
  end
72
91
 
73
- def close_html
74
- content_tag :button, type: 'button', class: 'close', "data-dismiss" => "alert", "aria-label" => "Close" do
75
- concat content_tag :span, "×", "aria-hidden" => true
76
- concat content_tag :span, "Close", class: "sr-only"
77
- end
78
- end
79
-
80
92
  def status
81
93
  "alert-#{ options[:status] || :info }"
82
94
  end
@@ -0,0 +1,50 @@
1
+ module UiBibz::Ui::Core::Notifications::Components
2
+
3
+ # Create a alert body
4
+ #
5
+ # ==== Attributes
6
+ #
7
+ # * +content+ - Content of element
8
+ # * +options+ - Options of element
9
+ # * +html_options+ - Html Options of element
10
+ #
11
+ # ==== Options
12
+ #
13
+ # You can add HTML attributes using the +html_options+.
14
+ # You can pass arguments in options attribute:
15
+ #
16
+ # ==== Signatures
17
+ #
18
+ # UiBibz::Ui::Core::Notifications::AlertBody.new(content, options = nil, html_options = nil)
19
+ #
20
+ # UiBibz::Ui::Core::Notifications::AlertBody.new(options = nil, html_options = nil) do
21
+ # content
22
+ # end
23
+ #
24
+ # ==== Examples
25
+ #
26
+ # UiBibz::Ui::Core::Notifications::AlertBody.new.render
27
+ #
28
+ # UiBibz::Ui::Core::Notifications::AlertBody.new do
29
+ # 'Exemple'
30
+ # end.render
31
+ #
32
+ class AlertBody < UiBibz::Ui::Core::Component
33
+
34
+ # See UiBibz::Ui::Core::Component.initialize
35
+ def initialize content = nil, options = nil, html_options = nil, &block
36
+ super
37
+ end
38
+
39
+ def render
40
+ tag(:hr) + content_tag(:p, content, html_options)
41
+ end
42
+
43
+ private
44
+
45
+ def component_html_classes
46
+ "alert-body mb-0"
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,67 @@
1
+ module UiBibz::Ui::Core::Notifications::Components
2
+
3
+ # Create a alert body
4
+ #
5
+ # ==== Attributes
6
+ #
7
+ # * +content+ - Content of element
8
+ # * +options+ - Options of element
9
+ # * +html_options+ - Html Options of element
10
+ #
11
+ # ==== Options
12
+ #
13
+ # You can add HTML attributes using the +html_options+.
14
+ # You can pass arguments in options attribute:
15
+ #
16
+ # ==== Signatures
17
+ #
18
+ # UiBibz::Ui::Core::Notifications::AlertHeader.new(content, options = nil, html_options = nil)
19
+ #
20
+ # UiBibz::Ui::Core::Notifications::AlertHeader.new(options = nil, html_options = nil) do
21
+ # content
22
+ # end
23
+ #
24
+ # ==== Examples
25
+ #
26
+ # UiBibz::Ui::Core::Notifications::AlertHeader.new.render
27
+ #
28
+ # UiBibz::Ui::Core::Notifications::AlertHeader.new do
29
+ # 'Exemple'
30
+ # end.render
31
+ #
32
+ class AlertHeader < UiBibz::Ui::Core::Component
33
+
34
+ # See UiBibz::Ui::Core::Component.initialize
35
+ def initialize content = nil, options = nil, html_options = nil, &block
36
+ super
37
+ end
38
+
39
+ def render
40
+ if options[:tap]
41
+ content_tag :h4, html_content, html_options
42
+ else
43
+ html_content
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def component_html_classes
50
+ "alert-header"
51
+ end
52
+
53
+ def html_content
54
+ output = [glyph_and_content_html]
55
+ output << close_html if options[:closable]
56
+ output.join.html_safe
57
+ end
58
+
59
+ def close_html
60
+ content_tag :button, type: 'button', class: 'close', "data-dismiss" => "alert", "aria-label" => "Close" do
61
+ concat content_tag :span, "×", "aria-hidden" => true
62
+ concat content_tag :span, "Close", class: "sr-only"
63
+ end
64
+ end
65
+
66
+ end
67
+ end
@@ -1,6 +1,6 @@
1
- module UiBibz::Ui::Core
1
+ module UiBibz::Ui::Core::Progresses::Components
2
2
 
3
- # Create a progress bar
3
+ # Create a bar
4
4
  #
5
5
  # This element is an extend of UiBibz::Ui::Core::Component.
6
6
  #
@@ -17,69 +17,62 @@ module UiBibz::Ui::Core
17
17
  # * +status+ - status of élement with symbol value:
18
18
  # (+:secondary+, +:primary+, +:info+, +:warning+, +:danger+)
19
19
  # * +max+ - Max value (default: 100)
20
+ # * +min+ - Min value (default: 0)
20
21
  # * +value+ - Value of percentage (default: content)
21
22
  # * +animated+ - Boolean
22
23
  # * +striped+ - Boolean
23
24
  #
24
- #
25
25
  # ==== Signatures
26
26
  #
27
- # UiBibz::Ui::Core::Progress.new(percentage, options = nil, html_options = nil)
27
+ # UiBibz::Ui::Core::Bar.new(percentage, options = nil, html_options = nil)
28
28
  #
29
- # UiBibz::Ui::Core::Progress.new(options = nil, html_options = nil) do
29
+ # UiBibz::Ui::Core::Bar.new(options = nil, html_options = nil) do
30
30
  # percentage
31
31
  # end
32
32
  #
33
33
  # ==== Examples
34
34
  #
35
- # UiBibz::Ui::Core::Progress.new(50%, { value: 50})
35
+ # UiBibz::Ui::Core::Bar.new(50%, { value: 50})
36
36
  # # or
37
- # UiBibz::Ui::Core::Progress.new(10%, { value: 10, status: :success },{ class: 'test' }).render
37
+ # UiBibz::Ui::Core::Bar.new(10%, { value: 10, status: :success },{ class: 'test' }).render
38
38
  # # or
39
- # UiBibz::Ui::Core::Progress.new({ value: 10, status: :success},{ class: 'test' }) do
39
+ # UiBibz::Ui::Core::Bar.new({ value: 10, status: :success},{ class: 'test' }) do
40
40
  # 10%
41
41
  # end.render
42
42
  #
43
- # ==== Helper
44
- #
45
- # progress(integer, options = {}, html_options = {})
46
- #
47
- # progress(options = { tap: true }, html_options = {}) do |pb|
48
- # pb.bar(integer, options = {}, html_options = {})
49
- # pb.bar(options = {}, html_options = {}) do
50
- # integer
51
- # end
52
- # end
53
- #
54
- class Progress < Component
43
+ class Bar < UiBibz::Ui::Core::Component
55
44
 
56
45
  # See UiBibz::Ui::Core::Component.initialize
57
46
  def initialize content = nil, options = nil, html_options = nil, &block
58
47
  super
59
- @bars = []
60
48
  end
61
49
 
62
50
  # Render html tag
63
51
  def render
64
- content_tag :progress, content, html_options
52
+ content_tag :div, '', html_options
65
53
  end
66
54
 
67
55
  private
68
56
 
69
57
  def component_html_classes
70
- ['progress', striped, animated]
58
+ ['progress-bar', striped, animated]
71
59
  end
72
60
 
73
61
  def component_html_options
74
- { max: max, value: value }
62
+ { "aria-valuenow": value, "aria-valuemin": min, "aria-valuemax": max, style: "width: #{ value }%", role: 'progressbar' }
75
63
  end
76
64
 
77
65
  def striped
78
- 'progress-striped' unless options[:striped].nil?
66
+ 'progress-bar-striped' unless options[:striped].nil?
79
67
  end
80
68
 
81
69
  def animated
82
- 'progress-animated' unless options[:animated].nil?
70
+ 'progress-bar-animated' unless options[:animated].nil?
71
+ end
72
+
73
+
74
+ def min
75
+ options[:min] || 0
83
76
  end
84
77
 
85
78
  def max
@@ -87,11 +80,11 @@ module UiBibz::Ui::Core
87
80
  end
88
81
 
89
82
  def value
90
- options[:value] || content.to_i
83
+ options[:value] || content.to_f
91
84
  end
92
85
 
93
86
  def status
94
- "progress-#{ options[:status] }" unless options[:status].nil?
87
+ "bg-#{ options[:status] }" unless options[:status].nil?
95
88
  end
96
89
 
97
90
  end
@@ -0,0 +1,115 @@
1
+ require 'ui_bibz/ui/core/progresses/components/bar'
2
+ module UiBibz::Ui::Core::Progresses
3
+
4
+ # Create a progress bar
5
+ #
6
+ # This element is an extend of UiBibz::Ui::Core::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
+ # * +status+ - status of élement with symbol value:
19
+ # (+:secondary+, +:primary+, +:info+, +:warning+, +:danger+)
20
+ # * +value+ - Value of percentage (default: content)
21
+ # * +animated+ - Boolean
22
+ # * +striped+ - Boolean
23
+ # * +stacked+ - Boolean
24
+ # * +line+ - Boolean
25
+ #
26
+ #
27
+ # ==== Signatures
28
+ #
29
+ # UiBibz::Ui::Core::ProgressBar.new(percentage, options = nil, html_options = nil)
30
+ #
31
+ # UiBibz::Ui::Core::ProgressBar.new(options = nil, html_options = nil) do
32
+ # percentage
33
+ # end
34
+ #
35
+ # ==== Examples
36
+ #
37
+ # UiBibz::Ui::Core::ProgressBar.new(50%, { value: 50})
38
+ # # or
39
+ # UiBibz::Ui::Core::ProgressBar.new(10%, { value: 10, status: :success },{ class: 'test' }).render
40
+ # # or
41
+ # UiBibz::Ui::Core::ProgressBar.new({ value: 10, status: :success},{ class: 'test' }) do
42
+ # 10%
43
+ # end.render
44
+ #
45
+ # ==== Helper
46
+ #
47
+ # ui_progress_bar(integer, options = {}, html_options = {})
48
+ #
49
+ # ui_progress_bar(options = { tap: true }, html_options = {}) do |pb|
50
+ # pb.bar(integer, options = {}, html_options = {})
51
+ # pb.bar(options = {}, html_options = {}) do
52
+ # integer
53
+ # end
54
+ # end
55
+ #
56
+ class ProgressBar < UiBibz::Ui::Core::Component
57
+
58
+ # See UiBibz::Ui::Core::Component.initialize
59
+ def initialize content = nil, options = nil, html_options = nil, &block
60
+ super
61
+ @bars = []
62
+ end
63
+
64
+ # Render html tag
65
+ def render
66
+ content_tag :div, bars.join.html_safe, html_options
67
+ end
68
+
69
+ def bar content = nil, options = nil, html_options = nil, &block
70
+ @bars << UiBibz::Ui::Core::Progresses::Components::Bar.new(content, options, html_options, &block).render
71
+ end
72
+
73
+ private
74
+
75
+ def component_html_classes
76
+ ['progress', line]
77
+ end
78
+
79
+ def bars
80
+ if @bars.size > 0
81
+ @bars
82
+ elsif options[:stacked]
83
+ stacked_bars
84
+ else
85
+ [UiBibz::Ui::Core::Progresses::Components::Bar.new(content, options).render]
86
+ end
87
+ end
88
+
89
+ def line
90
+ "progress-bar-line" if options[:line]
91
+ end
92
+
93
+ def stacked_bars
94
+ percentages = [7.4, 15.3, 21.1, 25.9, 30.3, 100]
95
+ stacked_colors.map.with_index do |color, i|
96
+ if percentages[0, i].sum <= content.to_f
97
+ if content.to_f.between?(percentages[0, i].sum , percentages[0, i+1].sum)
98
+ UiBibz::Ui::Core::Progresses::Components::Bar.new((content.to_f*percentages[i]/100), min: 0, striped: options[:striped], animated: options[:animated], max: 100, status: color).render
99
+ else
100
+ UiBibz::Ui::Core::Progresses::Components::Bar.new(percentages[i], min: 0, striped: options[:striped], animated: options[:animated], max: 100, status: color).render
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ def stacked_colors
107
+ if options[:inverse]
108
+ %i(success primary info warning danger).reverse
109
+ else
110
+ %i(success primary info warning danger)
111
+ end
112
+ end
113
+
114
+ end
115
+ end
@@ -39,8 +39,8 @@ module UiBibz::Ui::Core::Windows::Components
39
39
  # Render html tag
40
40
  def render
41
41
  content_tag :div, html_options do
42
+ concat content_tag :h5, glyph_and_content_html, class: 'modal-title'
42
43
  concat close_button_html
43
- concat content_tag :h4, glyph_and_content_html, class: 'modal-title'
44
44
  end
45
45
  end
46
46
 
@@ -1,8 +1,8 @@
1
1
  module GlyphExtension
2
2
 
3
3
  # Render glyph and content html
4
- def glyph_and_content_html
5
- [glyph_with_space, content].compact.join.html_safe
4
+ def glyph_and_content_html content_html = nil
5
+ [glyph_with_space, content_html || content].compact.join.html_safe
6
6
  end
7
7
 
8
8
  # Render glyph with space html