bootstrap_builders 0.0.16 → 0.0.17

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: 4cea9f9ce171e693d5b8b7abec3af1487f690940
4
- data.tar.gz: 401cf5ce394a7ca92a5bbceafb14acee0c41586b
3
+ metadata.gz: 86af43be2744904728e7bcf4695eafcb4c735674
4
+ data.tar.gz: ec12f0941810f4f603d11299d87e2e857e8caafc
5
5
  SHA512:
6
- metadata.gz: e21fcde535f048f3f1c4fac6b60b2c03739baa405099396fd8e18531e5b63fa98ffe97e357befdfebf4c38338076e5e68eb491c53acb6dabd458634a7f344105
7
- data.tar.gz: f7758ca1c4f2c095fafffafb838f0c6ccf306ded35f32ed171a06aaafc917f726047c3c90915b6d5410ec10af6f4e1ad98603dcbaae4c7940d1c2555a71228d7
6
+ metadata.gz: 74b8839a01f9b473c6296a366e4e4677b68d82a4b82ea31187d18b55ff7e7bfe1252a8a28735b741b540c641cec18f6ae17ce84bfb45d4b36b77ec71d93b3e7e
7
+ data.tar.gz: 34cb7316f6a42ee7a591cedfcdf229fd7b1b82b98b0210264b687481586eaf4b77defa25cf2ff9e02e2132ccd7d3f8cd374d7534d805842891114af37626d4a8
data/README.md CHANGED
@@ -33,7 +33,13 @@ Then add to your `application.css`:
33
33
  3. Table if `:table` argument is given
34
34
 
35
35
  ```haml
36
- = bb_panel "Title of panel", right: button_content do
36
+ = bb_panel "Title of panel", controls: button_content do
37
+ Content of panel
38
+ ```
39
+
40
+ ```haml
41
+ = bb_panel "Title of panel", controls: button_content do |panel|
42
+ - panel.controls << bb_btn("#", "Another button", :mini)
37
43
  Content of panel
38
44
  ```
39
45
 
@@ -1,5 +1,5 @@
1
1
  class BootstrapBuilders::Panel
2
- attr_accessor :context
2
+ attr_accessor :context, :controls
3
3
 
4
4
  def self.with_parsed_args(*opts, &blk)
5
5
  title = opts.shift unless opts.first.is_a?(Hash)
@@ -19,15 +19,20 @@ class BootstrapBuilders::Panel
19
19
 
20
20
  def initialize(args)
21
21
  @title = args.fetch(:title)
22
- @controls = args[:controls]
23
22
  @table = args[:table]
24
- @block = args.fetch(:block)
25
23
  @context = args[:context]
26
24
  @class = args[:class]
27
25
  @data = args[:data]
28
26
 
27
+ @controls = args[:controls]
28
+ @controls = [@controls] unless @controls.is_a?(Array)
29
+
29
30
  @css = {}
30
31
  @css[:width] = args.fetch(:width) if args[:width]
32
+
33
+ @block = proc do
34
+ args.fetch(:block).call(self)
35
+ end
31
36
  end
32
37
 
33
38
  def html
@@ -41,6 +46,7 @@ class BootstrapBuilders::Panel
41
46
  add_body
42
47
  end
43
48
 
49
+ add_heading_controls
44
50
  html = @panel.html
45
51
 
46
52
  if html.respond_to?(:html_safe)
@@ -53,15 +59,17 @@ class BootstrapBuilders::Panel
53
59
  private
54
60
 
55
61
  def add_heading
56
- heading = @panel.add_ele(:div, classes: ["panel-heading", "clearfix"])
62
+ @heading = @panel.add_ele(:div, classes: ["panel-heading", "clearfix"])
57
63
 
58
64
  if !@title || @title.to_s.strip.empty?
59
- heading.add_ele(:div, classes: ["panel-title", "pull-left"], str_html: "&nbsp;") if @controls
65
+ @heading.add_ele(:div, classes: ["panel-title", "pull-left"], str_html: "&nbsp;") if @controls
60
66
  else
61
- heading.add_ele(:div, classes: ["panel-title", "pull-left"], str: @title)
67
+ @heading.add_ele(:div, classes: ["panel-title", "pull-left"], str: @title)
62
68
  end
69
+ end
63
70
 
64
- heading.add_ele(:div, classes: ["pull-right"], str_html: controls_content) if @controls
71
+ def add_heading_controls
72
+ @heading.add_ele(:div, classes: ["pull-right"], str_html: controls_content) if @controls
65
73
  end
66
74
 
67
75
  def controls_content
@@ -1,3 +1,3 @@
1
1
  module BootstrapBuilders
2
- VERSION = "0.0.16".freeze
2
+ VERSION = "0.0.17".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.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-27 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails