railsstrap 4.0.0.beta2 → 4.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/railsstrap/classes/alert_box.rb +2 -0
- data/lib/railsstrap/classes/aside.rb +14 -0
- data/lib/railsstrap/classes/badge.rb +2 -0
- data/lib/railsstrap/classes/button.rb +1 -0
- data/lib/railsstrap/classes/button_group.rb +1 -0
- data/lib/railsstrap/classes/card.rb +1 -0
- data/lib/railsstrap/classes/card_group.rb +1 -0
- data/lib/railsstrap/classes/cdn.rb +2 -5
- data/lib/railsstrap/classes/icon.rb +1 -0
- data/lib/railsstrap/classes/nav.rb +5 -0
- data/lib/railsstrap/classes/navbar.rb +1 -0
- data/lib/railsstrap/helpers/aside_helper.rb +3 -2
- data/lib/railsstrap/helpers/card_helper.rb +1 -1
- data/lib/railsstrap/helpers/modal_helper.rb +3 -3
- data/lib/railsstrap/helpers/nav_helper.rb +2 -4
- data/lib/railsstrap/version.rb +1 -1
- data/lib/railsstrap/views/railsstrap/_aside.html.erb +15 -4
- data/spec/shared/aside_helper.rb +1 -16
- data/spec/shared/modal_helper.rb +2 -2
- data/vendor/assets/stylesheets/aside/aside.scss +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34a9242b16ded13eaa0e10e80737a5f289d7925cb8ad73ff5194dfdc3a602de4
|
4
|
+
data.tar.gz: ac0a0118896263220eb0edc24782e88c4aec99f6515da79c36e751dd3ca85de5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 660f0cabbe043a7946995402d8a91d312db26c743212c51f6fefcd902028c3503ff39796d93d366f43c6e107d83abd8096d28a8528c417e6fb70617afdb4e98d
|
7
|
+
data.tar.gz: db56ed92b03270128f46190eb9c9cb1860be15010950e2f91b00abe3a0611e095ee0ad7f9535c7b579903a1e2f7eda5af59492238be5617f7149fb25d610972c
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'railsstrap/classes/button'
|
2
4
|
|
3
5
|
module Railsstrap
|
@@ -14,6 +16,11 @@ module Railsstrap
|
|
14
16
|
super
|
15
17
|
end
|
16
18
|
|
19
|
+
# @return [#to_s] appends .left or .right css class to the aside
|
20
|
+
def pin_to_class
|
21
|
+
Aside.pin_to[@options[:pin_to]]
|
22
|
+
end
|
23
|
+
|
17
24
|
# @return [#to_s] the variant-related class to assign to the aside button.
|
18
25
|
def button_variant_class
|
19
26
|
Button.variants[@options.fetch(:button, {})[:variant]]
|
@@ -55,6 +62,13 @@ module Railsstrap
|
|
55
62
|
end
|
56
63
|
end
|
57
64
|
|
65
|
+
def self.pin_to
|
66
|
+
HashWithIndifferentAccess.new(:'left').tap do |klass|
|
67
|
+
klass[:left] = 'left'
|
68
|
+
klass[:right] = 'right'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
58
72
|
def extract_content_from(*args, &block)
|
59
73
|
if block_given?
|
60
74
|
super
|
@@ -61,11 +61,8 @@ module Railsstrap
|
|
61
61
|
|
62
62
|
# fetches popper js
|
63
63
|
def self.popper_js(options = {})
|
64
|
-
|
65
|
-
|
66
|
-
path: 'ajax/libs/popper.js'
|
67
|
-
}.merge(options)
|
68
|
-
cdn_asset opts
|
64
|
+
options.merge!({version: '1.13.0'})
|
65
|
+
"https://cdnjs.cloudflare.com/ajax/libs/popper.js/#{options[:version]}/umd/popper.min.js"
|
69
66
|
end
|
70
67
|
|
71
68
|
# @return the url of the library from cdnjs.com
|
@@ -18,6 +18,11 @@ module Railsstrap
|
|
18
18
|
Nav.layouts[@options[:layout]]
|
19
19
|
end
|
20
20
|
|
21
|
+
# @return [#to_s] choose between using <nav>, <ol>, or <ul> tags
|
22
|
+
def tag
|
23
|
+
@options[:tag] || :nav
|
24
|
+
end
|
25
|
+
|
21
26
|
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
22
27
|
# append to navs for each possible style.
|
23
28
|
|
@@ -2,7 +2,7 @@ require 'railsstrap/classes/aside'
|
|
2
2
|
|
3
3
|
module Railsstrap
|
4
4
|
module Helpers
|
5
|
-
# Displays a Bootstrap-styled aside. Asides inherit from
|
5
|
+
# Displays a Bootstrap-styled aside. Asides inherit from Modal, but
|
6
6
|
# are pinned to the left or right of the screen.
|
7
7
|
# @see https://github.com/toadkicker/railsstrap/wiki/Aside-Helper
|
8
8
|
# @return [String] the HTML to display a Bootstrap-styled aside.
|
@@ -39,7 +39,7 @@ module Railsstrap
|
|
39
39
|
|
40
40
|
def aside(*args, &block)
|
41
41
|
aside = Railsstrap::Aside.new self, *args, &block
|
42
|
-
aside.extract! :button, :size, :body, :title, :id
|
42
|
+
aside.extract! :button, :size, :pin_to, :body, :title, :id
|
43
43
|
|
44
44
|
aside.extract_from :button, [:variant, :size, :layout, :caption]
|
45
45
|
aside.append_class_to! :button, :btn
|
@@ -47,6 +47,7 @@ module Railsstrap
|
|
47
47
|
aside.append_class_to! :button, aside.button_size_class
|
48
48
|
aside.merge! button: {caption: aside.caption}
|
49
49
|
|
50
|
+
aside.append_class_to! :script, aside.pin_to_class
|
50
51
|
aside.append_class_to! :div, :'aside-dialog'
|
51
52
|
aside.append_class_to! :div, aside.dialog_size_class
|
52
53
|
aside.merge! div: {title: aside.title, id: aside.id}
|
@@ -28,7 +28,7 @@ module Railsstrap
|
|
28
28
|
# @param [Hash] options the options for the card (see above).
|
29
29
|
# @yieldreturn [#to_s] the content to display in the card.
|
30
30
|
# @example Display a card with HTML content.
|
31
|
-
# card title: 'Thanks' do
|
31
|
+
# card title: 'Thanks', button: {caption: icon('circle-plus', library: :fas), variant: :success} do
|
32
32
|
# content_tag :div, class: 'card-body' do
|
33
33
|
# content_tag :em, 'ou accepted the Terms of service.'
|
34
34
|
# end
|
@@ -17,7 +17,7 @@ module Railsstrap
|
|
17
17
|
# (alias `:lg`) or `:small` (alias `:sm`).
|
18
18
|
# @option options [Hash] :button the options for the toggle button.
|
19
19
|
# * :caption (#to_s) ('Modal') the caption of the toggle button.
|
20
|
-
# * :
|
20
|
+
# * :variant (#to_s) (:default) the variant alternative to apply to
|
21
21
|
# the toggle button. Can be `:danger`, `:info`, `:link`, `:primary`,
|
22
22
|
# `:success` or `:warning`.
|
23
23
|
# * :size (#to_s) the size of the toggle button. Can be `:extra_small`
|
@@ -25,7 +25,7 @@ module Railsstrap
|
|
25
25
|
# * :layout (#to_s) if set to `:block`, span the button for the full
|
26
26
|
# width of the parent.
|
27
27
|
# @example Display a simple modal toggled by a blue button.
|
28
|
-
# modal 'You clicked me!', title: 'Click me', button: {
|
28
|
+
# modal 'You clicked me!', title: 'Click me', button: {variant: :info}
|
29
29
|
# @overload modal(options = {}, &block)
|
30
30
|
# @param [Hash] options the options for the modal (see above).
|
31
31
|
# @yieldreturn [#to_s] the content to display in the modal.
|
@@ -37,7 +37,7 @@ module Railsstrap
|
|
37
37
|
# end
|
38
38
|
def modal(*args, &block)
|
39
39
|
modal = Railsstrap::Modal.new self, *args, &block
|
40
|
-
modal.extract! :button, :size, :body, :title, :id, :
|
40
|
+
modal.extract! :button, :size, :body, :title, :id, :dismissible, :dismiss
|
41
41
|
|
42
42
|
modal.extract_from :button, [:variant, :size, :layout, :caption]
|
43
43
|
modal.append_class_to! :button, :btn
|
@@ -19,16 +19,14 @@ module Railsstrap
|
|
19
19
|
# end
|
20
20
|
def nav(options = {}, &block)
|
21
21
|
nav = Railsstrap::Nav.new(self, options, &block)
|
22
|
-
nav.extract! :as, :layout
|
22
|
+
nav.extract! :as, :layout, :tag
|
23
23
|
|
24
24
|
nav.append_class! :nav
|
25
25
|
nav.append_class! nav.style_class
|
26
26
|
nav.append_class! nav.layout_class
|
27
27
|
nav.merge! role: :navigation
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
nav.render_tag :nav
|
29
|
+
nav.render_tag nav.tag
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
data/lib/railsstrap/version.rb
CHANGED
@@ -1,14 +1,25 @@
|
|
1
1
|
<button class="<%= button[:class] %>" data-toggle="modal" data-target="#<%= div[:id] %>"><%= button[:caption] %></button>
|
2
|
-
<aside class="aside
|
2
|
+
<aside class="aside" id="<%= div[:id] %>" tabindex="-1" role="dialog" aria-labelledby="label-<%= div[:id] %>" aria-hidden="true">
|
3
3
|
<div class="<%= div[:class] %>">
|
4
4
|
<div class="aside-content">
|
5
5
|
<div class="aside-header">
|
6
|
-
<
|
6
|
+
<h4 class="aside-title" id="label-<%= div[:id] %>"><%= div[:title] %></h4>
|
7
|
+
<button type="button" class="close" data-dismiss="modal" data-target="#<%= div[:id] %>">
|
7
8
|
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
|
8
9
|
</button>
|
9
|
-
<h4 class="aside-title" id="label-<%= div[:id] %>"><%= div[:title] %></h4>
|
10
10
|
</div>
|
11
11
|
<%= content %>
|
12
12
|
</div>
|
13
13
|
</div>
|
14
|
-
</aside>
|
14
|
+
</aside>
|
15
|
+
<script>
|
16
|
+
document.addEventListener("DOMContentLoaded", function () {
|
17
|
+
$("[data-target='#<%=div[:id]%>']").on('click', function (e) {
|
18
|
+
$("#<%=div[:id]%>").modal('hide');
|
19
|
+
});
|
20
|
+
|
21
|
+
$("#<%= div[:id] %>").on('show.bs.modal', function (e) {
|
22
|
+
$(e.currentTarget).addClass("<%= script[:class] %>")
|
23
|
+
});
|
24
|
+
})
|
25
|
+
</script>
|
data/spec/shared/aside_helper.rb
CHANGED
@@ -14,22 +14,7 @@ end
|
|
14
14
|
|
15
15
|
shared_examples_for 'no aside options' do
|
16
16
|
specify 'sets the role and the class to "aside", uses a generated ID and uses "Aside" as the title and caption' do
|
17
|
-
html =
|
18
|
-
<button class="btn btn-primary" data-toggle="modal" data-target="#(.+)">Aside<\/button>
|
19
|
-
<aside class="aside fade" id="\\1" tabindex="-1" role="dialog" aria-labelledby="label-\\1" aria-hidden="true">
|
20
|
-
<div class="aside-dialog">
|
21
|
-
<div class="aside-content">
|
22
|
-
<div class="aside-header">
|
23
|
-
<button type="button" class="close" data-dismiss="modal">
|
24
|
-
<span aria-hidden="true">×<\/span><span class="sr-only">Close<\/span>
|
25
|
-
<\/button>
|
26
|
-
<h4 class="aside-title" id="label-\\1">Aside<\/h4>
|
27
|
-
<\/div>
|
28
|
-
(<div class=\"aside-body\">)*content(</div>)*
|
29
|
-
<\/div>
|
30
|
-
<\/div>
|
31
|
-
<\/aside>
|
32
|
-
EOT
|
17
|
+
html = %r{(button.*data-toggle="modal".*data-target)*(aside)}
|
33
18
|
expect(:aside).to generate %r{#{html}}
|
34
19
|
end
|
35
20
|
end
|
data/spec/shared/modal_helper.rb
CHANGED
@@ -88,8 +88,8 @@ shared_examples_for 'the button: :class modal option' do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
shared_examples_for 'the :
|
92
|
-
specify 'renders the
|
91
|
+
shared_examples_for 'the :dismissible modal option' do
|
92
|
+
specify 'renders the dismissible button on the modal button' do
|
93
93
|
html = %r{.*(class="close").*(dismiss="modal")}
|
94
94
|
expect(modal: {dismissible: true, dismiss: :modal}).to generate html
|
95
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railsstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Baur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -170,28 +170,28 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
173
|
+
version: 0.15.1
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
180
|
+
version: 0.15.1
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
182
|
+
name: coveralls_reborn
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- - "
|
185
|
+
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
187
|
+
version: 0.10.0
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - "
|
192
|
+
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
194
|
+
version: 0.10.0
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: mocha
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|