bootstrap_builders 0.0.57 → 0.0.58

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb24102d775e6d84af456d1f248ad0b5959bb9be
4
- data.tar.gz: 930daebdc4cf5dacbc7059621b825845cb3ca362
3
+ metadata.gz: 3e303a01b54c15d59f2936827173ca7404a9365c
4
+ data.tar.gz: 398879ca3fc276a118f61530f8c82e50574453f4
5
5
  SHA512:
6
- metadata.gz: 636cb389b0f3a0b3d974de289512b75ba2507c7981b9675c029d16a4b350c5b54e3f4c67f38dd8aa7566d56b324e2bb80143ec0a46bca366bcbb7ca3065300a5
7
- data.tar.gz: 979c306390c542717affc8222d4e811db9f441e4e83ad57afa8b8481851f451a338204d2621d045cde0367a6a1d2f6a4c8b6614d4dc9e3489779b3c4fd707f58
6
+ metadata.gz: c31c1afe0e028a11116c29d9b6fe1eb8754d8ea42942abf91c8dbc090b5b6f7b46a8182347b4faf880d31f4c9b31851bc2c2140d5107de9c3448b3ce1b65ab1a
7
+ data.tar.gz: '08ed57c31cf021b758f7df1a1e098def0745a5f082fcfdbe15f13d35f3bd7295b04db53c38fb0ff4653a6d3053adcf08d0681af032d0c5923ff49ceb67efda1e'
data/README.md CHANGED
@@ -138,6 +138,14 @@ The classes "bb-table" and "table" are always added.
138
138
  <%= bb_btn "/url", "My label", :block, :lg, :confirm, :disabled %>
139
139
  ```
140
140
 
141
+ ### Button drop downs
142
+
143
+ ```erb
144
+ <%= bb_btn_drop_down label: t("actions") do |drop_down| %>
145
+ <% drop_down.option [:new, :something], t(".new"), icon: "plus" %>
146
+ <% end %>
147
+ ```
148
+
141
149
  ### Responsive mixins
142
150
 
143
151
  Use responsive mixins to only apply certain CSS rules on specific sizes, below or above.
@@ -1,8 +1,14 @@
1
1
  class BootstrapBuilders::ButtonDropDown
2
2
  attr_accessor :view_context
3
3
 
4
- def initialize(args)
5
- @args = args
4
+ def initialize(*args)
5
+ args_parser = BootstrapBuilders::ArgumentsParser.new(
6
+ arguments: args,
7
+ short_true_arguments: [:block, :danger, :link, :info, :primary, :sm, :warning]
8
+ )
9
+
10
+ args_parser.arguments_hash[:label] ||= args.shift if args.first.is_a?(String)
11
+ @args = args_parser.arguments_hash
6
12
  @buttons = []
7
13
  end
8
14
 
@@ -32,7 +38,7 @@ class BootstrapBuilders::ButtonDropDown
32
38
  "aria-exapended" => false,
33
39
  type: "button"
34
40
  },
35
- classes: ["btn", "btn-default", "dropdown-toggle"],
41
+ classes: classes.classes,
36
42
  data: {
37
43
  toggle: "dropdown"
38
44
  }
@@ -63,4 +69,33 @@ class BootstrapBuilders::ButtonDropDown
63
69
 
64
70
  btn_group.html
65
71
  end
72
+
73
+ private
74
+
75
+ def add_default_as_default
76
+ @classes.add("btn-default") if !@args[:danger] && !@args[:info] && !@args[:primary] && !@args[:warning]
77
+ end
78
+
79
+ def classes
80
+ unless @classes
81
+ @classes = BootstrapBuilders::ClassAttributeHandler.new(class: ["btn", "btn-default", "dropdown-toggle"])
82
+ @classes.add("bb-btn-responsive") if @args[:responsive]
83
+ add_default_as_default
84
+ @classes.add("btn-block") if @args[:block]
85
+ @classes.add("btn-danger") if @args[:danger]
86
+ @classes.add("btn-info") if @args[:info]
87
+ @classes.add("btn-link") if @args[:link]
88
+ @classes.add("btn-primary") if @args[:primary]
89
+ @classes.add("btn-warning") if @args[:warning]
90
+
91
+ size_classes = [:lg, :md, :sm, :xs]
92
+ size_classes.each do |size_class|
93
+ next unless @args[size_class]
94
+ btn_size_class = "btn-#{size_class}"
95
+ @classes.add(btn_size_class) unless @classes.include?(btn_size_class)
96
+ end
97
+ end
98
+
99
+ @classes
100
+ end
66
101
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapBuilders
2
- VERSION = "0.0.57".freeze
2
+ VERSION = "0.0.58".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_builders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.57
4
+ version: 0.0.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-11 00:00:00.000000000 Z
11
+ date: 2017-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails