twitter-bootstrap-components-rails 0.5.1 → 0.6.0

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: a9e07dba730485ac765a56c139567c1ac47d1453
4
- data.tar.gz: a30d95ae90652378d74e1a556b066defd03fb1d1
3
+ metadata.gz: 2691f40249dfa6fb7610573c99cf126556f2ca08
4
+ data.tar.gz: 4752a3ade40ff4cdec10d3ed0ff81d2ab9b83768
5
5
  SHA512:
6
- metadata.gz: d1034a0efb11e549318e8f33c360d0c9ea81ae98a0331e28c4f2398e6fccae8cf353ad7505d1897f55f764d3567b557217d6a35a4991d1ab7471f79c263d2b8a
7
- data.tar.gz: 645a7a250a9828238b7cb8429572e8d563f0f22029000732d6ea21d974e784953e2c127823c0c3bffecf2479156b07df780f94043c6c249f77e1f0fdb6cd9bf7
6
+ metadata.gz: 378db48735dd633c524178789cf3502990a97cf7feb537220d0b17a0291bb95fb2fbef40296a52e8281477517b7ecba3c885d76065ffb889da9699b0673c31fc
7
+ data.tar.gz: 8399ba8144c8c87c3f101fd901d42158ccfaaead45ba8343cb3495cdf0fe2e9bcc16e49caaa57270983e391f79bf47876bd81e0ffe6eab5e2e07e0dae0531a94
@@ -3,10 +3,21 @@ module Twitter
3
3
  module Components
4
4
  module V4
5
5
  class Card < Base
6
+ def initialize(*args)
7
+ super
8
+ @options.reverse_merge(default_options)
9
+ end
10
+
6
11
  private
7
12
 
13
+ def default_options
14
+ {
15
+ gutters: true
16
+ }
17
+ end
18
+
8
19
  def view_locals
9
- {
20
+ {
10
21
  block_output: block_output,
11
22
  image_options: image_options,
12
23
  additional_css_classes: additional_css_classes
@@ -26,7 +37,7 @@ module Twitter
26
37
  end
27
38
 
28
39
  def additional_css_classes
29
- [@options[:additional_css_classes], text_algin_css_class, inverse_css_class, context_css_class].compact.join(" ")
40
+ [@options[:additional_css_classes], gutters_css_class, text_algin_css_class, inverse_css_class, context_css_class].compact.join(" ")
30
41
  end
31
42
 
32
43
  def text_align
@@ -42,6 +53,14 @@ module Twitter
42
53
  end
43
54
  end
44
55
 
56
+ def gutters
57
+ @options[:gutters]
58
+ end
59
+
60
+ def gutters_css_class
61
+ @options[:gutters] ? nil : 'no-gutters'
62
+ end
63
+
45
64
  def inverse?
46
65
  !!@options[:inverse]
47
66
  end
@@ -61,4 +80,4 @@ module Twitter
61
80
  end
62
81
  end
63
82
  end
64
- end
83
+ end
@@ -0,0 +1,52 @@
1
+ module Twitter
2
+ module Bootstrap
3
+ module Components
4
+ module V4
5
+ class Carousel < Base
6
+ def add_item(options = {})
7
+ @items << options
8
+ end
9
+
10
+ private
11
+
12
+ def initialize(*args)
13
+ super
14
+ @options.reverse_merge!(option_defaults)
15
+ @items = []
16
+ end
17
+
18
+ def view_locals
19
+ {
20
+ block_output: @block_output,
21
+ carousel_id: carousel_id,
22
+ items: @items,
23
+ carousel_options: carousel_options,
24
+ autostart: @options[:autostart]
25
+ }
26
+ end
27
+
28
+ def carousel_id
29
+ @options[:id] || "carousel-#{SecureRandom.uuid}"
30
+ end
31
+
32
+ def carousel_options
33
+ @carousel_options ||= %i(interval keyboard pause ride wrap).each_with_object({}) do |key, memo|
34
+ memo["data-#{key}"] = @options[key].to_s
35
+ end
36
+ end
37
+
38
+ def option_defaults
39
+ {
40
+ autostart: true,
41
+ interval: 5000,
42
+ keyboard: true,
43
+ pause: 'hover',
44
+ ride: 'false',
45
+ wrap: true
46
+ }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,32 @@
1
+ module Twitter
2
+ module Bootstrap
3
+ module Components
4
+ module V4
5
+ class CarouselItem < Base
6
+ private
7
+
8
+ def view_locals
9
+ {
10
+ block_output: @block_output,
11
+ caption: caption,
12
+ image_source: image_source,
13
+ active: active
14
+ }
15
+ end
16
+
17
+ def active
18
+ @options[:active]
19
+ end
20
+
21
+ def caption
22
+ @options[:caption]
23
+ end
24
+
25
+ def image_source
26
+ @options[:image_source]
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,43 @@
1
+ module Twitter
2
+ module Bootstrap
3
+ module Components
4
+ module V4
5
+ # Example:
6
+ #
7
+ # .col-lg-4
8
+ # = bootstrap_portrait_card(image_options: { src: "data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" }) do
9
+ # %h2 Heading
10
+ # %p Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna.
11
+ # %p
12
+ # %a.btn.btn-secondary{:href => "#", :role => "button"} View details »
13
+ #
14
+ class PortraitCard < Base
15
+ attr_accessor :image_options
16
+
17
+ def initialize(*args)
18
+ super
19
+ @options.reverse_merge(default_options)
20
+ @image_options = (@options.delete(:image_options) || {}).reverse_merge(default_image_options)
21
+ end
22
+
23
+ private
24
+
25
+ def default_options
26
+ {}
27
+ end
28
+
29
+ def default_image_options
30
+ { height: "140", width: "140"}
31
+ end
32
+
33
+ def view_locals
34
+ {
35
+ block_output: block_output,
36
+ image_options: image_options
37
+ }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -28,8 +28,12 @@ module Twitter
28
28
  Twitter::Bootstrap::Components::V4::Card.new(self, options, &block).perform
29
29
  end
30
30
 
31
- def bootstrap_carousel(options)
32
- Twitter::Bootstrap::Components::V4::Carousel.new(options).perform
31
+ def bootstrap_carousel(options = {}, &block)
32
+ Twitter::Bootstrap::Components::V4::Carousel.new(self, options, &block).perform
33
+ end
34
+
35
+ def bootstrap_carousel_item(options = {}, &block)
36
+ Twitter::Bootstrap::Components::V4::CarouselItem.new(self, options, &block).perform
33
37
  end
34
38
 
35
39
  def bootstrap_collapse(options)
@@ -49,6 +53,10 @@ module Twitter
49
53
  Twitter::Bootstrap::Components::V4::Form.new(options).perform
50
54
  end
51
55
 
56
+ def bootstrap_portrait_card(options = {}, &block)
57
+ Twitter::Bootstrap::Components::V4::PortraitCard.new(self, options, &block).perform
58
+ end
59
+
52
60
  # add-on
53
61
  def bootstrap_form_for(object, *args, &block)
54
62
  options = args.extract_options!
@@ -0,0 +1,24 @@
1
+ .carousel.slide{ carousel_options, id: carousel_id }
2
+ %ol.carousel-indicators
3
+ - items.each_with_index do |item, index|
4
+ - if index == 0
5
+ %li.active{"data-slide-to" => index.to_s, "data-target" => "##{carousel_id}" }
6
+ - else
7
+ %li{"data-slide-to" => index.to_s, "data-target" => "##{carousel_id}" }
8
+ .carousel-inner
9
+ - items.each_with_index do |item, index|
10
+ - item.merge!(active: true) if index == 0
11
+ = bootstrap_carousel_item(item)
12
+ %a.carousel-control-prev{"data-slide" => "prev", :href => "##{carousel_id}" , :role => "button"}
13
+ %span.carousel-control-prev-icon{"aria-hidden" => "true"}
14
+ %span.sr-only Previous
15
+ %a.carousel-control-next{"data-slide" => "next", :href => "##{carousel_id}" , :role => "button"}
16
+ %span.carousel-control-next-icon{"aria-hidden" => "true"}
17
+ %span.sr-only Next
18
+ - if autostart
19
+ :javascript
20
+ $('##{carousel_id}').carousel(
21
+ {
22
+ interval: #{carousel_options['data-interval']}
23
+ }
24
+ );
@@ -0,0 +1,6 @@
1
+ - div_classes = active ? 'carousel-item active' : 'carousel-item'
2
+ %div{ class: div_classes }
3
+ %img.d-block.w-100{ src: image_source }/
4
+ - if caption.present?
5
+ .carousel-caption.d-none.d-md-block
6
+ = caption
@@ -0,0 +1,3 @@
1
+ .text-center
2
+ %img.rounded-circle{ image_options }/
3
+ = block_output
@@ -0,0 +1 @@
1
+ require 'twitter/bootstrap/components/rails'
@@ -2,7 +2,7 @@ module Twitter
2
2
  module Bootstrap
3
3
  module Components
4
4
  module Rails
5
- VERSION = '0.5.1'
5
+ VERSION = '0.6.0'.freeze
6
6
  end
7
7
  end
8
8
  end
@@ -1 +1 @@
1
- require 'twitter/bootstrap/components/rails'
1
+ require 'twitter_bootstrap_components_rails'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter-bootstrap-components-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-01 00:00:00.000000000 Z
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -157,10 +157,13 @@ files:
157
157
  - app/components/twitter/bootstrap/components/v4/card/blockquote.rb
158
158
  - app/components/twitter/bootstrap/components/v4/card/footer.rb
159
159
  - app/components/twitter/bootstrap/components/v4/card/header.rb
160
+ - app/components/twitter/bootstrap/components/v4/carousel.rb
161
+ - app/components/twitter/bootstrap/components/v4/carousel_item.rb
160
162
  - app/components/twitter/bootstrap/components/v4/flash.rb
161
163
  - app/components/twitter/bootstrap/components/v4/nav.rb
162
164
  - app/components/twitter/bootstrap/components/v4/nav_item.rb
163
165
  - app/components/twitter/bootstrap/components/v4/navbar_brand.rb
166
+ - app/components/twitter/bootstrap/components/v4/portrait_card.rb
164
167
  - app/controllers/twitter/bootstrap/components/rails/application_controller.rb
165
168
  - app/form_builders/twitter/bootstrap/components/rails/v4/default_form_builder.rb
166
169
  - app/helpers/twitter/bootstrap/components/rails/v3/components_helper.rb
@@ -184,10 +187,13 @@ files:
184
187
  - app/views/twitter/bootstrap/components/v4/_card.html.haml
185
188
  - app/views/twitter/bootstrap/components/v4/_card_kitchen_sink.html.haml
186
189
  - app/views/twitter/bootstrap/components/v4/_card_list_group.html.haml
190
+ - app/views/twitter/bootstrap/components/v4/_carousel.html.haml
191
+ - app/views/twitter/bootstrap/components/v4/_carousel_item.html.haml
187
192
  - app/views/twitter/bootstrap/components/v4/_flash.html.haml
188
193
  - app/views/twitter/bootstrap/components/v4/_nav.html.haml
189
194
  - app/views/twitter/bootstrap/components/v4/_nav_item.html.haml
190
195
  - app/views/twitter/bootstrap/components/v4/_navbar_brand.html.haml
196
+ - app/views/twitter/bootstrap/components/v4/_portrait_card.html.haml
191
197
  - app/views/twitter/bootstrap/components/v4/card/_block.html.haml
192
198
  - app/views/twitter/bootstrap/components/v4/card/_blockquote.html.haml
193
199
  - app/views/twitter/bootstrap/components/v4/card/_footer.html.haml
@@ -195,6 +201,7 @@ files:
195
201
  - config/initializers/assets.rb
196
202
  - config/routes.rb
197
203
  - lib/tasks/twitter/bootstrap/components/rails_tasks.rake
204
+ - lib/twitter-bootstrap-components-rails.rb
198
205
  - lib/twitter/bootstrap/components/rails.rb
199
206
  - lib/twitter/bootstrap/components/rails/engine.rb
200
207
  - lib/twitter/bootstrap/components/rails/version.rb