beyond_canvas 0.6.4.pre → 0.7.0.pre

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
  SHA256:
3
- metadata.gz: 69b9311ccfa66b8ff9b358476c40005dae8084848abb4408d1deecfacfd485eb
4
- data.tar.gz: 2a5ac1f10b54e41f04f997e88b58f37ef52c85a0d63507d0b1a06f053b322ffd
3
+ metadata.gz: 57ce3075063f9f943f9b4a4fa47580696046a4d23563e70a3fc1a40c578592f9
4
+ data.tar.gz: b7a63f7471c95a67c8c436a6291826878d79acf913faeb13539f3604c1341820
5
5
  SHA512:
6
- metadata.gz: a214821f18cfd0e7ef9be448f6a7a9b44f0bae9b5e4da1d9154c10f989da2005c7f40ab4b2e7002058b4595a59bf7f8df408ff25bb346a23a1bfa3eebe3b2aa6
7
- data.tar.gz: 45a919581e32011b4a64838237601ec2004d327776d861b264551d35442ff0e51202abe9ae1ecc441d7aaad23501a392dda6eefedf54bbb0e06ac0df6dd1d245
6
+ metadata.gz: cb70bf7931a673e05d1040923d9c4fdfaffd1c50a6a9f03e3b5b9aca0937c488d03923b6971a9c69d871ab0f6291493dec782399b6097d69e24cbc12aad841c8
7
+ data.tar.gz: 93f84bcd9bc6027fe4e25ea77213ae8a818d6edb0c4f0f683d71da5ff9fb7fbd14768aaa80edf31197a04a01661ce58de76561afd34f0a03d6269651163408fb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ### v0.7.0.pre
2
+
3
+ * deprecations
4
+ * Use custom `stylesheet_link_tag` and `javascript_include_tag` on head
5
+
6
+ * enhancements
7
+ * Make `lib/generators/templates/beyond_canvas_form_utils.rb` rubocop compatible
8
+
9
+ * features
10
+ * Add loading buttons
11
+
1
12
  ### v0.6.4.pre
2
13
 
3
14
  * bug-fixes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beyond_canvas (0.6.4.pre)
4
+ beyond_canvas (0.7.0.pre)
5
5
  bourbon (~> 5.1)
6
6
  inline_svg (~> 1.5)
7
7
  sassc-rails (~> 2.1)
@@ -34,13 +34,13 @@ GEM
34
34
  thor (~> 0.19)
35
35
  builder (3.2.4)
36
36
  colorize (0.8.1)
37
- concurrent-ruby (1.1.5)
38
- crass (1.0.5)
37
+ concurrent-ruby (1.1.6)
38
+ crass (1.0.6)
39
39
  erubi (1.9.0)
40
- ffi (1.11.3)
41
- i18n (1.7.1)
40
+ ffi (1.12.2)
41
+ i18n (1.8.2)
42
42
  concurrent-ruby (~> 1.0)
43
- inline_svg (1.6.0)
43
+ inline_svg (1.7.0)
44
44
  activesupport (>= 3.0)
45
45
  nokogiri (>= 1.6)
46
46
  loofah (2.4.0)
@@ -48,10 +48,10 @@ GEM
48
48
  nokogiri (>= 1.5.9)
49
49
  method_source (0.9.2)
50
50
  mini_portile2 (2.4.0)
51
- minitest (5.13.0)
52
- nokogiri (1.10.7)
51
+ minitest (5.14.0)
52
+ nokogiri (1.10.8)
53
53
  mini_portile2 (~> 2.4.0)
54
- rack (2.0.8)
54
+ rack (2.2.2)
55
55
  rack-test (1.1.0)
56
56
  rack (>= 1.0, < 3)
57
57
  rails-dom-testing (2.0.3)
@@ -1 +1,2 @@
1
1
  //= require flash
2
+ //= require buttons
@@ -0,0 +1,65 @@
1
+ $(document).ready(function() {
2
+ ('use strict');
3
+
4
+ $('[class^="button"]').each(function() {
5
+ var button = $(this);
6
+
7
+ // Add width attribute and save old width
8
+ button.width(button.width());
9
+ button.data('oldWidth', button.width());
10
+
11
+ // Add the spinner
12
+ button.prepend(`
13
+ <div class="spinner">
14
+ <div class="bounce1"></div>
15
+ <div class="bounce2"></div>
16
+ <div class="bounce3"></div>
17
+ </div>`
18
+ );
19
+
20
+ // Bind ajax:success and ajax:error to the form the button belongs to
21
+ button
22
+ .closest('form')
23
+ .on('ajax:success', function() {
24
+ hideSpinner(button);
25
+ enableActionElements();
26
+ })
27
+ .on('ajax:error', function() {
28
+ hideSpinner(button);
29
+ enableActionElements();
30
+ });
31
+ });
32
+
33
+ // Bind click event to buttons
34
+ $('[class^="button"]').click(function() {
35
+ disableActionElements();
36
+ showSpinner($(this));
37
+ });
38
+ });
39
+
40
+ function showSpinner(button) {
41
+ // Adjust the width of the button
42
+ button.width(button.width() + $('.spinner').outerWidth(true));
43
+ // Show the spinner
44
+ setTimeout(function() {
45
+ button.find('.spinner').css('display', 'flex');
46
+ }, 125);
47
+ }
48
+
49
+ function hideSpinner(button) {
50
+ // Hide the spinner
51
+ button.find('.spinner').hide();
52
+ // Adjust the width of the button
53
+ button.width(button.data('oldWidth'));
54
+ }
55
+
56
+ function disableActionElements() {
57
+ $('a, input[type="submit"], input[type="button"], input[type="reset"], button').each(function() {
58
+ $(this).addClass('actions--disabled');
59
+ });
60
+ }
61
+ function enableActionElements() {
62
+ $('a, input[type="submit"], input[type="button"], input[type="reset"], button').each(function() {
63
+ $(this).removeClass("actions--disabled");
64
+ });
65
+ }
@@ -1,5 +1,5 @@
1
- document.addEventListener('turbolinks:load', function() {
2
- 'use strict'
1
+ $(document).ready(function() {
2
+ ('use strict');
3
3
 
4
4
  $('.flash').each(function() {
5
5
  $(this).css('right', -$(this).width() + 'px');
@@ -14,8 +14,11 @@ document.addEventListener('turbolinks:load', function() {
14
14
  });
15
15
 
16
16
  function closeAlert() {
17
- $('.flash').removeClass('flash--shown').delay(700).queue(function() {
18
- $(this).remove();
19
- });
17
+ $('.flash')
18
+ .removeClass('flash--shown')
19
+ .delay(700)
20
+ .queue(function() {
21
+ $(this).remove();
22
+ });
20
23
  }
21
24
  });
@@ -6,6 +6,7 @@
6
6
 
7
7
  @import 'utilities/mixins'
8
8
 
9
+ @import 'components/actions'
9
10
  @import 'components/buttons'
10
11
  @import 'components/cards'
11
12
  @import 'components/comments'
@@ -18,3 +19,4 @@
18
19
  @import 'components/notices'
19
20
  @import 'components/relative'
20
21
  @import 'components/tables'
22
+ @import 'components/spinner'
@@ -0,0 +1,5 @@
1
+ .actions
2
+
3
+ &--disabled
4
+ cursor: not-allowed
5
+ pointer-events: none
@@ -2,11 +2,14 @@
2
2
  +padding($button-padding)
3
3
  @if $button-box-shadow != true
4
4
  padding-top: 7px
5
+ align-items: center
5
6
  border-radius: $button-border-radius
6
7
  border-width: 1px
7
8
  border-style: solid
8
9
  cursor: pointer
10
+ display: flex
9
11
  font-weight: $button-font-weight
12
+ justify-content: flex-end
10
13
  line-height: 1
11
14
  outline: none
12
15
  transition: $main-transition
@@ -15,6 +18,12 @@
15
18
  +background-color-darken($background, 10%)
16
19
  color: $color
17
20
 
21
+ .spinner
22
+ display: none
23
+
24
+ > div
25
+ background-color: $color
26
+
18
27
  &:hover
19
28
  border-color: darken($background, 10%)
20
29
 
@@ -23,6 +32,12 @@
23
32
  border-color: $background
24
33
  color: $background
25
34
 
35
+ .spinner
36
+ display: none
37
+
38
+ > div
39
+ background-color: $background
40
+
26
41
  &:hover
27
42
  background-color: lighten($background, 40%)
28
43
 
@@ -0,0 +1,38 @@
1
+ .spinner
2
+ display: flex
3
+ margin-right: 12px
4
+ width: 24px
5
+ text-align: center
6
+
7
+ > div
8
+ margin: 0 !important
9
+ width: 8px
10
+ height: 8px
11
+ border-radius: 100%
12
+ display: inline-block
13
+ -webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both
14
+ animation: sk-bouncedelay 1.4s infinite ease-in-out both
15
+
16
+ .bounce1
17
+ -webkit-animation-delay: -0.32s
18
+ animation-delay: -0.32s
19
+
20
+ .bounce2
21
+ -webkit-animation-delay: -0.16s
22
+ animation-delay: -0.16s
23
+
24
+ @-webkit-keyframes sk-bouncedelay
25
+ 0%, 80%, 100%
26
+ -webkit-transform: scale(0)
27
+
28
+ 40%
29
+ -webkit-transform: scale(1)
30
+
31
+ @keyframes sk-bouncedelay
32
+ 0%, 80%, 100%
33
+ -webkit-transform: scale(0)
34
+ transform: scale(0)
35
+
36
+ 40%
37
+ -webkit-transform: scale(1)
38
+ transform: scale(1)
@@ -3,10 +3,10 @@ head
3
3
  meta content='width=device-width, initial-scale=1.0' name='viewport' /
4
4
  link crossorigin="anonymous" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" rel="stylesheet" /
5
5
  script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"
6
- - if defined? Turbolinks
7
- = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
8
- = javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
9
- - else
10
- = stylesheet_link_tag 'application'
11
- = javascript_include_tag 'application'
6
+
7
+ - stylesheet_link_tag = BeyondCanvas.configuration.stylesheet_link_tag
8
+ - javascript_include_tag = BeyondCanvas.configuration.javascript_include_tag
9
+ = stylesheet_link_tag(stylesheet_link_tag) unless stylesheet_link_tag.nil?
10
+ = javascript_include_tag(javascript_include_tag) unless javascript_include_tag.nil?
11
+
12
12
  = render 'beyond_canvas/custom/public_head'
data/lib/beyond_canvas.rb CHANGED
@@ -26,10 +26,12 @@ module BeyondCanvas
26
26
  end
27
27
 
28
28
  class Configuration
29
- attr_accessor :public_logo
29
+ attr_accessor :public_logo, :stylesheet_link_tag, :javascript_include_tag
30
30
 
31
31
  def initialize
32
32
  @public_logo = nil
33
+ @stylesheet_link_tag = nil
34
+ @javascript_include_tag = nil
33
35
  end
34
36
  end
35
37
  end
@@ -1,3 +1,3 @@
1
1
  module BeyondCanvas
2
- VERSION = "0.6.4.pre".freeze
2
+ VERSION = "0.7.0.pre".freeze
3
3
  end
@@ -2,4 +2,7 @@
2
2
 
3
3
  BeyondCanvas.setup do |config|
4
4
  # config.public_logo = "logo.png"
5
+
6
+ # config.stylesheet_link_tag = 'application'
7
+ # config.javascript_include_tag = 'application'
5
8
  end
@@ -1,19 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
3
+ # Adds form__error class to the inputs after sending a form when errors
4
+ ActionView::Base.field_error_proc = proc do |html_tag, _instance|
5
+ include ActionView::Helpers::SanitizeHelper
6
+
4
7
  if html_tag =~ /<(input|textarea|select)/
5
- error_class = "input__error".freeze
8
+ error_class = 'form__error'
6
9
 
7
10
  doc = Nokogiri::XML(html_tag)
8
11
  doc.children.each do |field|
9
- unless field["type"] == "hidden"
10
- unless field["class"] =~ /\berror\b/
11
- field["class"] = "#{field['class']} #{error_class}".strip
12
- end
13
- end
12
+ next if field['type'] == 'hidden'
13
+
14
+ next if field['class'] =~ /\berror\b/
15
+
16
+ field['class'] = "#{field['class']} #{error_class}".strip
14
17
  end
15
18
 
16
- doc.to_html.html_safe
19
+ sanitize doc.to_html
17
20
  else
18
21
  html_tag
19
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond_canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4.pre
4
+ version: 0.7.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unai Abrisketa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2020-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -98,8 +98,10 @@ files:
98
98
  - README.md
99
99
  - Rakefile
100
100
  - app/assets/javascripts/beyond_canvas.js
101
+ - app/assets/javascripts/buttons.js
101
102
  - app/assets/javascripts/flash.js
102
103
  - app/assets/stylesheets/_beyond_canvas.sass
104
+ - app/assets/stylesheets/components/_actions.sass
103
105
  - app/assets/stylesheets/components/_buttons.sass
104
106
  - app/assets/stylesheets/components/_cards.sass
105
107
  - app/assets/stylesheets/components/_comments.sass
@@ -112,6 +114,7 @@ files:
112
114
  - app/assets/stylesheets/components/_notices.sass
113
115
  - app/assets/stylesheets/components/_relative.sass
114
116
  - app/assets/stylesheets/components/_tables.sass
117
+ - app/assets/stylesheets/components/spinner.sass
115
118
  - app/assets/stylesheets/settings/_reset_css.sass
116
119
  - app/assets/stylesheets/settings/_typography.sass
117
120
  - app/assets/stylesheets/settings/_variables.sass