bootstrap_builders 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d2b445ff08e8364293bcc095ec87fce582b6cfc
4
- data.tar.gz: e52c591ab8cb84304d59870f1198f0898f52dd5b
3
+ metadata.gz: 5667a14a34a64f4e0d6dc77a4132aab7e960d3c6
4
+ data.tar.gz: a145dbbb99683102010efc65bf84ad8925450f8d
5
5
  SHA512:
6
- metadata.gz: 6ef12514c3312731383bee31575bfdcf7bf6ec502f8918843f56d8c3c7b0643c0f2c31d1f2e582b9f66adbb226ef23504b3f99a5572dd8fb9a0a366c6bd6f5a3
7
- data.tar.gz: 6bd1b2ec48146106df1abf9a4fb3e8dd7211617c38bde91ee91ce72c76be06903eef9b702d77e3de9c16a2c52479ab390364ef5b7b4c20c40534e12ccb9caf30
6
+ metadata.gz: a9a1c90e3d3cd6fd3ea8767fe90d29799285a0aef122b71d4e944ddef353d65baf72e05f617265222c308535bc0cd84043bfedc1a183ecdec44c31a74aa98bc1
7
+ data.tar.gz: f8d789fbbeaf73c1cb0a33d9cfb6d121ad1085e7cf339045de2ccfd73cda8743b41dbb41b147621c90af575dc5f0b9b010f4c8fa81b59b113a9725490403717a
data/README.md CHANGED
@@ -55,6 +55,14 @@ You can add custom classes like this:
55
55
  %td= "Test"
56
56
  ```
57
57
 
58
+ 2. A table showing a models attributes:
59
+
60
+ ```haml
61
+ = bb_table do
62
+ %tbody
63
+ = bb_attribute_rows @model, [:id, :created_at, :updated_at]
64
+ ```
65
+
58
66
  You can change the default classes like this:
59
67
  ```ruby
60
68
  BootstrapBuilders.configuration.default_table_classes = [:striped, :hover]
@@ -97,13 +97,19 @@ module BootstrapBuilders::ApplicationHelper
97
97
  button.html
98
98
  end
99
99
 
100
+ def bb_flash(args = {})
101
+ flash = BootstrapBuilders::Flash.new(args.merge(context: self))
102
+ flash.html
103
+ end
104
+
100
105
  def bb_table(args = {}, &blk)
101
106
  table = BootstrapBuilders::Table.new(args.merge(context: self, blk: blk))
102
107
  table.html
103
108
  end
104
109
 
105
- def bb_flash(args = {})
106
- flash = BootstrapBuilders::Flash.new(args.merge(context: self))
107
- flash.html
110
+ def bb_tabs(args = {})
111
+ tabs = BootstrapBuilders::Tabs.new(args.merge(context: self))
112
+ yield tabs
113
+ tabs.to_html
108
114
  end
109
115
  end
@@ -12,6 +12,8 @@ module BootstrapBuilders
12
12
  autoload :IsAChecker
13
13
  autoload :Panel
14
14
  autoload :Table
15
+ autoload :Tab
16
+ autoload :Tabs
15
17
 
16
18
  def self.configuration
17
19
  @configuration ||= BootstrapBuilders::Configuration.new
@@ -0,0 +1,16 @@
1
+ class BootstrapBuilders::Tab
2
+ attr_accessor :container_html
3
+ attr_reader :container_id, :label
4
+
5
+ def initialize(args)
6
+ @active = args[:active]
7
+ @label = args.fetch(:label)
8
+
9
+ @container_id = args[:container_id].presence
10
+ @container_id ||= SecureRandom.hex
11
+ end
12
+
13
+ def active?
14
+ @active
15
+ end
16
+ end
@@ -0,0 +1,41 @@
1
+ class BootstrapBuilders::Tabs
2
+ def initialize(args)
3
+ @context = args.fetch(:context)
4
+ @tabs = []
5
+ end
6
+
7
+ def tab(*args, &blk)
8
+ tab_args = {}
9
+
10
+ tab_args[:label] = args.shift if args.first.is_a?(String)
11
+ tab_args[:container_id] = args.shift if args.first.is_a?(String)
12
+ tab_args.merge!(args.shift) if args.first.is_a?(Hash)
13
+
14
+ tab = BootstrapBuilders::Tab.new(tab_args)
15
+ tab.container_html = @context.content_tag(:div, nil, class: ["bb-tab-container"], &blk)
16
+ @tabs << tab
17
+ nil
18
+ end
19
+
20
+ def to_html
21
+ container = HtmlGen::Element.new(:div, inden: " ", classes: ["bb-tabs-container"])
22
+ ul = container.add_ele(:ul, classes: ["nav", "nav-tabs"])
23
+
24
+ @tabs.each do |tab|
25
+ li = ul.add_ele(:li)
26
+ li.add_ele(:a, str: tab.label, attr: {href: "##{tab.container_id}"}, data: {toggle: "tab"})
27
+ li.classes << "active" if tab.active?
28
+ end
29
+
30
+ tabs_content = container.add_ele(:div, classes: ["tab-content"])
31
+
32
+ @tabs.each do |tab|
33
+ tab_content = tabs_content.add_ele(:div, classes: ["tab-pane"], attr: {id: tab.container_id})
34
+ tab_content.add_ele(:h3, str: tab.label)
35
+ tab_content.add_html(tab.container_html)
36
+ tab_content.classes << "active" if tab.active?
37
+ end
38
+
39
+ container.html
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module BootstrapBuilders
2
- VERSION = "0.0.6".freeze
2
+ VERSION = "0.0.7".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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -212,14 +212,14 @@ dependencies:
212
212
  requirements:
213
213
  - - '='
214
214
  - !ruby/object:Gem::Version
215
- version: 0.36.0
215
+ version: 0.40.0
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - '='
221
221
  - !ruby/object:Gem::Version
222
- version: 0.36.0
222
+ version: 0.40.0
223
223
  description: A library to generate Bootstrap HTML for Rails.
224
224
  email:
225
225
  - kaspernj@gmail.com
@@ -246,7 +246,9 @@ files:
246
246
  - lib/bootstrap_builders/flash.rb
247
247
  - lib/bootstrap_builders/is_a_checker.rb
248
248
  - lib/bootstrap_builders/panel.rb
249
+ - lib/bootstrap_builders/tab.rb
249
250
  - lib/bootstrap_builders/table.rb
251
+ - lib/bootstrap_builders/tabs.rb
250
252
  - lib/bootstrap_builders/version.rb
251
253
  - lib/tasks/bootstrap_builders_tasks.rake
252
254
  homepage: https://github.com/kaspernj/bootstrap_builders