card-mod-bootstrap 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate_core_cards/20170719163733_update_bootswatch_themes_to_4_beta.rb +1 -2
  3. data/db/migrate_core_cards/20170726111053_add_bootstrap_mixins.rb +2 -2
  4. data/db/migrate_core_cards/20170726145012_select2.rb +2 -2
  5. data/db/migrate_core_cards/20180423160231_migrate_customized_bootstrap_skin.rb +1 -0
  6. data/db/migrate_core_cards/20180423170283_add_type_bootswatch_skin.rb +1 -0
  7. data/db/migrate_core_cards/20180425174433_delete_deprecated_skin_cards.rb +1 -0
  8. data/db/migrate_core_cards/20181129140917_fix_skin_images.rb +0 -1
  9. data/db/migrate_core_cards/data/20181108181219_migrate_classic_skins_to_bootstrap.rb +1 -0
  10. data/db/migrate_core_cards/lib/skin.rb +1 -1
  11. data/lib/card/bootstrap.rb +17 -0
  12. data/lib/card/bootstrap/basic_tags.rb +26 -0
  13. data/lib/card/bootstrap/component.rb +110 -0
  14. data/lib/card/bootstrap/component/carousel.rb +78 -0
  15. data/lib/card/bootstrap/component/form.rb +67 -0
  16. data/lib/card/bootstrap/component/horizontal_form.rb +65 -0
  17. data/lib/card/bootstrap/component/layout.rb +107 -0
  18. data/lib/card/bootstrap/component/panel.rb +11 -0
  19. data/lib/card/bootstrap/component_klass.rb +37 -0
  20. data/lib/card/bootstrap/component_loader.rb +30 -0
  21. data/lib/card/bootstrap/content.rb +42 -0
  22. data/lib/card/bootstrap/delegate.rb +18 -0
  23. data/lib/card/bootstrap/old_component.rb +108 -0
  24. data/lib/card/bootstrap/tag_method.rb +56 -0
  25. data/lib/card/bootstrapper.rb +17 -0
  26. data/lib/card/tab.rb +8 -1
  27. data/set/abstract/bootstrap_code_file.rb +0 -1
  28. data/set/abstract/bootswatch_theme.rb +1 -0
  29. data/set/abstract/bs_badge/tab_badge.haml +1 -1
  30. data/set/all/bootstrap/dropdown.rb +12 -4
  31. data/set/all/bootstrap/helper.rb +18 -11
  32. data/set/all/bootstrap/icon.rb +3 -1
  33. data/set/all/bootstrap/table.rb +1 -0
  34. data/set/all/bootstrap/wrapper.rb +2 -4
  35. data/set/self/bootstrap_core.rb +7 -8
  36. data/set/type/customized_bootswatch_skin.rb +11 -7
  37. data/set/type_plus_right/customized_bootswatch_skin/colors.rb +3 -2
  38. metadata +28 -27
  39. data/lib/bootstrap.rb +0 -16
  40. data/lib/bootstrap/basic_tags.rb +0 -26
  41. data/lib/bootstrap/component.rb +0 -139
  42. data/lib/bootstrap/component/carousel.rb +0 -68
  43. data/lib/bootstrap/component/form.rb +0 -65
  44. data/lib/bootstrap/component/horizontal_form.rb +0 -63
  45. data/lib/bootstrap/component/layout.rb +0 -95
  46. data/lib/bootstrap/component/panel.rb +0 -9
  47. data/lib/bootstrap/component_loader.rb +0 -28
  48. data/lib/bootstrap/content.rb +0 -40
  49. data/lib/bootstrap/delegate.rb +0 -16
  50. data/lib/bootstrap/old_component.rb +0 -103
  51. data/lib/bootstrap/tag_method.rb +0 -54
  52. data/lib/bootstrapper.rb +0 -16
@@ -1,68 +0,0 @@
1
- class Bootstrap
2
- class Component
3
- class Carousel < Component
4
- def render_content
5
- carousel *@args, &@build_block
6
- end
7
-
8
- def carousel id, active_index, &block
9
- @id = id
10
- @active_item_index = active_index
11
- @items = []
12
- instance_exec &block
13
-
14
- @html.div class: "carousel slide", id: id, "data-ride" => "carousel" do
15
- indicators
16
- items
17
- control_prev
18
- control_next
19
- end
20
- end
21
-
22
- def item content=nil, &block
23
- @items << (content || block)
24
- end
25
-
26
- def items
27
- @html.div class: "carousel-inner", role: "listbox" do
28
- @items.each_with_index do |item, index|
29
- html_opts = { class: "carousel-item" }
30
- add_class html_opts, "active" if index == @active_item_index
31
- @html.div html_opts do
32
- item = item.call if item.respond_to?(:call)
33
- @html << item if item.is_a?(String)
34
- end
35
- end
36
- end
37
- end
38
-
39
- def control_prev
40
- @html.a class: "carousel-control-prev", href: "##{@id}", role: "button",
41
- "data-slide" => "prev" do
42
- @html.span class: "carousel-control-prev-icon", "aria-hidden" => "true"
43
- @html.span "Previous", class: "sr-only"
44
- end
45
- end
46
-
47
- def control_next
48
- @html.a class: "carousel-control-next", href: "##{@id}", role: "button",
49
- "data-slide": "next" do
50
- @html.span class: "carousel-control-next-icon", "aria-hidden" => "true"
51
- @html.span "Next", class: "sr-only"
52
- end
53
- end
54
-
55
- def indicators
56
- @html.ol class: "carousel-indicators" do
57
- @items.size.times { |i| indicator i }
58
- end
59
- end
60
-
61
- def indicator index
62
- html_opts = { "data-slide-to" => index, "data-target": "##{@id}" }
63
- add_class html_opts, "active" if index == @active_item_index
64
- @html.li html_opts
65
- end
66
- end
67
- end
68
- end
@@ -1,65 +0,0 @@
1
- class Bootstrap
2
- class Component
3
- class Form < Component
4
- def render_content *args
5
- form *args, &@build_block
6
- end
7
-
8
- #
9
- # def_tag_method :form, nil, optional_classes: {
10
- # horizontal: "form-horizontal",
11
- # inline: "form-inline"
12
- # }
13
- # def_div_method :group, "form-group"
14
- # def_tag_method :label, nil
15
- # def_tag_method :input, "form-control" do |opts, extra_args|
16
- # type, label = extra_args
17
- # prepend { label label, for: opts[:id] } if label
18
- # opts[:type] = type
19
- # opts
20
- # end
21
-
22
- def form opts={}, &block
23
- add_class opts, "form-horizontal" if opts.delete(:horizontal)
24
- add_class opts, "form-inline" if opts.delete(:inline)
25
- @html.form opts do
26
- instance_exec &block
27
- end
28
- end
29
-
30
- def group text=nil, &block
31
- @html.div text, class: "form-group" do
32
- instance_exec &block
33
- end
34
- end
35
-
36
- def label text=nil, &block
37
- @html.label text, &block
38
- end
39
-
40
- def input type, text: nil, label: nil, id: nil
41
- @html.input id: id, class: "form-control", type: type do
42
- @html.label label, for: id if label
43
- @html << text if text
44
- end
45
- end
46
-
47
- %i[text password datetime datetime-local date month time
48
- week number email url search tel color].each do |tag|
49
- # def_tag_method tag, "form-control", attributes: { type: tag },
50
- # tag: :input do |opts, extra_args|
51
- # label, = extra_args
52
- # prepend { label label, for: opts[:id] } if label
53
- # opts
54
- # end
55
-
56
- define_method tag do |text: nil, id:, label: |
57
- @html.input id: id, class: "form-control", type: tag do
58
- @html.label label, for: id if label
59
- @html << text
60
- end
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,63 +0,0 @@
1
- class Bootstrap
2
- class Component
3
- class HorizontalForm < Form
4
- def left_col_width
5
- @child_args.last && @child_args.last[0] || 2
6
- end
7
-
8
- def right_col_width
9
- @child_args.last && @child_args.last[1] || 10
10
- end
11
-
12
- def_tag_method :form, "form-horizontal"
13
-
14
- def_tag_method :label, "control-label" do |opts, _extra_args|
15
- prepend_class opts, "col-sm-#{left_col_width}"
16
- opts
17
- end
18
-
19
- # def_div_method :input, nil do |opts, extra_args, &block|
20
- # type, label = extra_args
21
- # prepend { tag(:label, nil, for: opts[:id]) { label } } if label
22
- # insert { inner_input opts.merge(type: type) }
23
- # { class: "col-sm-#{right_col_width}" }
24
- # end
25
-
26
- def label_col label, id:
27
- @html.label label, for: id, class: "col-sm-#{left_col_width} control-label"
28
- end
29
-
30
- def input type, label:, id:, &block
31
- label_col label, id: id
32
- @html.div class: "col-sm-#{right_col_width}" do
33
- @html.input type: type, id: id, class: "form-control"
34
- end
35
- # block.call class: "col-sm-#{right_col_width}" do
36
- # inner_input opts.merge(type: type)
37
- # end
38
- end
39
-
40
- def_tag_method :inner_input, "form-control", tag: :input
41
- def_div_method :inner_checkbox, "checkbox"
42
-
43
- def_div_method :checkbox, nil do |opts, extra_args|
44
- inner_checkbox do
45
- label do
46
- inner_input "checkbox", extra_args.first, opts
47
- end
48
- end
49
- { class: "col-sm-offset-#{left_col_width} col-sm-#{right_col_width}" }
50
- end
51
-
52
- def checkbox text, extra_args
53
- @html.div class: "col-sm-offset-#{left_col_width} col-sm-#{right_col_width}" do
54
- @html.div class: "checkbox" do
55
- label_cllabel do
56
- inner_input "checkbox"
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,95 +0,0 @@
1
- class Bootstrap
2
- class Component
3
- # generate bootstrap column layout
4
- # @example
5
- # layout container: true, fluid: true, class: "hidden" do
6
- # row 6, 6, class: "unicorn" do
7
- # column "horn",
8
- # column "rainbow", class: "colorful"
9
- # end
10
- # end
11
- # @example
12
- # layout do
13
- # row 3, 3, 4, 2, class: "unicorn" do
14
- # [ "horn", "body", "tail", "rainbow"]
15
- # end
16
- # add_html "<span> some extra html</span>"
17
- # row 6, 6, ["unicorn", "rainbow"], class: "horn"
18
- # end
19
- class Layout < OldComponent
20
-
21
- def render
22
- @rendered = begin
23
- render_content
24
- @content[-1]
25
- end
26
- end
27
-
28
- def render_content
29
- content = instance_exec *@args, &@build_block
30
- add_content content
31
- opts = @args.first
32
- return unless opts && opts.delete(:container)
33
- content = @content.pop
34
- @content = ["".html_safe]
35
- container content, opts
36
- end
37
-
38
- add_div_method :container, nil do |opts, _extra_args|
39
- prepend_class opts, opts.delete(:fluid) ? "container-fluid" : "container"
40
- opts
41
- end
42
-
43
- # @param args column widths, column content and html attributes
44
- # @example
45
- # row 6, 6, ["col one", "col two"], class: "count", id: "count"
46
- # @example
47
- # row md: 12, xs: 8, "single column content"
48
- # @example
49
- # row md: [1, 11], xs: [2, 10] do
50
- # col "A"
51
- # col "B"
52
- # end
53
- add_div_method :row, "row", content_processor: :column do |opts, extra_args|
54
- cols_content = extra_args.pop if extra_args.last.is_a? Array
55
- [opts, col_widths(extra_args, opts), cols_content].compact
56
- end
57
-
58
- # default column width type is for medium devices (col-md-)
59
- add_div_method :column, nil do |opts, _extra_args|
60
- @child_args.last.each do |medium, size|
61
- if medium == :xs
62
- prepend_class opts, "col-#{size.shift}"
63
- else
64
- prepend_class opts, "col-#{medium}-#{size.shift}"
65
- end
66
- end
67
- opts
68
- end
69
-
70
- alias_method :col, :column
71
-
72
- private
73
-
74
- def standardize_row_args args
75
- opts = args.last.is_a?(Hash) ? args.pop : {}
76
- cols = (args.last.is_a?(Array) || args.last.is_a?(String)) &&
77
- Array.wrap(args.pop)
78
- [cols, opts, col_widths(args, opts)]
79
- end
80
-
81
- def col_widths args, opts
82
- opts = args.pop if args.one? && args.last.is_a?(Hash)
83
- if args.present?
84
- raise Error, "bad argument" unless args.all? { |a| a.is_a? Integer }
85
- { md: Array.wrap(args) }
86
- else
87
- %i[lg xs sm md].each_with_object({}) do |k, cols_w|
88
- next unless (widths = opts.delete(k))
89
- cols_w[k] = Array.wrap widths
90
- end
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,9 +0,0 @@
1
- class Bootstrap
2
- class Component
3
- class Panel < OldComponent
4
- def_div_method :panel, "card"
5
- def_div_method :heading, "card-header"
6
- def_div_method :body, "card-body"
7
- end
8
- end
9
- end
@@ -1,28 +0,0 @@
1
- class Bootstrap
2
- module ComponentLoader
3
- def load_components
4
- components.each do |component|
5
- require_relative "component/#{component}"
6
- include_component component
7
- end
8
- end
9
-
10
- def include_component component
11
- component_class = to_const component.camelcase
12
- define_method component do |*args, &block|
13
- component_class.render self, *args, &block
14
- end
15
- end
16
-
17
- def components
18
- path = File.expand_path "../component/*.rb", __FILE__
19
- Dir.glob(path).map do |file|
20
- File.basename file, ".rb"
21
- end
22
- end
23
-
24
- def to_const name
25
- self.class.const_get "::Bootstrap::Component::#{name.camelcase}"
26
- end
27
- end
28
- end
@@ -1,40 +0,0 @@
1
- class Bootstrap
2
- # shared methods for OldComponent and TagMethod
3
- module Content
4
- private
5
-
6
- def process_collected_content tag_name, opts
7
- collected_content = @content.pop
8
- tag_name = opts.delete(:tag) if tag_name == :yield
9
- add_content content_tag(tag_name, collected_content, opts, false)
10
- end
11
-
12
- def process_content &content_block
13
- content, opts = yield
14
- wrappers = @wrap.pop
15
- if wrappers.present?
16
- process_wrappers wrappers, content, &content_block
17
- else
18
- add_content content
19
- end
20
- opts
21
- end
22
-
23
- def process_append
24
- @append.pop.each do |block|
25
- add_content instance_exec(&block)
26
- end
27
- end
28
-
29
- def process_wrappers wrappers, content, &content_block
30
- while wrappers.present?
31
- wrapper = wrappers.shift
32
- if wrapper.is_a? Symbol
33
- send wrapper, &content_block
34
- else
35
- instance_exec content, &wrappers.shift
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,16 +0,0 @@
1
- class Bootstrap
2
- module Delegate
3
- def method_missing method_name, *args, &block
4
- # return super unless @context.respond_to? method_name
5
- if block_given?
6
- @context.send(method_name, *args, &block)
7
- else
8
- @context.send(method_name, *args)
9
- end
10
- end
11
-
12
- def respond_to_missing? method_name, _include_private=false
13
- @context.respond_to? method_name
14
- end
15
- end
16
- end
@@ -1,103 +0,0 @@
1
- class Bootstrap
2
- # not-yet-obviated component handling
3
- class OldComponent < Component
4
- include Content
5
-
6
- def initialize context, *args, &block
7
- @context = context
8
- @content = ["".html_safe]
9
- @args = args
10
- @child_args = []
11
- @append = []
12
- @wrap = []
13
- @build_block = block
14
- end
15
-
16
- class << self
17
- def render format, *args, &block
18
- new(format, *args, &block).render
19
- end
20
-
21
- # Like add_tag_method but always generates a div tag
22
- # The tag option is not available
23
- def add_div_method name, html_class, opts={}, &tag_block
24
- add_tag_method name, html_class, opts.merge(tag: :div), &tag_block
25
- end
26
-
27
- # Defines a method that generates a html tag
28
- # @param name [Symbol, String] the name of the method. If no :tag option in tag_opts is defined then the name is also the name of the tag that the method generates
29
- # @param html_class [String] a html class that is added to tag. Use nil if you don't want a html_class
30
- # @param tag_opts [Hash] additional argument that will be added to the tag
31
- # @option tag_opts [Symbol, String] tag the name of the tag
32
- # @example
33
- # add_tag_method :link, "known-link", tag: :a, id: "uniq-link"
34
- # link # => <a class="known-link" id="uniq-link"></a>
35
- def add_tag_method name, html_class, tag_opts={}, &tag_block
36
- define_method name do |*args, &block|
37
- process_tag tag_opts[:tag] || name do
38
- content, opts, new_child_args = standardize_args args, &tag_block
39
- add_classes opts, html_class, tag_opts.delete(:optional_classes)
40
- if (attributes = tag_opts.delete(:attributes))
41
- opts.merge! attributes
42
- end
43
-
44
- content = with_child_args new_child_args do
45
- generate_content content,
46
- tag_opts[:content_processor],
47
- &block
48
- end
49
-
50
- [content, opts]
51
- end
52
- end
53
- end
54
-
55
- alias_method :def_div_method, :add_div_method
56
- alias_method :def_tag_method, :add_tag_method
57
- end
58
-
59
- def render
60
- @rendered = begin
61
- render_content
62
- @content[-1]
63
- end
64
- end
65
-
66
- private
67
-
68
- def process_tag tag_name, &content_block
69
- @content.push "".html_safe
70
- @append << []
71
- @wrap << []
72
-
73
- opts = process_content(&content_block)
74
- process_collected_content tag_name, opts
75
- process_append
76
- ""
77
- end
78
-
79
- # include BasicTags
80
- def html content
81
- add_content String(content).html_safe
82
- ""
83
- end
84
-
85
- add_div_method :div, nil do |opts, extra_args|
86
- prepend_class opts, extra_args.first if extra_args.present?
87
- opts
88
- end
89
-
90
- add_div_method :span, nil do |opts, extra_args|
91
- prepend_class opts, extra_args.first if extra_args.present?
92
- opts
93
- end
94
-
95
- add_tag_method :tag, nil, tag: :yield do |opts, extra_args|
96
- prepend_class opts, extra_args[1] if extra_args[1].present?
97
- opts[:tag] = extra_args[0]
98
- opts
99
- end
100
-
101
- include Delegate
102
- end
103
- end