card-mod-bootstrap 0.11.0 → 0.11.5

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 (43) 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/bootstrap.rb +3 -1
  12. data/lib/bootstrap/component.rb +39 -128
  13. data/lib/bootstrap/component/carousel.rb +16 -8
  14. data/lib/bootstrap/component/component_class.rb +36 -0
  15. data/lib/bootstrap/component/form.rb +4 -4
  16. data/lib/bootstrap/component/horizontal_form.rb +2 -2
  17. data/lib/bootstrap/component/layout.rb +20 -10
  18. data/lib/bootstrap/component_loader.rb +1 -1
  19. data/lib/bootstrap/content.rb +40 -0
  20. data/lib/bootstrap/old_component.rb +6 -85
  21. data/lib/bootstrap/tag_method.rb +54 -0
  22. data/lib/bootstrapper.rb +1 -1
  23. data/lib/stylesheets/style_bootstrap_cards.scss +2 -2
  24. data/public/assets/fonts/MaterialIcons-Regular.svg +1 -2373
  25. data/public/assets/fonts/fa-brands-400.svg +1 -3717
  26. data/public/assets/fonts/fa-regular-400.svg +1 -801
  27. data/public/assets/fonts/fa-solid-900.svg +1 -5028
  28. data/public/assets/fonts/glyphicons-halflings-regular.svg +1 -288
  29. data/set/abstract/bootstrap_code_file.rb +0 -1
  30. data/set/abstract/bootswatch_theme.rb +1 -0
  31. data/set/abstract/bs_badge/tab_badge.haml +1 -1
  32. data/set/all/bootstrap/downdown_button.haml +9 -0
  33. data/set/all/bootstrap/dropdown.rb +13 -15
  34. data/set/all/bootstrap/helper.rb +23 -12
  35. data/set/all/bootstrap/icon.rb +16 -11
  36. data/set/all/bootstrap/navbar.rb +8 -28
  37. data/set/all/bootstrap/navbar/navbar_responsive.haml +17 -0
  38. data/set/all/bootstrap/table.rb +9 -7
  39. data/set/all/bootstrap/wrapper.rb +2 -4
  40. data/set/self/bootstrap_core.rb +7 -8
  41. data/set/type/customized_bootswatch_skin.rb +11 -7
  42. data/set/type_plus_right/customized_bootswatch_skin/colors.rb +3 -2
  43. metadata +24 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb22a07be3da857bf3be570e9cddf086b344f1eb1ca918414b41a6343bcadba8
4
- data.tar.gz: 412e7017a6dc34b1b76ccbc228d5d14a21b84a10b0a2f1a107c9a6c06aea03cf
3
+ metadata.gz: 3cec84d4d107eb10c36b89dcdcf027d3c5dd2f6fd3a0f37409099cee8fe037b9
4
+ data.tar.gz: 641ae7a1c7480deac8d098899b3188d8e0b0e55579ebdc430d393f423b4e7754
5
5
  SHA512:
6
- metadata.gz: ff9a23373846462c9fa0dc437426d931227073978b59e7329917f7b19d8cdbfb0d874ab8bf7d8384f5bbb5b5852f0ae938c73e2520bd13b1dcc3ef20275aeedc
7
- data.tar.gz: f820f08dedddcae7540dc6ea8be9e94b6089d56ac04ff96dc00780dca2987a745c99ee3a1d823d303218a55baf85e38440d0075807caa9b299488c62c45e1da1
6
+ metadata.gz: d1ddfdf005e2cc00e919f50f6e39c5395eaae0de0c713ecb44bb8dc9a66a7a5390d89fb12f99a21f0d681eef7aa8abf97a86e188d670ebbcb355058ba9c03f84
7
+ data.tar.gz: 748a9964081887d8b5a9123197db0e5278e03d55201302c7b3b5843f9fa2c8273fd0770ee7d8d749dd1061c7c2694745bef2b65656f30718394159a659ed2e1b
@@ -1,4 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
+
2
3
  require_relative "lib/skin"
3
4
 
4
5
  class UpdateBootswatchThemesTo4Beta < Cardio::Migration::Core
@@ -51,5 +52,3 @@ class UpdateBootswatchThemesTo4Beta < Cardio::Migration::Core
51
52
  end
52
53
  end
53
54
  end
54
-
55
-
@@ -3,9 +3,9 @@
3
3
  class AddBootstrapMixins < Cardio::Migration::Core
4
4
  def up
5
5
  ensure_card "style: bootstrap mixins", type_id: Card::ScssID,
6
- codename: "style_bootstrap_mixins"
6
+ codename: "style_bootstrap_mixins"
7
7
 
8
8
  ensure_card "style: bootstrap breakpoints", type_id: Card::ScssID,
9
- codename: "style_bootstrap_breakpoints"
9
+ codename: "style_bootstrap_breakpoints"
10
10
  end
11
11
  end
@@ -3,8 +3,8 @@
3
3
  class Select2 < Cardio::Migration
4
4
  def up
5
5
  add_script "select2",
6
- type_id: Card::JavaScriptID,
7
- to: "*all+*script"
6
+ type_id: Card::JavaScriptID,
7
+ to: "*all+*script"
8
8
 
9
9
  # add_style "select2",
10
10
  # type_id: Card::CssID,
@@ -51,6 +51,7 @@ class MigrateCustomizedBootstrapSkin < Cardio::Migration::Core
51
51
  def migrate_customizable_bootstrap_skin
52
52
  referers = Card.search refer_to: { codename: OLD_SKIN.to_s }
53
53
  return unless referers.present?
54
+
54
55
  replace_old_skin referers
55
56
  build_new_skin
56
57
  delete_code_card OLD_SKIN
@@ -25,6 +25,7 @@ class AddTypeBootswatchSkin < Cardio::Migration::Core
25
25
  puts "updating #{skin_name}"
26
26
  card = Card.fetch(skin_name)
27
27
  next puts "card not found" unless card
28
+
28
29
  card.update! type_id: Card::BootswatchSkinID
29
30
  end
30
31
  end
@@ -6,6 +6,7 @@ class Skin
6
6
  def delete_deprecated_skin_cards
7
7
  skin_cards.each do |name_parts|
8
8
  next if !Card.fetch(name_parts) || !Card.fetch(name_parts).pristine?
9
+
9
10
  delete_card name_parts
10
11
  end
11
12
  end
@@ -1,4 +1,3 @@
1
-
2
1
  require_relative "lib/skin"
3
2
 
4
3
  class FixSkinImages < ActiveRecord::Migration[5.2]
@@ -22,6 +22,7 @@ class MigrateClassicSkinsToBootstrap < ActiveRecord::Migration[5.2]
22
22
 
23
23
  layout_rule = Card[:all, :layout]
24
24
  return unless layout_rule.first_name.key == UNSUPPORTED_LAYOUT
25
+
25
26
  layout_rule.update! content: DEFAULT_LAYOUT
26
27
  end
27
28
  end
@@ -4,7 +4,7 @@ class Skin
4
4
 
5
5
  class << self
6
6
  def vendor_path
7
- File.expand_path "../../../../vendor", __FILE__
7
+ File.expand_path "../../../vendor", __dir__
8
8
  end
9
9
 
10
10
  def bootstrap_scss_path filename
data/lib/bootstrap.rb CHANGED
@@ -6,11 +6,13 @@ class Bootstrap
6
6
  extend ComponentLoader
7
7
  load_components
8
8
 
9
+ attr_reader :context
10
+
9
11
  def initialize context=nil
10
12
  @context = context
11
13
  end
12
14
 
13
15
  def render *args, &block
14
- instance_exec *args, &block
16
+ instance_exec(*args, &block)
15
17
  end
16
18
  end
@@ -1,68 +1,8 @@
1
- #! no set module
2
1
  class Bootstrap
3
- class TagMethod
4
- def initialize component, name, html_class, tag_opts={}, &tag_block
5
- @component = component
6
- @name = name
7
- @html_class = html_class
8
- @tag_opts = tag_opts
9
- @tag_block = tag_block
10
- @append = []
11
- @wrap = []
12
- @xm = Builder::XmlMarkup.new
13
- end
14
-
15
- def call *args, &content_block
16
- component.content.push "".html_safe
17
-
18
- content, opts = content_block.call
19
- wrappers = @wrap.pop
20
- if wrappers.present?
21
- while wrappers.present? do
22
- wrapper = wrappers.shift
23
- if wrapper.is_a? Symbol
24
- send wrapper, &content_block
25
- else
26
- instance_exec(content, &wrappers.shift)
27
- end
28
- end
29
- else
30
- add_content content
31
- end
32
-
33
- collected_content = @content.pop
34
- tag_name = opts.delete(:tag) if tag_name == :yield
35
- add_content content_tag(tag_name, collected_content, opts, false)
36
- @append.pop.each do |block|
37
- add_content instance_exec(&block)
38
- end
39
- ""
40
- end
41
-
42
- def method_missing method, *args, &block
43
- @component.send method, *args, &block
44
- end
45
-
46
- def prepend &block
47
- tmp = @content.pop
48
- instance_exec &block
49
- @content << tmp
50
- end
51
-
52
- def wrap &block
53
- instance_exec &block
54
- end
55
-
56
- def append &block
57
- @append[-1] << block
58
- end
59
-
60
- def wrapInner tag=nil, &block
61
- @wrap[-1] << (block_given? ? block : tag)
62
- end
63
- end
64
-
2
+ # render components of bootstrap library
65
3
  class Component
4
+ extend ComponentClass
5
+
66
6
  def initialize context, *args, &block
67
7
  @context = context
68
8
  @content = ["".html_safe]
@@ -74,64 +14,18 @@ class Bootstrap
74
14
  @html = Builder::XmlMarkup.new
75
15
  end
76
16
 
77
- class << self
78
- def render format, *args, &block
79
- new(format, *args, &block).render
80
- end
81
-
82
- # Like def_tag_method but always generates a div tag
83
- # The tag option is not available
84
- def def_div_method name, html_class, opts={}, &tag_block
85
- def_tag_method name, html_class, opts.merge(tag: :div), &tag_block
86
- end
87
-
88
- # Defines a method that generates a html tag
89
- # @param method_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
90
- # @param html_class [String] a html class that is added to tag. Use nil if you don't want a html_class
91
- # @param tag_opts [Hash] additional argument that will be added to the tag
92
- # @option tag_opts [Symbol, String] tag the name of the tag
93
- # @example
94
- # def_tag_method :link, "known-link", tag: :a, id: "uniq-link"
95
- # link # => <a class="known-link" id="uniq-link"></a>
96
- def def_tag_method method_name, html_class, tag_opts={}, &tag_opts_block
97
- tag = tag_opts.delete(:tag) || method_name
98
- return def_simple_tag_method method_name, tag, html_class, tag_opts unless block_given?
99
-
100
- define_method method_name do |*args, &content_block|
101
- content, opts, new_child_args = standardize_args args, &tag_opts_block
102
- add_classes opts, html_class, tag_opts.delete(:optional_classes)
103
-
104
- @html.tag! tag, opts do
105
- instance_exec &content_block
106
- end
107
- end
108
- end
109
-
110
- def def_simple_tag_method method_name, tag, html_class, tag_opts={}
111
- define_method method_name do |*args, &content_block|
112
- @html.tag! tag, class: html_class do
113
- instance_exec &content_block
114
- end
115
- end
116
- end
117
- end
118
-
119
-
120
17
  def render
121
- @rendered = begin
122
- render_content
123
- # @content[-1]
124
- end
18
+ @rendered = render_content
125
19
  end
126
20
 
127
21
  def prepend &block
128
22
  tmp = @content.pop
129
- instance_exec &block
23
+ instance_exec(&block)
130
24
  @content << tmp
131
25
  end
132
26
 
133
27
  def insert &block
134
- instance_exec &block
28
+ instance_exec(&block)
135
29
  end
136
30
 
137
31
  def append &block
@@ -142,46 +36,63 @@ class Bootstrap
142
36
  @wrap[-1] << (block_given? ? block : tag)
143
37
  end
144
38
 
39
+ def card
40
+ @context.context.card
41
+ end
42
+
145
43
  private
146
44
 
45
+ def tag_method_opts args, html_class, tag_opts, &tag_opts_block
46
+ opts = {}
47
+ _blah, opts, _blah = standardize_args args, &tag_opts_block if block_given?
48
+ add_classes opts, html_class, tag_opts.delete(:optional_classes)
49
+ opts
50
+ end
51
+
147
52
  def render_content
148
53
  # if @build_block.arity > 0
149
- instance_exec *@args, &@build_block
54
+ instance_exec(*@args, &@build_block)
150
55
  end
151
56
 
152
57
  def generate_content content, processor, &block
153
- content = instance_exec &block if block.present?
58
+ content = instance_exec(&block) if block.present?
154
59
  return content if !processor || !content.is_a?(Array)
155
- content.each {|item| send processor, item}
60
+
61
+ content.each { |item| send processor, item }
156
62
  ""
157
63
  end
158
64
 
159
65
  def with_child_args args
160
66
  @child_args << args if args.present?
161
- res = yield
162
- @child_args.pop if args.present?
163
- res
67
+ yield.tap { @child_args.pop if args.present? }
164
68
  end
165
69
 
166
70
  def add_content content
167
71
  @content[-1] << "\n#{content}".html_safe if content.present?
168
72
  end
169
73
 
170
- def process_tag tag_name, &content_block
74
+ def standardize_args args, &block
75
+ opts = standardize_opts args
76
+ items = items_from_args args
77
+ opts, args = standardize_block_args opts, args, &block if block.present?
78
+
79
+ [items, opts, args]
171
80
  end
172
81
 
173
- def standardize_args args, &block
174
- opts = args.last.is_a?(Hash) ? args.pop : {}
175
- items = ((args.one? && args.last.is_a?(String)) || args.last.is_a?(Array)) &&
176
- args.pop
177
- if block.present?
178
- opts, args = instance_exec opts, args, &block
179
- unless opts.is_a?(Hash)
82
+ def standardize_opts args
83
+ args.last.is_a?(Hash) ? args.pop : {}
84
+ end
85
+
86
+ def items_from_args args
87
+ ((args.one? && args.last.is_a?(String)) || args.last.is_a?(Array)) && args.pop
88
+ end
89
+
90
+ def standardize_block_args opts, args, &block
91
+ instance_exec(opts, args, &block).tap do |s_opts, _s_args|
92
+ unless s_opts.is_a? Hash
180
93
  raise Card::Error, "first return value of a tag block has to be a hash"
181
94
  end
182
95
  end
183
-
184
- [items, opts, args]
185
96
  end
186
97
 
187
98
  def add_classes opts, html_class, optional_classes
@@ -2,14 +2,14 @@ class Bootstrap
2
2
  class Component
3
3
  class Carousel < Component
4
4
  def render_content
5
- carousel *@args, &@build_block
5
+ carousel(*@args, &@build_block)
6
6
  end
7
7
 
8
8
  def carousel id, active_index, &block
9
9
  @id = id
10
10
  @active_item_index = active_index
11
11
  @items = []
12
- instance_exec &block
12
+ instance_exec(&block)
13
13
 
14
14
  @html.div class: "carousel slide", id: id, "data-ride" => "carousel" do
15
15
  indicators
@@ -26,16 +26,24 @@ class Bootstrap
26
26
  def items
27
27
  @html.div class: "carousel-inner", role: "listbox" do
28
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
29
+ carousel_item item, carousel_item_opts(index)
35
30
  end
36
31
  end
37
32
  end
38
33
 
34
+ def carousel_item_opts index
35
+ { class: "carousel-item" }.tap do |opts|
36
+ add_class opts, "active" if index == @active_item_index
37
+ end
38
+ end
39
+
40
+ def carousel_item item, html_opts
41
+ @html.div html_opts do
42
+ item = item.call if item.respond_to?(:call)
43
+ @html << item if item.is_a?(String)
44
+ end
45
+ end
46
+
39
47
  def control_prev
40
48
  @html.a class: "carousel-control-prev", href: "##{@id}", role: "button",
41
49
  "data-slide" => "prev" do
@@ -0,0 +1,36 @@
1
+ class Bootstrap
2
+ class Component
3
+ # class methods for Bootstrap::Component
4
+ module ComponentClass
5
+ def render format, *args, &block
6
+ new(format, *args, &block).render
7
+ end
8
+
9
+ # Like def_tag_method but always generates a div tag
10
+ # The tag option is not available
11
+ def def_div_method name, html_class, opts={}, &tag_block
12
+ def_tag_method name, html_class, opts.merge(tag: :div), &tag_block
13
+ end
14
+
15
+ # Defines a method that generates a html tag
16
+ # @param method_name [Symbol, String] the name of the method. If no :tag option
17
+ # in tag_opts is defined then the name is also the name of the tag that the
18
+ # method generates
19
+ # @param html_class [String] a html class that is added to tag. Use nil if you
20
+ # don't want a html_class
21
+ # @param tag_opts [Hash] additional argument that will be added to the tag
22
+ # @option tag_opts [Symbol, String] tag the name of the tag
23
+ # @example
24
+ # def_tag_method :link, "known-link", tag: :a, id: "uniq-link"
25
+ # link # => <a class="known-link" id="uniq-link"></a>
26
+ def def_tag_method method_name, html_class, tag_opts={}, &tag_opts_block
27
+ tag = tag_opts.delete(:tag) || method_name
28
+ define_method method_name do |*args, &content_block|
29
+ @html.tag! tag, tag_method_opts(args, html_class, tag_opts, &tag_opts_block) do
30
+ instance_exec(&content_block)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -2,7 +2,7 @@ class Bootstrap
2
2
  class Component
3
3
  class Form < Component
4
4
  def render_content *args
5
- form *args, &@build_block
5
+ form(*args, &@build_block)
6
6
  end
7
7
 
8
8
  #
@@ -23,13 +23,13 @@ class Bootstrap
23
23
  add_class opts, "form-horizontal" if opts.delete(:horizontal)
24
24
  add_class opts, "form-inline" if opts.delete(:inline)
25
25
  @html.form opts do
26
- instance_exec &block
26
+ instance_exec(&block)
27
27
  end
28
28
  end
29
29
 
30
30
  def group text=nil, &block
31
31
  @html.div text, class: "form-group" do
32
- instance_exec &block
32
+ instance_exec(&block)
33
33
  end
34
34
  end
35
35
 
@@ -53,7 +53,7 @@ class Bootstrap
53
53
  # opts
54
54
  # end
55
55
 
56
- define_method tag do |text: nil, id:, label: |
56
+ define_method tag do |id:, label:, text: nil|
57
57
  @html.input id: id, class: "form-control", type: tag do
58
58
  @html.label label, for: id if label
59
59
  @html << text