card-mod-bootstrap 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9c45768f3e39a90bdf3221273cb03618c1d5604c7171c5b09b6ac1a73792bfd
4
- data.tar.gz: 3cc39c355177d193259941fa3c179bff3bb2eea750144ace1e61e2582583dbd8
3
+ metadata.gz: c958ede5306d8ad27fc2eabd5b52081202d49ebdfbc2581f23a6196adeeaa18c
4
+ data.tar.gz: 6fb46afc92a6fede6948991c58e20501f4e09ecdf4e0477a4d78d418c71c6ecd
5
5
  SHA512:
6
- metadata.gz: 9c6b1b7b29cc5ff96abb6794d2199541821df71a701f4b3c866f22799a61d510993d50c2ede724ce4f2e33137e34855d14f30ebfa668abc2e090222c026ee370
7
- data.tar.gz: 6b1fc97e12a256ff08f59d6e99e8d77edda9eb7539929bff0aeac576714ce07ee49bc254e596fc1691bf497a0eef5ea15315c8bfbdfcd1c14ab3a750a7afc48b
6
+ metadata.gz: 695eaca2a8e8caf883a135bba58d1c401286531be65d764a6e0cd4a998335ccd703a26a539774e2d97777fffe5dc68ab1495ed195dee9ca1224df2a98121f910
7
+ data.tar.gz: c539996dc2e5b04c639b5f13083b6f8e3cf9d80b5744c87ac6704748b6e7b249cde10b0a9d9b8a80166d64845a6869231f9184c9e12e7e0019fb98f74daca279
@@ -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
@@ -0,0 +1,17 @@
1
+ class Card
2
+ class Bootstrap
3
+ include Delegate
4
+ extend ComponentLoader
5
+ load_components
6
+
7
+ attr_reader :context
8
+
9
+ def initialize context=nil
10
+ @context = context
11
+ end
12
+
13
+ def render *args, &block
14
+ instance_exec(*args, &block)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ class Card
2
+ class Bootstrap
3
+ module BasicTags
4
+ def html content
5
+ add_content String(content).html_safe
6
+ ""
7
+ end
8
+
9
+ Component.def_div_method :div, nil do |opts, extra_args|
10
+ prepend_class opts, extra_args.first if extra_args.present?
11
+ opts
12
+ end
13
+
14
+ Component.def_div_method :span, nil do |opts, extra_args|
15
+ prepend_class opts, extra_args.first if extra_args.present?
16
+ opts
17
+ end
18
+
19
+ Component.def_tag_method :tag, nil, tag: :yield do |opts, extra_args|
20
+ prepend_class opts, extra_args[1] if extra_args[1].present?
21
+ opts[:tag] = extra_args[0]
22
+ opts
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,110 @@
1
+ class Card
2
+ class Bootstrap
3
+ # render components of bootstrap library
4
+ class Component
5
+ extend ComponentKlass
6
+
7
+ def initialize context, *args, &block
8
+ @context = context
9
+ @content = ["".html_safe]
10
+ @args = args
11
+ @child_args = []
12
+ @append = []
13
+ @wrap = []
14
+ @build_block = block
15
+ @html = Builder::XmlMarkup.new
16
+ end
17
+
18
+ def render
19
+ @rendered = render_content
20
+ end
21
+
22
+ def prepend &block
23
+ tmp = @content.pop
24
+ instance_exec(&block)
25
+ @content << tmp
26
+ end
27
+
28
+ def insert &block
29
+ instance_exec(&block)
30
+ end
31
+
32
+ def append &block
33
+ @append[-1] << block
34
+ end
35
+
36
+ def wrap tag=nil, &block
37
+ @wrap[-1] << (block_given? ? block : tag)
38
+ end
39
+
40
+ def card
41
+ @context.context.card
42
+ end
43
+
44
+ private
45
+
46
+ def tag_method_opts args, html_class, tag_opts, &tag_opts_block
47
+ opts = {}
48
+ _blah, opts, _blah = standardize_args args, &tag_opts_block if block_given?
49
+ add_classes opts, html_class, tag_opts.delete(:optional_classes)
50
+ opts
51
+ end
52
+
53
+ def render_content
54
+ # if @build_block.arity > 0
55
+ instance_exec(*@args, &@build_block)
56
+ end
57
+
58
+ def generate_content content, processor, &block
59
+ content = instance_exec(&block) if block.present?
60
+ return content if !processor || !content.is_a?(Array)
61
+
62
+ content.each { |item| send processor, item }
63
+ ""
64
+ end
65
+
66
+ def with_child_args args
67
+ @child_args << args if args.present?
68
+ yield.tap { @child_args.pop if args.present? }
69
+ end
70
+
71
+ def add_content content
72
+ @content[-1] << "\n#{content}".html_safe if content.present?
73
+ end
74
+
75
+ def standardize_args args, &block
76
+ opts = standardize_opts args
77
+ items = items_from_args args
78
+ opts, args = standardize_block_args opts, args, &block if block.present?
79
+
80
+ [items, opts, args]
81
+ end
82
+
83
+ def standardize_opts args
84
+ args.last.is_a?(Hash) ? args.pop : {}
85
+ end
86
+
87
+ def items_from_args args
88
+ ((args.one? && args.last.is_a?(String)) || args.last.is_a?(Array)) && args.pop
89
+ end
90
+
91
+ def standardize_block_args opts, args, &block
92
+ instance_exec(opts, args, &block).tap do |s_opts, _s_args|
93
+ unless s_opts.is_a? Hash
94
+ raise Card::Error, "first return value of a tag block has to be a hash"
95
+ end
96
+ end
97
+ end
98
+
99
+ def add_classes opts, html_class, optional_classes
100
+ prepend_class opts, html_class if html_class
101
+ Array.wrap(optional_classes).each do |k, v|
102
+ prepend_class opts, v if opts.delete k
103
+ end
104
+ end
105
+
106
+ include BasicTags
107
+ include Delegate
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,78 @@
1
+ class Card
2
+ class Bootstrap
3
+ class Component
4
+ class Carousel < Component
5
+ def render_content
6
+ carousel(*@args, &@build_block)
7
+ end
8
+
9
+ def carousel id, active_index, &block
10
+ @id = id
11
+ @active_item_index = active_index
12
+ @items = []
13
+ instance_exec(&block)
14
+
15
+ @html.div class: "carousel slide", id: id, "data-ride" => "carousel" do
16
+ indicators
17
+ items
18
+ control_prev
19
+ control_next
20
+ end
21
+ end
22
+
23
+ def item content=nil, &block
24
+ @items << (content || block)
25
+ end
26
+
27
+ def items
28
+ @html.div class: "carousel-inner", role: "listbox" do
29
+ @items.each_with_index do |item, index|
30
+ carousel_item item, carousel_item_opts(index)
31
+ end
32
+ end
33
+ end
34
+
35
+ def carousel_item_opts index
36
+ { class: "carousel-item" }.tap do |opts|
37
+ add_class opts, "active" if index == @active_item_index
38
+ end
39
+ end
40
+
41
+ def carousel_item item, html_opts
42
+ @html.div html_opts do
43
+ item = item.call if item.respond_to?(:call)
44
+ @html << item if item.is_a?(String)
45
+ end
46
+ end
47
+
48
+ def control_prev
49
+ @html.a class: "carousel-control-prev", href: "##{@id}", role: "button",
50
+ "data-slide" => "prev" do
51
+ @html.span class: "carousel-control-prev-icon", "aria-hidden" => "true"
52
+ @html.span "Previous", class: "sr-only"
53
+ end
54
+ end
55
+
56
+ def control_next
57
+ @html.a class: "carousel-control-next", href: "##{@id}", role: "button",
58
+ "data-slide": "next" do
59
+ @html.span class: "carousel-control-next-icon", "aria-hidden" => "true"
60
+ @html.span "Next", class: "sr-only"
61
+ end
62
+ end
63
+
64
+ def indicators
65
+ @html.ol class: "carousel-indicators" do
66
+ @items.size.times { |i| indicator i }
67
+ end
68
+ end
69
+
70
+ def indicator index
71
+ html_opts = { "data-slide-to" => index, "data-target": "##{@id}" }
72
+ add_class html_opts, "active" if index == @active_item_index
73
+ @html.li html_opts
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,67 @@
1
+ class Card
2
+ class Bootstrap
3
+ class Component
4
+ class Form < Component
5
+ def render_content *args
6
+ form(*args, &@build_block)
7
+ end
8
+
9
+ #
10
+ # def_tag_method :form, nil, optional_classes: {
11
+ # horizontal: "form-horizontal",
12
+ # inline: "form-inline"
13
+ # }
14
+ # def_div_method :group, "form-group"
15
+ # def_tag_method :label, nil
16
+ # def_tag_method :input, "form-control" do |opts, extra_args|
17
+ # type, label = extra_args
18
+ # prepend { label label, for: opts[:id] } if label
19
+ # opts[:type] = type
20
+ # opts
21
+ # end
22
+
23
+ def form opts={}, &block
24
+ add_class opts, "form-horizontal" if opts.delete(:horizontal)
25
+ add_class opts, "form-inline" if opts.delete(:inline)
26
+ @html.form opts do
27
+ instance_exec(&block)
28
+ end
29
+ end
30
+
31
+ def group text=nil, &block
32
+ @html.div text, class: "form-group" do
33
+ instance_exec(&block)
34
+ end
35
+ end
36
+
37
+ def label text=nil, &block
38
+ @html.label text, &block
39
+ end
40
+
41
+ def input type, text: nil, label: nil, id: nil
42
+ @html.input id: id, class: "form-control", type: type do
43
+ @html.label label, for: id if label
44
+ @html << text if text
45
+ end
46
+ end
47
+
48
+ %i[text password datetime datetime-local date month time
49
+ week number email url search tel color].each do |tag|
50
+ # def_tag_method tag, "form-control", attributes: { type: tag },
51
+ # tag: :input do |opts, extra_args|
52
+ # label, = extra_args
53
+ # prepend { label label, for: opts[:id] } if label
54
+ # opts
55
+ # end
56
+
57
+ define_method tag do |id:, label:, text: nil|
58
+ @html.input id: id, class: "form-control", type: tag do
59
+ @html.label label, for: id if label
60
+ @html << text
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,65 @@
1
+ class Card
2
+ class Bootstrap
3
+ class Component
4
+ class HorizontalForm < Form
5
+ def left_col_width
6
+ @child_args.last && @child_args.last[0] || 2
7
+ end
8
+
9
+ def right_col_width
10
+ @child_args.last && @child_args.last[1] || 10
11
+ end
12
+
13
+ def_tag_method :form, "form-horizontal"
14
+
15
+ def_tag_method :label, "control-label" do |opts, _extra_args|
16
+ prepend_class opts, "col-sm-#{left_col_width}"
17
+ opts
18
+ end
19
+
20
+ # def_div_method :input, nil do |opts, extra_args, &block|
21
+ # type, label = extra_args
22
+ # prepend { tag(:label, nil, for: opts[:id]) { label } } if label
23
+ # insert { inner_input opts.merge(type: type) }
24
+ # { class: "col-sm-#{right_col_width}" }
25
+ # end
26
+
27
+ def label_col label, id:
28
+ @html.label label, for: id, class: "col-sm-#{left_col_width} control-label"
29
+ end
30
+
31
+ def input type, label:, id:
32
+ label_col label, id: id
33
+ @html.div class: "col-sm-#{right_col_width}" do
34
+ @html.input type: type, id: id, class: "form-control"
35
+ end
36
+ # block.call class: "col-sm-#{right_col_width}" do
37
+ # inner_input opts.merge(type: type)
38
+ # end
39
+ end
40
+
41
+ def_tag_method :inner_input, "form-control", tag: :input
42
+ def_div_method :inner_checkbox, "checkbox"
43
+
44
+ def_div_method :checkbox, nil do |opts, extra_args|
45
+ inner_checkbox do
46
+ label do
47
+ inner_input "checkbox", extra_args.first, opts
48
+ end
49
+ end
50
+ { class: "col-sm-offset-#{left_col_width} col-sm-#{right_col_width}" }
51
+ end
52
+
53
+ def checkbox _text, _extra_args
54
+ @html.div class: "col-sm-offset-#{left_col_width} col-sm-#{right_col_width}" do
55
+ @html.div class: "checkbox" do
56
+ label_cllabel do
57
+ inner_input "checkbox"
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end