ui_bibz 1.2.5.3 → 2.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +10 -7
- data/README.md +8 -1042
- data/app/assets/javascripts/multi_column.coffee +45 -0
- data/app/assets/javascripts/{ui_bibz.js.coffee → ui_bibz.coffee} +16 -3
- data/app/assets/stylesheets/fix-bootstrap-4.sass +2 -0
- data/app/assets/stylesheets/ui_bibz.sass +22 -9
- data/app/inputs/custom_inputs/date_picker_input.rb +10 -0
- data/app/inputs/custom_inputs/date_picker_input_old.rb +61 -0
- data/app/inputs/custom_inputs/multi_column_input.rb +18 -0
- data/app/inputs/custom_inputs/multi_select_input.rb +15 -0
- data/app/inputs/custom_inputs/surround_input.rb +10 -0
- data/doc/UiBibz.html +2 -2
- data/doc/UiBibz/Concerns.html +1 -1
- data/doc/UiBibz/Concerns/Models.html +1 -1
- data/doc/UiBibz/Concerns/Models/Searchable.html +1 -1
- data/doc/UiBibz/Concerns/Models/Searchable/ClassMethods.html +5 -5
- data/doc/UiBibz/Helpers.html +1 -1
- data/doc/UiBibz/Helpers/MetaHelper.html +1 -1
- data/doc/UiBibz/Helpers/UiCoreHelper.html +1 -1
- data/doc/UiBibz/Helpers/UiUxHelper.html +1 -1
- data/doc/UiBibz/Helpers/UtilsHelper.html +1 -1
- data/doc/UiBibz/Rails.html +1 -1
- data/doc/UiBibz/Rails/Engine.html +1 -1
- data/doc/UiBibz/Ui.html +1 -1
- data/doc/UiBibz/Ui/Base.html +1 -1
- data/doc/UiBibz/Ui/Core.html +1 -1
- data/doc/UiBibz/Ui/Core/Alert.html +1 -1
- data/doc/UiBibz/Ui/Core/Bar.html +1 -1
- data/doc/UiBibz/Ui/Core/Breadcrumb.html +1 -1
- data/doc/UiBibz/Ui/Core/BreadcrumbLink.html +1 -1
- data/doc/UiBibz/Ui/Core/Button.html +1 -1
- data/doc/UiBibz/Ui/Core/ButtonDropdown.html +1 -1
- data/doc/UiBibz/Ui/Core/ButtonGroup.html +1 -1
- data/doc/UiBibz/Ui/Core/ButtonLink.html +1 -1
- data/doc/UiBibz/Ui/Core/ButtonSplitDropdown.html +1 -1
- data/doc/UiBibz/Ui/Core/Col.html +1 -1
- data/doc/UiBibz/Ui/Core/Component.html +1 -1
- data/doc/UiBibz/Ui/Core/Dropdown.html +1 -1
- data/doc/UiBibz/Ui/Core/DropdownDivider.html +1 -1
- data/doc/UiBibz/Ui/Core/DropdownHeader.html +1 -1
- data/doc/UiBibz/Ui/Core/DropdownLink.html +1 -1
- data/doc/UiBibz/Ui/Core/Glyph.html +1 -1
- data/doc/UiBibz/Ui/Core/Jumbotron.html +1 -1
- data/doc/UiBibz/Ui/Core/Label.html +1 -1
- data/doc/UiBibz/Ui/Core/List.html +1 -1
- data/doc/UiBibz/Ui/Core/ListGroup.html +1 -1
- data/doc/UiBibz/Ui/Core/Modal.html +1 -1
- data/doc/UiBibz/Ui/Core/ModalBody.html +1 -1
- data/doc/UiBibz/Ui/Core/ModalFooter.html +1 -1
- data/doc/UiBibz/Ui/Core/ModalHeader.html +1 -1
- data/doc/UiBibz/Ui/Core/Nav.html +1 -1
- data/doc/UiBibz/Ui/Core/NavDropdown.html +1 -1
- data/doc/UiBibz/Ui/Core/NavLink.html +1 -1
- data/doc/UiBibz/Ui/Core/Navbar.html +1 -1
- data/doc/UiBibz/Ui/Core/NavbarForm.html +1 -1
- data/doc/UiBibz/Ui/Core/NavbarNav.html +1 -1
- data/doc/UiBibz/Ui/Core/NavbarText.html +1 -1
- data/doc/UiBibz/Ui/Core/Panel.html +1 -1
- data/doc/UiBibz/Ui/Core/ProgressBar.html +1 -1
- data/doc/UiBibz/Ui/Core/Row.html +1 -1
- data/doc/UiBibz/Ui/Core/Stars.html +1 -1
- data/doc/UiBibz/Ui/Ux.html +1 -1
- data/doc/UiBibz/Ui/Ux/Actionable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Actions.html +1 -1
- data/doc/UiBibz/Ui/Ux/Column.html +1 -1
- data/doc/UiBibz/Ui/Ux/Columns.html +1 -1
- data/doc/UiBibz/Ui/Ux/Grid.html +1 -1
- data/doc/UiBibz/Ui/Ux/Paginable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Searchable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Sortable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Store.html +18 -70
- data/doc/UiBibz/Ui/Ux/Table.html +1 -1
- data/doc/UiBibz/Ui/Ux/TablePagination.html +1 -1
- data/doc/UiBibz/Ui/Ux/TablePaginationPerPage.html +1 -1
- data/doc/UiBibz/Ui/Ux/TablePanel.html +1 -1
- data/doc/UiBibz/Ui/Ux/TableSearchField.html +1 -1
- data/doc/UiBibz/Utils.html +1 -1
- data/doc/UiBibz/Utils/Internationalization.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +47 -51
- data/doc/index.html +47 -51
- data/doc/method_list.html +69 -75
- data/doc/top-level-namespace.html +1 -1
- data/lib/ui_bibz.rb +14 -7
- data/lib/ui_bibz/helpers/ui_core_helper.rb +46 -11
- data/lib/ui_bibz/helpers/ui_ux_helper.rb +7 -3
- data/lib/ui_bibz/rails/engine.rb +2 -2
- data/lib/ui_bibz/ui/base.rb +5 -0
- data/lib/ui_bibz/ui/core/alert.rb +15 -6
- data/lib/ui_bibz/ui/core/breadcrumb/breadcrumb.rb +37 -2
- data/lib/ui_bibz/ui/core/breadcrumb/components/breadcrumb_link.rb +3 -3
- data/lib/ui_bibz/ui/core/button/button.rb +39 -6
- data/lib/ui_bibz/ui/core/button/button_choice.rb +104 -0
- data/lib/ui_bibz/ui/core/button/button_dropdown.rb +15 -2
- data/lib/ui_bibz/ui/core/button/button_group.rb +17 -5
- data/lib/ui_bibz/ui/core/button/button_link.rb +8 -11
- data/lib/ui_bibz/ui/core/button/button_split_dropdown.rb +15 -5
- data/lib/ui_bibz/ui/core/card/card.rb +158 -0
- data/lib/ui_bibz/ui/core/card/card_column.rb +60 -0
- data/lib/ui_bibz/ui/core/card/card_deck.rb +62 -0
- data/lib/ui_bibz/ui/core/card/card_group.rb +60 -0
- data/lib/ui_bibz/ui/core/card/components/block/card_block_link.rb +51 -0
- data/lib/ui_bibz/ui/core/card/components/block/card_block_text.rb +51 -0
- data/lib/ui_bibz/ui/core/card/components/block/card_block_title.rb +51 -0
- data/lib/ui_bibz/ui/core/card/components/card_block.rb +67 -0
- data/lib/ui_bibz/ui/core/card/components/card_footer.rb +55 -0
- data/lib/ui_bibz/ui/core/card/components/card_header.rb +51 -0
- data/lib/ui_bibz/ui/core/card/components/card_image.rb +57 -0
- data/lib/ui_bibz/ui/core/card/components/card_list_group.rb +47 -0
- data/lib/ui_bibz/ui/core/component.rb +78 -32
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_divider.rb +1 -1
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_header.rb +11 -1
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb +11 -4
- data/lib/ui_bibz/ui/core/dropdown/dropdown.rb +14 -6
- data/lib/ui_bibz/ui/core/glyph.rb +22 -4
- data/lib/ui_bibz/ui/core/input/date_picker_field.rb +125 -0
- data/lib/ui_bibz/ui/core/input/multi_column_field.rb +77 -0
- data/lib/ui_bibz/ui/core/input/multi_select_field.rb +89 -0
- data/lib/ui_bibz/ui/core/input/surround_field.rb +74 -0
- data/lib/ui_bibz/ui/core/jumbotron.rb +10 -6
- data/lib/ui_bibz/ui/core/label.rb +13 -3
- data/lib/ui_bibz/ui/core/{col.rb → layout/col.rb} +38 -18
- data/lib/ui_bibz/ui/core/layout/container.rb +65 -0
- data/lib/ui_bibz/ui/core/{row.rb → layout/row.rb} +7 -1
- data/lib/ui_bibz/ui/core/list/components/list.rb +26 -11
- data/lib/ui_bibz/ui/core/list/components/list_body.rb +36 -0
- data/lib/ui_bibz/ui/core/list/components/list_header.rb +36 -0
- data/lib/ui_bibz/ui/core/list/list_group.rb +7 -3
- data/lib/ui_bibz/ui/core/modal/components/modal_body.rb +7 -1
- data/lib/ui_bibz/ui/core/modal/components/modal_footer.rb +7 -1
- data/lib/ui_bibz/ui/core/modal/components/modal_header.rb +5 -2
- data/lib/ui_bibz/ui/core/modal/modal.rb +13 -2
- data/lib/ui_bibz/ui/core/nav/components/nav_dropdown.rb +6 -2
- data/lib/ui_bibz/ui/core/nav/components/nav_link.rb +7 -18
- data/lib/ui_bibz/ui/core/nav/components/nav_link_link.rb +45 -0
- data/lib/ui_bibz/ui/core/nav/components/nav_link_list.rb +35 -0
- data/lib/ui_bibz/ui/core/nav/components/navbar_brand.rb +40 -0
- data/lib/ui_bibz/ui/core/nav/components/navbar_form.rb +2 -2
- data/lib/ui_bibz/ui/core/nav/components/navbar_nav.rb +1 -1
- data/lib/ui_bibz/ui/core/nav/components/navbar_text.rb +6 -2
- data/lib/ui_bibz/ui/core/nav/nav.rb +22 -4
- data/lib/ui_bibz/ui/core/nav/navbar.rb +26 -17
- data/lib/ui_bibz/ui/core/progress.rb +98 -0
- data/lib/ui_bibz/ui/core/stars.rb +13 -5
- data/lib/ui_bibz/ui/ux/table/components/actions.rb +4 -0
- data/lib/ui_bibz/ui/ux/table/components/store.rb +4 -4
- data/lib/ui_bibz/ui/ux/table/extensions/actionable.rb +15 -13
- data/lib/ui_bibz/ui/ux/table/extensions/paginable.rb +7 -6
- data/lib/ui_bibz/ui/ux/table/extensions/searchable.rb +6 -5
- data/lib/ui_bibz/ui/ux/table/table.rb +14 -7
- data/lib/ui_bibz/ui/ux/table/{table_panel.rb → table_card.rb} +34 -36
- data/lib/ui_bibz/ui/ux/table/table_search_field.rb +19 -11
- data/lib/ui_bibz/version.rb +1 -1
- data/test/ui/breadcrumb_test.rb +25 -0
- data/test/ui/button_test.rb +44 -4
- data/test/ui/card_test.rb +106 -0
- data/test/ui/col_test.rb +22 -0
- data/test/ui/dropdown_test.rb +1 -1
- data/test/ui/inputs_test.rb +81 -0
- data/test/ui/list_group_test.rb +1 -1
- data/test/ui/nav_test.rb +4 -5
- data/test/ui/table_test.rb +11 -11
- data/test/ui_helper_test.rb +29 -18
- data/ui_bibz.gemspec +3 -3
- data/vendor/assets/images/switch.png +0 -0
- data/vendor/assets/javascripts/bootstrap-4.0.0-alpha.min.js +7 -0
- data/vendor/assets/javascripts/bootstrap-multiselect.min.js +1180 -0
- data/vendor/assets/javascripts/jquery.multi-select.min.js +1 -0
- data/vendor/assets/javascripts/jquery.quicksearch.min.js +1 -0
- data/vendor/assets/stylesheets/bootstrap-4.0.0-alpha.min.css +6 -0
- data/vendor/assets/stylesheets/bootstrap-datepicker3.min.css +1 -1
- data/vendor/assets/stylesheets/bootstrap-multiselect.min.css +1 -0
- data/vendor/assets/stylesheets/multi-select.min.css +1 -0
- metadata +70 -24
- data/.yardoc/checksums +0 -59
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/lib/ui_bibz/helpers/meta_helper.rb +0 -32
- data/lib/ui_bibz/ui/core/panel.rb +0 -138
- data/lib/ui_bibz/ui/core/progress_bar/components/bar.rb +0 -105
- data/lib/ui_bibz/ui/core/progress_bar/progress_bar.rb +0 -94
- data/lib/ui_bibz/ui/ux/grid.rb +0 -121
- data/test/ui/grid_test.rb +0 -46
- data/test/ui/panel_test.rb +0 -52
@@ -1,105 +0,0 @@
|
|
1
|
-
module UiBibz::Ui::Core
|
2
|
-
|
3
|
-
# Create a NavLink
|
4
|
-
#
|
5
|
-
# This element is an extend of UiBibz::Ui::Core::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
|
-
# * label - String (default: "percentage%")
|
20
|
-
# * percentage_min - Integer (default: 0)
|
21
|
-
# * percentage_max - Integer (default: 100)
|
22
|
-
# * sr_only - Boolean to show label (default: false)
|
23
|
-
# * type
|
24
|
-
# (+:striped+, +:animated+)
|
25
|
-
#
|
26
|
-
# ==== Signatures
|
27
|
-
#
|
28
|
-
# UiBibz::Ui::Core::Bar.new(percentage, options = nil, html_options = nil)
|
29
|
-
#
|
30
|
-
# UiBibz::Ui::Core::Bar.new(options = nil, html_options = nil) do
|
31
|
-
# percentage
|
32
|
-
# end
|
33
|
-
#
|
34
|
-
# ==== Examples
|
35
|
-
#
|
36
|
-
# UiBibz::Ui::Core::Bar.new(10)
|
37
|
-
# # or
|
38
|
-
# UiBibz::Ui::Core::Bar.new(10, { state: :success, sr_only: true, label: 'Loading...' },{ class: 'test' }).render
|
39
|
-
# # or
|
40
|
-
# UiBibz::Ui::Core::Bar.new({ state: :primary }) do
|
41
|
-
# 40
|
42
|
-
# end.render
|
43
|
-
#
|
44
|
-
class Bar < Component
|
45
|
-
|
46
|
-
# See UiBibz::Ui::Core::Component.initialize
|
47
|
-
def initialize content = nil, options = nil, html_options = nil, &block
|
48
|
-
super
|
49
|
-
end
|
50
|
-
|
51
|
-
# Render html tag
|
52
|
-
def render
|
53
|
-
content_tag :div, progressbar_inner_html, class_and_html_options(['progress-bar', type]).merge(bar_html_options)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def bar_html_options
|
59
|
-
{
|
60
|
-
"role" => 'progressbar',
|
61
|
-
"aria-valuenow" => percentage,
|
62
|
-
"aria-valuemin" => percentage_min,
|
63
|
-
"aria-valuemax" => percentage_max,
|
64
|
-
"style" => "width: #{ percentage }%"
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
def progressbar_inner_html
|
69
|
-
sr_only ? content_tag(:span, label, class: 'sr-only') : label
|
70
|
-
end
|
71
|
-
|
72
|
-
def percentage
|
73
|
-
@content || 0
|
74
|
-
end
|
75
|
-
|
76
|
-
def sr_only
|
77
|
-
@options[:sr_only] || false
|
78
|
-
end
|
79
|
-
|
80
|
-
def percentage_min
|
81
|
-
@options[:percentage_min] || 0
|
82
|
-
end
|
83
|
-
|
84
|
-
def percentage_max
|
85
|
-
@options[:percentage_max] || 100
|
86
|
-
end
|
87
|
-
|
88
|
-
def label
|
89
|
-
@options[:label].nil? ? "#{ percentage }%" : @options[:label]
|
90
|
-
end
|
91
|
-
|
92
|
-
def type
|
93
|
-
if @options[:type] == :animated
|
94
|
-
"progress-bar-striped active"
|
95
|
-
elsif @options[:type]
|
96
|
-
"progress-bar-#{ @options[:type] }"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def state
|
101
|
-
"progress-bar-#{ @options[:state] }" unless @options[:state].nil?
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'ui_bibz/ui/core/progress_bar/components/bar'
|
2
|
-
module UiBibz::Ui::Core
|
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
|
-
# * +state+ - State of élement with symbol value:
|
19
|
-
# (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
|
20
|
-
# * label - String (default: "percentage%")
|
21
|
-
# * tap - Boolean (true: To add several bars)
|
22
|
-
# * percentage_min - Integer (default: 0)
|
23
|
-
# * percentage_max - Integer (default: 100)
|
24
|
-
# * sr_only - Boolean to show label (default: false)
|
25
|
-
# * type
|
26
|
-
# (+:striped+, +:animated+)
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# ==== Signatures
|
30
|
-
#
|
31
|
-
# UiBibz::Ui::Core::ProgressBar.new(percentage, options = nil, html_options = nil)
|
32
|
-
#
|
33
|
-
# UiBibz::Ui::Core::ProgressBar.new(options = nil, html_options = nil) do
|
34
|
-
# percentage
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# UiBibz::Ui::Core::ProgressBar.new(tap: true).tap do |pb|
|
38
|
-
# pb.bar percentage, options = nil, html_options = nil
|
39
|
-
# pb.bar options = nil, html_options = nil do
|
40
|
-
# percentage
|
41
|
-
# end
|
42
|
-
# end
|
43
|
-
#
|
44
|
-
# ==== Examples
|
45
|
-
#
|
46
|
-
# UiBibz::Ui::Core::ProgressBar.new(50)
|
47
|
-
# # or
|
48
|
-
# UiBibz::Ui::Core::ProgressBar.new(10, { state: :success, sr_only: false, label: 'Loading...' },{ class: 'test' }).render
|
49
|
-
# # or
|
50
|
-
# UiBibz::Ui::Core::ProgressBar.new(tap: true).tap |pb|
|
51
|
-
# pb.bar 10, { state: :success, sr_only: false, label: 'Loading...' },{ class: 'test' }
|
52
|
-
# pb.bar { state: :primary } do
|
53
|
-
# 20
|
54
|
-
# end
|
55
|
-
# end.render
|
56
|
-
#
|
57
|
-
# ==== Helper
|
58
|
-
#
|
59
|
-
# progress_bar(integer, options = {}, html_options = {})
|
60
|
-
#
|
61
|
-
# progress_bar(options = { tap: true }, html_options = {}) do |pb|
|
62
|
-
# pb.bar(integer, options = {}, html_options = {})
|
63
|
-
# pb.bar(options = {}, html_options = {}) do
|
64
|
-
# integer
|
65
|
-
# end
|
66
|
-
# end
|
67
|
-
#
|
68
|
-
class ProgressBar < Component
|
69
|
-
|
70
|
-
# See UiBibz::Ui::Core::Component.initialize
|
71
|
-
def initialize content = nil, options = nil, html_options = nil, &block
|
72
|
-
super
|
73
|
-
@bars = []
|
74
|
-
end
|
75
|
-
|
76
|
-
# Render html tag
|
77
|
-
def render
|
78
|
-
content_tag :div, content, class: 'progress'
|
79
|
-
end
|
80
|
-
|
81
|
-
# Add progressbar bar items
|
82
|
-
# See UiBibz::Ui::Core::Bar
|
83
|
-
def bar content = nil, options = nil, html_options = nil, &block
|
84
|
-
@bars << Bar.new(content, options, html_options, &block).render
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def content
|
90
|
-
@options[:tap] ? @bars.join().html_safe : Bar.new(@content, @options, @html_options).render
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
data/lib/ui_bibz/ui/ux/grid.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
module UiBibz::Ui::Ux
|
2
|
-
|
3
|
-
# Create a Grid
|
4
|
-
#
|
5
|
-
# This element is an extend of UiBibz::Ui::Ux::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::Ux::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::Ux::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
|
-
# ==== Helper
|
47
|
-
#
|
48
|
-
# grid(options = { tap: true }, html_options = {}) do |g|
|
49
|
-
# g.view(content, options = {}, html_options = {})
|
50
|
-
# g.view(options = {}, html_options = {}) do
|
51
|
-
# content
|
52
|
-
# end
|
53
|
-
# end
|
54
|
-
#
|
55
|
-
class Grid < UiBibz::Ui::Core::Component
|
56
|
-
|
57
|
-
COL_NUM = 12
|
58
|
-
|
59
|
-
def initialize content = nil, options = nil, html_options = nil, &block
|
60
|
-
super
|
61
|
-
@views = {}
|
62
|
-
end
|
63
|
-
|
64
|
-
# Add grid view items
|
65
|
-
def view content = nil, options = nil, html_options = nil, &block
|
66
|
-
o = content.kind_of?(Hash) ? content : options
|
67
|
-
c = UiBibz::Ui::Core::Component.new content, options, html_options, &block
|
68
|
-
h = Hash[o[:position], { component: c, num: o[:num]}]
|
69
|
-
@views = @views.merge(h)
|
70
|
-
end
|
71
|
-
|
72
|
-
# Render html tag
|
73
|
-
def render
|
74
|
-
define_col_nums
|
75
|
-
UiBibz::Ui::Core::Row.new(class: 'grid') do
|
76
|
-
# top
|
77
|
-
concat top_view unless @views[:top].nil?
|
78
|
-
# left
|
79
|
-
concat left_view unless @views[:left].nil?
|
80
|
-
# center
|
81
|
-
concat center_view unless @views[:center].nil?
|
82
|
-
# right
|
83
|
-
concat right_view unless @views[:right].nil?
|
84
|
-
# bottom
|
85
|
-
concat bottom_view unless @views[:bottom].nil?
|
86
|
-
end.render
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
def view_by_num c, num, item_class
|
92
|
-
UiBibz::Ui::Core::Col.new(c.content, c.options.merge({ num: num }), c.class_and_html_options(['col', item_class])).render
|
93
|
-
end
|
94
|
-
|
95
|
-
def top_view
|
96
|
-
view_by_num @views[:top][:component], COL_NUM, 'grid-top'
|
97
|
-
end
|
98
|
-
|
99
|
-
def bottom_view
|
100
|
-
view_by_num @views[:bottom][:component], COL_NUM, 'grid-bottom'
|
101
|
-
end
|
102
|
-
|
103
|
-
def left_view
|
104
|
-
view_by_num @views[:left][:component], @left_val, 'grid-left'
|
105
|
-
end
|
106
|
-
|
107
|
-
def center_view
|
108
|
-
view_by_num @views[:center][:component], COL_NUM-@left_val-@right_val, 'grid-center'
|
109
|
-
end
|
110
|
-
|
111
|
-
def right_view
|
112
|
-
view_by_num @views[:right][:component], @right_val, 'grid-right'
|
113
|
-
end
|
114
|
-
|
115
|
-
def define_col_nums
|
116
|
-
@left_val = @views[:left].nil? ? 0 : (@views[:left][:num] || 1)
|
117
|
-
@right_val = @views[:right].nil? ? 0 : (@views[:right][:num] || 1)
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
data/test/ui/grid_test.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
include UiBibz::Helpers
|
3
|
-
class GridTest < ActionView::TestCase
|
4
|
-
|
5
|
-
test 'row' do
|
6
|
-
actual = UiBibz::Ui::Core::Row.new() do
|
7
|
-
'test'
|
8
|
-
end.render
|
9
|
-
expected = "<div class=\"row\">test</div>"
|
10
|
-
|
11
|
-
assert_equal expected, actual
|
12
|
-
end
|
13
|
-
|
14
|
-
test 'col with simple arg' do
|
15
|
-
actual = UiBibz::Ui::Core::Col.new({ size: :lg, num: 1}) do
|
16
|
-
'test'
|
17
|
-
end.render
|
18
|
-
expected = "<div class=\"col-lg-1\">test</div>"
|
19
|
-
|
20
|
-
assert_equal expected, actual
|
21
|
-
end
|
22
|
-
|
23
|
-
test 'col with multiple args' do
|
24
|
-
actual = UiBibz::Ui::Core::Col.new([{ size: :lg, num: 1, offset: 2}, { num: 1 }], class: 'test') do
|
25
|
-
'test'
|
26
|
-
end.render
|
27
|
-
expected = "<div class=\"test col-lg-1 col-offset-2 col-md-1\">test</div>"
|
28
|
-
|
29
|
-
assert_equal expected, actual
|
30
|
-
end
|
31
|
-
|
32
|
-
test 'grid' do
|
33
|
-
actual = UiBibz::Ui::Ux::Grid.new().tap do |g|
|
34
|
-
g.view position: :left do
|
35
|
-
'left'
|
36
|
-
end
|
37
|
-
g.view 'center', position: :center
|
38
|
-
g.view 'right', position: :right
|
39
|
-
g.view 'bottom', position: :bottom
|
40
|
-
end.render
|
41
|
-
expected = "<div class=\"grid row\"><div class=\"col grid-left col-md-1\">left</div><div class=\"col grid-center col-md-10\">center</div><div class=\"col grid-right col-md-1\">right</div><div class=\"col grid-bottom col-md-12\">bottom</div></div>"
|
42
|
-
|
43
|
-
assert_equal expected, actual
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
data/test/ui/panel_test.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
include UiBibz::Helpers
|
3
|
-
class PanelTest < ActionView::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@content = 'Example'
|
7
|
-
end
|
8
|
-
|
9
|
-
test 'simple panel' do
|
10
|
-
actual = UiBibz::Ui::Core::Panel.new(@content).render
|
11
|
-
expected = "<div class=\"panel-default panel\"><div class=\"panel-body\">#{ @content }</div></div>"
|
12
|
-
|
13
|
-
assert_equal expected, actual
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'simple panel with block' do
|
17
|
-
actual = UiBibz::Ui::Core::Panel.new do
|
18
|
-
@content
|
19
|
-
end.render
|
20
|
-
expected = "<div class=\"panel-default panel\"><div class=\"panel-body\">#{ @content }</div></div>"
|
21
|
-
|
22
|
-
assert_equal expected, actual
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'simple panel with tap' do
|
26
|
-
actual = UiBibz::Ui::Core::Panel.new().tap do |p|
|
27
|
-
p.body @content
|
28
|
-
end.render
|
29
|
-
expected = "<div class=\"panel-default panel\"><div class=\"panel-body\">#{ @content }</div></div>"
|
30
|
-
|
31
|
-
assert_equal expected, actual
|
32
|
-
end
|
33
|
-
|
34
|
-
test 'complex panel with tap' do
|
35
|
-
actual = UiBibz::Ui::Core::Panel.new({state: :danger}, { class: 'example'}).tap do |p|
|
36
|
-
p.header 'header', class: 'header-example'
|
37
|
-
p.body class: 'body-example' do
|
38
|
-
@content
|
39
|
-
end
|
40
|
-
p.footer do
|
41
|
-
"footer"
|
42
|
-
end
|
43
|
-
end.render
|
44
|
-
expected = "<div class=\"example panel-danger panel\">\
|
45
|
-
<div class=\"header-example panel-heading\">header</div>\
|
46
|
-
<div class=\"body-example panel-body\">#{ @content }</div>\
|
47
|
-
<div class=\"panel-footer\">footer</div></div>"
|
48
|
-
|
49
|
-
assert_equal expected, actual
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|