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.
- checksums.yaml +7 -0
- data/.gitignore +44 -0
- data/.travis.yml +13 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +171 -0
- data/MIT-LICENSE +20 -0
- data/README.md +728 -0
- data/README.rdoc +0 -0
- data/Rakefile +34 -0
- data/config/locales/en.yml +14 -0
- data/config/locales/fr.yml +14 -0
- data/doc/images/alert.png +0 -0
- data/doc/images/breadcrumb.png +0 -0
- data/doc/images/button.png +0 -0
- data/doc/images/button_dropdown.png +0 -0
- data/doc/images/button_group.png +0 -0
- data/doc/images/button_link.png +0 -0
- data/doc/images/button_split_dropdown.png +0 -0
- data/doc/images/glyph.png +0 -0
- data/doc/images/list.png +0 -0
- data/doc/images/nav.png +0 -0
- data/doc/images/panel.png +0 -0
- data/doc/images/table.png +0 -0
- data/doc/images/table_pagination_per_page.png +0 -0
- data/doc/images/table_panel.png +0 -0
- data/doc/images/table_search_field.png +0 -0
- data/doc/images/ui-bibz-logo-without-border.gif +0 -0
- data/doc/images/ui-bibz-logo.gif +0 -0
- data/lib/tasks/ui_bibz_tasks.rake +4 -0
- data/lib/ui_bibz/concerns/models/searchable.rb +93 -0
- data/lib/ui_bibz/helpers/meta_helper.rb +27 -0
- data/lib/ui_bibz/helpers/ui_helper.rb +108 -0
- data/lib/ui_bibz/helpers/utils_helper.rb +9 -0
- data/lib/ui_bibz/rails/engine.rb +39 -0
- data/lib/ui_bibz/ui/alert.rb +67 -0
- data/lib/ui_bibz/ui/breadcrumb/breadcrumb.rb +54 -0
- data/lib/ui_bibz/ui/breadcrumb/components/breadcrumb_link.rb +62 -0
- data/lib/ui_bibz/ui/button/button.rb +65 -0
- data/lib/ui_bibz/ui/button/button_dropdown.rb +56 -0
- data/lib/ui_bibz/ui/button/button_group.rb +62 -0
- data/lib/ui_bibz/ui/button/button_link.rb +66 -0
- data/lib/ui_bibz/ui/button/button_split_dropdown.rb +80 -0
- data/lib/ui_bibz/ui/component.rb +137 -0
- data/lib/ui_bibz/ui/dropdown/components/dropdown_list.rb +73 -0
- data/lib/ui_bibz/ui/dropdown/dropdown.rb +101 -0
- data/lib/ui_bibz/ui/glyph.rb +92 -0
- data/lib/ui_bibz/ui/grid/components/col.rb +74 -0
- data/lib/ui_bibz/ui/grid/components/row.rb +32 -0
- data/lib/ui_bibz/ui/grid/grid.rb +108 -0
- data/lib/ui_bibz/ui/jumbotron.rb +58 -0
- data/lib/ui_bibz/ui/label.rb +58 -0
- data/lib/ui_bibz/ui/list/components/list.rb +105 -0
- data/lib/ui_bibz/ui/list/list_group.rb +78 -0
- data/lib/ui_bibz/ui/nav/components/nav_link.rb +68 -0
- data/lib/ui_bibz/ui/nav/nav.rb +65 -0
- data/lib/ui_bibz/ui/panel.rb +101 -0
- data/lib/ui_bibz/ui/table/components/actions.rb +44 -0
- data/lib/ui_bibz/ui/table/components/column.rb +34 -0
- data/lib/ui_bibz/ui/table/components/columns.rb +16 -0
- data/lib/ui_bibz/ui/table/components/store.rb +67 -0
- data/lib/ui_bibz/ui/table/components/table_action.rb +21 -0
- data/lib/ui_bibz/ui/table/table.rb +146 -0
- data/lib/ui_bibz/ui/table/table_pagination.rb +29 -0
- data/lib/ui_bibz/ui/table/table_pagination_per_page.rb +53 -0
- data/lib/ui_bibz/ui/table/table_panel.rb +66 -0
- data/lib/ui_bibz/ui/table/table_search_field.rb +62 -0
- data/lib/ui_bibz/ui/table/ux/actionable.rb +59 -0
- data/lib/ui_bibz/ui/table/ux/paginable.rb +35 -0
- data/lib/ui_bibz/ui/table/ux/searchable.rb +47 -0
- data/lib/ui_bibz/ui/table/ux/sortable.rb +93 -0
- data/lib/ui_bibz/ui/ui.rb +14 -0
- data/lib/ui_bibz/utils/internationalization.rb +30 -0
- data/lib/ui_bibz/version.rb +3 -0
- data/lib/ui_bibz.rb +60 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/user.rb +5 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +57 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20150123191721_user.rb +4 -0
- data/test/dummy/db/migrate/20150123191805_create_users.rb +12 -0
- data/test/dummy/db/schema.rb +25 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/fixtures/users.yml +13 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/factories/user.rb +8 -0
- data/test/store_test.rb +46 -0
- data/test/support/factory_girl.rb +6 -0
- data/test/test_helper.rb +23 -0
- data/test/ui/button_test.rb +56 -0
- data/test/ui/component_test.rb +21 -0
- data/test/ui/dropdown_test.rb +18 -0
- data/test/ui/glyph_test.rb +23 -0
- data/test/ui/grid_test.rb +46 -0
- data/test/ui/list_group_test.rb +28 -0
- data/test/ui/nav_test.rb +27 -0
- data/test/ui/panel_test.rb +52 -0
- data/test/ui/table_test.rb +178 -0
- data/test/ui_bibz_test.rb +13 -0
- data/test/ui_helper_test.rb +44 -0
- data/ui_bibz.gemspec +36 -0
- data/vendor/assets/javascripts/ui_bibz.js.coffee +24 -0
- data/vendor/assets/stylesheets/ui_bibz.sass +46 -0
- metadata +398 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create a button dropdown
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Dropdown.
|
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
|
+
# * +size+
|
20
|
+
# (+:xs+, +:sm+, +:lg+)
|
21
|
+
# * +glyph+ - Add glyph with name or hash options
|
22
|
+
# * +name+ - String
|
23
|
+
# * +size+ - Integer
|
24
|
+
# * +type+ - Symbol
|
25
|
+
#
|
26
|
+
# ==== Signatures
|
27
|
+
#
|
28
|
+
# UiBibz::Ui::ButtonDropdown.new(options = nil, html_options = nil).tap do |d|
|
29
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
30
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
31
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
32
|
+
# ...
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# ==== Examples
|
36
|
+
#
|
37
|
+
# UiBibz::Ui::ButtonDropdown.new(name, state: :success).tap do |d|
|
38
|
+
# d.list link_to('test', '#')
|
39
|
+
# d.list link_to('test2', '#')
|
40
|
+
# end.render
|
41
|
+
#
|
42
|
+
class ButtonDropdown < Dropdown
|
43
|
+
|
44
|
+
def initialize name, options = nil, html_options = nil, &block
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
def render
|
49
|
+
content_tag :div, class_and_html_options(['btn-group', type]).merge({ role: 'group' }) do
|
50
|
+
concat button_html
|
51
|
+
concat ul_html
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create a button group
|
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 element with +symbol+ value:
|
18
|
+
# (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
|
19
|
+
# * +size+ - Size of element with +symbol+ value:
|
20
|
+
# (+:xs+, +:sm+, +:lg+)
|
21
|
+
# * +position+ - Position vertical or horizontal with +symbol+ value:
|
22
|
+
# (+:vertical+, +:horizontal+)
|
23
|
+
#
|
24
|
+
# ==== Signatures
|
25
|
+
#
|
26
|
+
# UiBibz::Ui::ButtonGroup.new(options = nil, html_options = nil) do
|
27
|
+
# ...
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# ==== Examples
|
31
|
+
#
|
32
|
+
# UiBibz::Ui::ButtonGroup.new(position: :vertical, size: :xs) do
|
33
|
+
# UiBibz::Ui.Button.new('test').render
|
34
|
+
# UiBibz::Ui.Button.new('test2').render
|
35
|
+
# end.render
|
36
|
+
#
|
37
|
+
class ButtonGroup < Component
|
38
|
+
|
39
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def render
|
44
|
+
content_tag :div, @content, class_and_html_options(["btn-#{ type }", size, position]).merge({ role: type })
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def type
|
50
|
+
@options[:type] || :group
|
51
|
+
end
|
52
|
+
|
53
|
+
def size
|
54
|
+
"btn-group-#{ @options[:size] }" if @options[:size]
|
55
|
+
end
|
56
|
+
|
57
|
+
def position
|
58
|
+
"btn-group-#{ @options[:position] }" if @options[:position]
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create a button link
|
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
|
+
# * +size+
|
20
|
+
# (+:xs+, +:sm+, +:lg+)
|
21
|
+
# * +url+ - String url
|
22
|
+
# * +glyph+ - Add glyph with name or hash options
|
23
|
+
# * +name+ - String
|
24
|
+
# * +size+ - Integer
|
25
|
+
# * +type+ - Symbol
|
26
|
+
#
|
27
|
+
# ==== Signatures
|
28
|
+
#
|
29
|
+
# UiBibz::Ui::ButtonLink.new(content, options = nil, html_options = nil)
|
30
|
+
#
|
31
|
+
# UiBibz::Ui::ButtonLink.new(options = nil, html_options = nil) do
|
32
|
+
# content
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# ==== Examples
|
36
|
+
#
|
37
|
+
# UiBibz::Ui::ButtonLink.new('test', type: :primary, url: '#')
|
38
|
+
#
|
39
|
+
# UiBibz::Ui::ButtonLink.new(type: :primary, url: '#') do
|
40
|
+
# test
|
41
|
+
# end.render
|
42
|
+
#
|
43
|
+
class ButtonLink < Component
|
44
|
+
|
45
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def render
|
50
|
+
link_to glyph_and_content_html, @options[:url], class_and_html_options("btn")
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def state
|
56
|
+
sym = @options[:state] || :default
|
57
|
+
"btn-#{ states[sym] }"
|
58
|
+
end
|
59
|
+
|
60
|
+
# :lg, :sm or :xs
|
61
|
+
def size
|
62
|
+
"btn-#{ @options[:size] }" if @options[:size]
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create a button dropdown
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Dropdown.
|
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
|
+
# * +size+
|
20
|
+
# (+:xs+, +:sm+, +:lg+)
|
21
|
+
# * +glyph+ - Add glyph with name or hash options
|
22
|
+
# * +name+ - String
|
23
|
+
# * +size+ - Integer
|
24
|
+
# * +type+ - Symbol
|
25
|
+
#
|
26
|
+
# ==== Signatures
|
27
|
+
#
|
28
|
+
# UiBibz::Ui::ButtonSplitDropdown.new(options = nil, html_options = nil).tap do |d|
|
29
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
30
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
31
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
32
|
+
# ...
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# ==== Examples
|
36
|
+
#
|
37
|
+
# UiBibz::Ui::ButtonSplitDropdown.new(name, state: :success).tap do |d|
|
38
|
+
# d.list link_to('test', '#')
|
39
|
+
# d.list link_to('test2', '#')
|
40
|
+
# end.render
|
41
|
+
#
|
42
|
+
class ButtonSplitDropdown < Dropdown
|
43
|
+
|
44
|
+
def initialize name, options = nil, html_options = nil, &block
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
def render
|
49
|
+
content_tag :div, class_and_html_options(['btn-group', type]).merge({ role: 'group' }) do
|
50
|
+
concat button_html
|
51
|
+
concat split_html
|
52
|
+
concat ul_html
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
|
59
|
+
def button_html
|
60
|
+
content_tag :button, button_content, class: add_classes("btn", button_state, size)
|
61
|
+
end
|
62
|
+
|
63
|
+
def split_html
|
64
|
+
content_tag :button, split_content, class: add_classes("btn", button_state, "dropdown-toggle"), type: 'button', "data-toggle" => 'dropdown', "aria-expanded" => false
|
65
|
+
end
|
66
|
+
|
67
|
+
def split_content
|
68
|
+
[caret, src_only].join.html_safe
|
69
|
+
end
|
70
|
+
|
71
|
+
def src_only
|
72
|
+
content_tag :span, "Toggle Dropdown", class: "sr-only"
|
73
|
+
end
|
74
|
+
|
75
|
+
def button_content
|
76
|
+
[glyph_with_space, @content].compact.join.html_safe
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'haml'
|
2
|
+
module UiBibz::Ui
|
3
|
+
|
4
|
+
# Creates a component of the given +name+ using options created by the set of +options+.
|
5
|
+
#
|
6
|
+
# ==== Attributes
|
7
|
+
#
|
8
|
+
# * +content+ - Content of element
|
9
|
+
# * +options+ - Options of element
|
10
|
+
# * +html_options+ - Html Options of element
|
11
|
+
#
|
12
|
+
# ==== Options
|
13
|
+
#
|
14
|
+
# You can add HTML attributes using the +html_options+.
|
15
|
+
# You can pass arguments in options attribute:
|
16
|
+
# * +state+ - State of élement with symbol value:
|
17
|
+
# (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
|
18
|
+
# * +glyph+ - Add glyph with name or hash options
|
19
|
+
# * +name+ - String
|
20
|
+
# * +size+ - Integer
|
21
|
+
# * +type+ - Symbol
|
22
|
+
#
|
23
|
+
# ==== Signatures
|
24
|
+
#
|
25
|
+
# UiBibz::Ui::Component.new(content, options = nil, html_options = nil)
|
26
|
+
#
|
27
|
+
# UiBibz::Ui::Component.new(options = nil, html_options = nil) do
|
28
|
+
# content
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# ==== Examples
|
32
|
+
#
|
33
|
+
# UiBibz::Ui::Component.new(content, { type: :success, glyph: 'eye' },{ class: 'test' })
|
34
|
+
# # or
|
35
|
+
# UiBibz::Ui::Component.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do
|
36
|
+
# content
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
class Component < Ui
|
40
|
+
|
41
|
+
attr_accessor :content, :html_options, :options
|
42
|
+
|
43
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
44
|
+
if !block.nil?
|
45
|
+
@html_options, @options = options, content
|
46
|
+
context = eval("self", block.binding)
|
47
|
+
@content = context.capture(&block)
|
48
|
+
else
|
49
|
+
if content.kind_of?(Hash)
|
50
|
+
@html_options, @options = options, content
|
51
|
+
else
|
52
|
+
@html_options, @options, @content = html_options, options, content
|
53
|
+
end
|
54
|
+
end
|
55
|
+
@html_options = @html_options || {}
|
56
|
+
@options = @options || {}
|
57
|
+
end
|
58
|
+
|
59
|
+
def render
|
60
|
+
glyph_and_content_html
|
61
|
+
end
|
62
|
+
|
63
|
+
def glyph_and_content_html
|
64
|
+
[glyph_with_space, @content].compact.join.html_safe
|
65
|
+
end
|
66
|
+
|
67
|
+
def glyph
|
68
|
+
glyph_info = options[:glyph] if options.kind_of?(Hash)
|
69
|
+
Glyph.new(glyph_info).render unless glyph_info.nil?
|
70
|
+
end
|
71
|
+
|
72
|
+
def glyph_with_space
|
73
|
+
"#{ glyph } " unless glyph.nil?
|
74
|
+
end
|
75
|
+
|
76
|
+
def options
|
77
|
+
@options
|
78
|
+
end
|
79
|
+
|
80
|
+
def html_options
|
81
|
+
@html_options
|
82
|
+
end
|
83
|
+
|
84
|
+
def content
|
85
|
+
@content
|
86
|
+
end
|
87
|
+
|
88
|
+
def state
|
89
|
+
sym = options.delete(:state) if options[:state]
|
90
|
+
sym = sym || :default
|
91
|
+
states[:sym]
|
92
|
+
end
|
93
|
+
|
94
|
+
def badge_html
|
95
|
+
content_tag :span, @options[:badge], class: 'badge'
|
96
|
+
end
|
97
|
+
|
98
|
+
def class_and_html_options classes = nil
|
99
|
+
options_class = options[:class] if options.kind_of?(Hash)
|
100
|
+
cls = [
|
101
|
+
html_options[:class],
|
102
|
+
status,
|
103
|
+
state,
|
104
|
+
options_class
|
105
|
+
]
|
106
|
+
cls << classes unless classes.nil?
|
107
|
+
cls = cls.flatten.compact
|
108
|
+
html_options[:class] = cls.join(' ') unless cls.empty?
|
109
|
+
html_options
|
110
|
+
end
|
111
|
+
|
112
|
+
def options_in_html_options opts
|
113
|
+
html_options.merge!(opts) unless opts.nil?
|
114
|
+
html_options
|
115
|
+
end
|
116
|
+
|
117
|
+
def status
|
118
|
+
options[:status]
|
119
|
+
end
|
120
|
+
|
121
|
+
def states
|
122
|
+
if @states.nil?
|
123
|
+
states = {}
|
124
|
+
%w(default success primary info waring danger).each do |s|
|
125
|
+
states = states.merge(Hash[s.to_sym, s])
|
126
|
+
end
|
127
|
+
@states = states
|
128
|
+
end
|
129
|
+
@states
|
130
|
+
end
|
131
|
+
|
132
|
+
def add_classes *classes
|
133
|
+
classes.compact.join(' ')
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create DropdownList
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Component.
|
6
|
+
# Use '---' in content to add a separator
|
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+ - State of élement with symbol value:
|
19
|
+
# (+:active+)
|
20
|
+
# * +url+ - String
|
21
|
+
# * +glyph+ - Add glyph with name or hash options
|
22
|
+
# * +name+ - String
|
23
|
+
# * +size+ - Integer
|
24
|
+
# * +type+ - Symbol
|
25
|
+
#
|
26
|
+
# ==== Signatures
|
27
|
+
#
|
28
|
+
# UiBibz::Ui::DropdownList.new(content, options = nil, html_options = nil)
|
29
|
+
#
|
30
|
+
# UiBibz::Ui::DropdownList.new(options = nil, html_options = nil) do
|
31
|
+
# content
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# ==== Examples
|
35
|
+
#
|
36
|
+
# UiBibz::Ui::DropdownList.new('Home', { glyph: 'home', status: :active },{ class: 'test' }).render
|
37
|
+
#
|
38
|
+
# UiBibz::Ui::DropdownList.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do
|
39
|
+
# 'Home'
|
40
|
+
# end.render
|
41
|
+
#
|
42
|
+
# UiBibz::UiBibz::DropdownList.new('---').render # To add a separator
|
43
|
+
#
|
44
|
+
class DropdownList < Component
|
45
|
+
|
46
|
+
DIVIDER = '---'
|
47
|
+
|
48
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
49
|
+
super
|
50
|
+
end
|
51
|
+
|
52
|
+
def render
|
53
|
+
@content == DIVIDER ? divider_html : link_html
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def divider_html
|
59
|
+
content_tag :li, '', class_and_html_options('divider').merge({ role: 'presentation' })
|
60
|
+
end
|
61
|
+
|
62
|
+
def link_html
|
63
|
+
content_tag :li, class_and_html_options(type).merge({ role: 'presentation' }) do
|
64
|
+
@content
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def type
|
69
|
+
"dropdown-header" if @options[:type] == :header
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'ui_bibz/ui/dropdown/components/dropdown_list'
|
2
|
+
module UiBibz::Ui
|
3
|
+
|
4
|
+
# Create a dropdown
|
5
|
+
#
|
6
|
+
# This element is an extend of UiBibz::Ui::Component.
|
7
|
+
# You can use tap method to add list items.
|
8
|
+
#
|
9
|
+
# ==== Attributes
|
10
|
+
#
|
11
|
+
# * +content+ - Content of element
|
12
|
+
# * +options+ - Options of element
|
13
|
+
# * +html_options+ - Html Options of element
|
14
|
+
#
|
15
|
+
# ==== Options
|
16
|
+
#
|
17
|
+
# You can add HTML attributes using the +html_options+.
|
18
|
+
# You can pass arguments in options attribute:
|
19
|
+
# * +state+ - State of élement with symbol value:
|
20
|
+
# (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
|
21
|
+
# * +size+
|
22
|
+
# (+:xs+, +:sm+, +:lg+)
|
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::Dropdown.new(options = nil, html_options = nil).tap do |d|
|
31
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
32
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
33
|
+
# d.list content = nil, options = nil, html_options = nil, &block
|
34
|
+
# ...
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# ==== Examples
|
38
|
+
#
|
39
|
+
# UiBibz::Ui::Dropdown.new(name, state: :success).tap do |d|
|
40
|
+
# d.list link_to('test', '#')
|
41
|
+
# d.list link_to('test2', '#')
|
42
|
+
# end.render
|
43
|
+
#
|
44
|
+
class Dropdown < Component
|
45
|
+
|
46
|
+
def initialize content, options = nil, html_options = nil, &block
|
47
|
+
super
|
48
|
+
@lists = []
|
49
|
+
@state = @options.delete(:state)
|
50
|
+
end
|
51
|
+
|
52
|
+
def render
|
53
|
+
content_tag :div, class_and_html_options(type) do
|
54
|
+
concat button_html
|
55
|
+
concat ul_html
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# See UiBibz::Ui::DropdownList
|
60
|
+
def list content = nil, options = nil, html_options = nil, &block
|
61
|
+
@lists << DropdownList.new(content, options, html_options, &block).render
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def button_content
|
67
|
+
[glyph_with_space, @content, ' ', caret].compact.join.html_safe
|
68
|
+
end
|
69
|
+
|
70
|
+
def button_html
|
71
|
+
content_tag :button, button_content, class: add_classes("btn", button_state, size, "dropdown-toggle"), type: 'button', "data-toggle" => 'dropdown', "aria-expanded" => false
|
72
|
+
end
|
73
|
+
|
74
|
+
def ul_html
|
75
|
+
content_tag :ul, @lists.join.html_safe, class: "dropdown-menu dropdown-menu-#{ position }", role: 'menu'
|
76
|
+
end
|
77
|
+
|
78
|
+
def caret
|
79
|
+
content_tag :span, '', class: 'caret'
|
80
|
+
end
|
81
|
+
|
82
|
+
def position
|
83
|
+
@options[:position] || 'left'
|
84
|
+
end
|
85
|
+
|
86
|
+
def type
|
87
|
+
@options[:type] || 'dropdown'
|
88
|
+
end
|
89
|
+
|
90
|
+
def button_state
|
91
|
+
sym = @state || :default
|
92
|
+
"btn-#{ states[sym] }"
|
93
|
+
end
|
94
|
+
|
95
|
+
# :lg, :sm or :xs
|
96
|
+
def size
|
97
|
+
"btn-#{ @options[:size] }" if @options[:size]
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module UiBibz::Ui
|
2
|
+
|
3
|
+
# Create a glyph
|
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
|
+
# * +name+ - String
|
18
|
+
# * +size+ - Integer
|
19
|
+
# * +type+ - Symbol
|
20
|
+
#
|
21
|
+
# ==== Signatures
|
22
|
+
#
|
23
|
+
# UiBibz::Ui::Glyph.new content = nil, options = nil, html_options = nil,
|
24
|
+
# &block
|
25
|
+
#
|
26
|
+
# UiBibz::Ui::Glyph.new(options = nil, html_options = nil) do
|
27
|
+
# content
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# UiBibz::Ui::Glyph.new content = {}
|
31
|
+
#
|
32
|
+
# UiBibz::Ui::Glyph.new content, options = {}, html_options = {}
|
33
|
+
#
|
34
|
+
# ==== Exemples
|
35
|
+
#
|
36
|
+
# UiBibz::Ui::Glyph.new('eye').render
|
37
|
+
#
|
38
|
+
# UiBibz::Ui::Glyph.new() do
|
39
|
+
# name
|
40
|
+
# end.render
|
41
|
+
#
|
42
|
+
# UiBibz::Ui::Glyph.new('eye', { size: 3, type: 'fw' }).render
|
43
|
+
#
|
44
|
+
# UiBibz::Ui::Glyph.new({ name: 'eye', size: 3, type: 'fw' }).render
|
45
|
+
#
|
46
|
+
#
|
47
|
+
class Glyph < Component
|
48
|
+
|
49
|
+
def initialize content, options = nil, html_options = nil, &block
|
50
|
+
super
|
51
|
+
end
|
52
|
+
|
53
|
+
def render
|
54
|
+
content_tag :i, '', class_and_html_options(classes)
|
55
|
+
end
|
56
|
+
|
57
|
+
def classes
|
58
|
+
cls = ["glyph", "fa", "fa-#{ content }"]
|
59
|
+
cls << "fa-#{ size }x" unless size.nil?
|
60
|
+
cls << "fa-rotate-#{ rotate }" unless rotate.nil?
|
61
|
+
cls << "fa-flip-#{ flip }" unless flip.nil?
|
62
|
+
cls << "fa-stack-#{ stack }x" unless stack.nil?
|
63
|
+
cls << "fa-#{ type }" unless type.nil?
|
64
|
+
cls.compact.join(' ')
|
65
|
+
end
|
66
|
+
|
67
|
+
def size
|
68
|
+
@options[:size]
|
69
|
+
end
|
70
|
+
|
71
|
+
def stack
|
72
|
+
@options[:stack]
|
73
|
+
end
|
74
|
+
|
75
|
+
def rotate
|
76
|
+
@options[:rotate]
|
77
|
+
end
|
78
|
+
|
79
|
+
def flip
|
80
|
+
@options[:flip]
|
81
|
+
end
|
82
|
+
|
83
|
+
def type
|
84
|
+
@options[:type]
|
85
|
+
end
|
86
|
+
|
87
|
+
def content
|
88
|
+
@options[:name] || @content
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|