nfg_ui 0.9.14 → 0.9.15

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
  SHA256:
3
- metadata.gz: d21d7e11f75aac9afef7657269e528bf821fc6a3e61a9e666f66a94dbfae1f42
4
- data.tar.gz: 012c06a94c1899513fe2ed37c18add52b43cbb1c9b645fca997644bbadda1599
3
+ metadata.gz: bcde1c0cb0c6710204e47174a49a1d9714b9eb7c4e8efc056a324931e1800461
4
+ data.tar.gz: 568118cf6b42f055b63ee32a14f6176bf2c8c0ebc61c29d4054a8c645068c3ef
5
5
  SHA512:
6
- metadata.gz: 7876d3dd5b67a3cc70c52c1700c78f296857312a9bd1e3a3e08762200e274a0de8f639cddd4070e679f1e02201228dbcec08231938a27342591a98ba61f31231
7
- data.tar.gz: 77f73e5667e4cd851c4382e05ada9716472d81be0704263e6d735073bc0e0cbd8075fe208b24369209b2993313d5dcb45c259c13c67d4ae4c9b2d51b80058427
6
+ metadata.gz: 857ab4ccaf62efa694c51439e508745aaab198efa34629cefe390324a78e8de6345ded9e078dc32a0ff8e3321d8803ead3f86f3c000a6ee490cbaef161ae381c
7
+ data.tar.gz: c7c24d5c2eb5a605c28f7488d26219eaf371f0683c6e40814de5901ced519314686b3663df758d2818ea89c3549bdb66c2b33838e9f71df4db9a8a2920c6eeb5
@@ -0,0 +1,32 @@
1
+ class NfgUi.DisableWithForLinks
2
+ constructor: (@el) ->
3
+ @buttonInnerHTML = @el.html()
4
+ @initialize()
5
+
6
+ $('body').on 'hide.bs.modal', '.modal', (e) =>
7
+ @restoreHTML()
8
+
9
+ initialize: ->
10
+ return if @el.hasClass 'disabled'
11
+ @el.addClass 'disabled'
12
+ .attr { 'data-link-disabled' : true, 'disabled' : '', 'tabindex' : '-1' }
13
+
14
+
15
+ restoreHTML: ->
16
+ return unless @el.data('link-disabled')
17
+ @el.html @buttonInnerHTML
18
+
19
+ @el.removeClass 'disabled'
20
+ .removeAttr 'data-link-disabled', 'disabled'
21
+
22
+ $ ->
23
+ elSelector = "a[data-disable-with]"
24
+
25
+ $(elSelector).click (e) =>
26
+ e.preventDefault();
27
+ inst = new NfgUi.DisableWithForLinks $(e.target)
28
+
29
+ $(document).on 'ajax:success', (e, xhr, settings) ->
30
+ return unless $(elSelector).length
31
+ $(elSelector).click (e) =>
32
+ inst = new NfgUi.DisableWithForLinks $(e.target)
@@ -95,7 +95,7 @@ $danger: $red;
95
95
  // $theme-color-interval: 8% !default;
96
96
 
97
97
  // The yiq lightness value that determines when the lightness of color changes from "dark" to "light". Acceptable values are between 0 and 255.
98
- $yiq-contrasted-threshold: 147;
98
+ $yiq-contrasted-threshold: 177;
99
99
 
100
100
  // Customize the light and dark text colors for use in our YIQ color contrast function.
101
101
  $yiq-text-dark: $gray-800;
@@ -12,6 +12,8 @@ label {
12
12
  }
13
13
  }
14
14
 
15
+ textarea.form-control { min-height: ($spacer * 6); }
16
+
15
17
  // Form groups
16
18
  //
17
19
  // Designed to help with the organization and spacing of vertical forms. For
@@ -64,7 +66,7 @@ label {
64
66
  // Sometimes rails likes to say a form control is valid even when it isn't... this helps ensure that
65
67
  // When simple_form (accurately) detects an error on the field...
66
68
  // that the invalid version wins ... avoiding false readings
67
- .is-invalid {
69
+ .is-invalid {
68
70
  &, .custom-select{ border-color: $form-feedback-invalid-color !important; }
69
71
  }
70
72
 
@@ -2,6 +2,7 @@
2
2
  // Basic Bootstrap table
3
3
  //
4
4
  .table {
5
+ margin-bottom: 0;
5
6
  thead th { border-bottom-width: $table-border-width; }
6
7
  tbody + tbody { border-top-width: $table-border-width; }
7
8
  }
@@ -12,6 +12,8 @@ label {
12
12
  }
13
13
  }
14
14
 
15
+ textarea.form-control { min-height: ($spacer * 6); }
16
+
15
17
  // Form groups
16
18
  //
17
19
  // Designed to help with the organization and spacing of vertical forms. For
@@ -1,11 +1,19 @@
1
1
  en:
2
2
  nfg_ui:
3
+ components:
4
+ elements:
5
+ table:
6
+ responsive_caption: "<< Scroll left and right to see all data >>"
3
7
  errors:
4
8
  argument_error:
9
+ components:
10
+ table:
11
+ size: 'Tables may not utilize the :lg size when setting a size option. You may set `size: :sm` or no size.'
12
+
5
13
  # required keys -- :modal, :class_name, :options, :file, :method
6
- #
14
+ #
7
15
  # Example keys:
8
- #
16
+ #
9
17
  # modal: '#example'
10
18
  # class_name: self.class.name
11
19
  # options: options
@@ -17,7 +25,7 @@ en:
17
25
 
18
26
  Raised from gem file: %{file}
19
27
  Raised from gem method: #%{method}
20
-
28
+
21
29
  To fix this error:
22
30
  Remove `tooltip: [the tooltip]` or `modal: '%{modal}'` from your component's :options hash
23
31
 
@@ -28,11 +36,11 @@ en:
28
36
  About:
29
37
  Modal and Tooltip both utilize the data-toggle HTML data attribute. When :modal is present,
30
38
  it will always overwrite the tooltip's data-toggle attribute causing a silent failure
31
- in which the tooltip does not render (though the modal HTML does).
39
+ in which the tooltip does not render (though the modal HTML does).
32
40
 
33
41
  remote: |
34
42
  ArgumentError: :modal & remote: true may not both be present in :options hash
35
-
43
+
36
44
  Raised from gem file: %{file}
37
45
  Raised from gem method: #%{method}
38
46
 
@@ -47,17 +55,17 @@ en:
47
55
  Component options: %{options}
48
56
 
49
57
  About:
50
- Components may not include both `modal: %{modal}` and `remote: true` in their options because modalable components
58
+ Components may not include both `modal: %{modal}` and `remote: true` in their options because modalable components
51
59
  that fire remote actions can result in undesirable modal activation behavior.
52
60
 
53
61
  This tends to occur when a modal is injected into the page from a remote action, is subsequently dismissed
54
62
  and then opened again from the same remote link.
55
63
 
56
- The previously dismissed modal appears (because it's still on the page, and referenced in the component's HTML)
64
+ The previously dismissed modal appears (because it's still on the page, and referenced in the component's HTML)
57
65
  and the modal is then, visibly to the user, re-animated (overwritten and re-started) by the newly injected modal from the remote ajax action.
58
-
59
66
 
60
67
 
61
-
62
68
 
63
-
69
+
70
+
71
+
@@ -4,7 +4,6 @@ module NfgUi
4
4
  module Bootstrap
5
5
  module Components
6
6
  # Bootstrap Alert Component
7
- # https://getbootstrap.com/docs/4.1/components/alerts/
8
7
  class Alert < NfgUi::Bootstrap::Components::Base
9
8
  include Bootstrap::Utilities::Dismissible
10
9
  include Bootstrap::Utilities::Headable
@@ -73,13 +73,6 @@ module NfgUi
73
73
  options[:id]
74
74
  end
75
75
 
76
- # For components that inherit bootstrap, provide a second
77
- # layer of initialization, for example:
78
- # to initialize traits on design system components
79
- # (which are not available on bootstrap)
80
- def component_initialize; end
81
- def utility_initialize; end
82
-
83
76
  def style
84
77
  options[:style]
85
78
  end
@@ -96,6 +89,13 @@ module NfgUi
96
89
  @assistive_html_attributes ||= {}
97
90
  end
98
91
 
92
+ # For components that inherit bootstrap, provide a second
93
+ # layer of initialization, for example:
94
+ # to initialize traits on design system components
95
+ # (which are not available on bootstrap)
96
+ def component_initialize; end
97
+ def utility_initialize; end
98
+
99
99
  # the base_element is used in the default render for all components
100
100
  # as the outer wrapping element. Typically, this is a div, but
101
101
  # can be overriddent as a different static element in a child class
@@ -2,12 +2,8 @@ module NfgUi
2
2
  module Bootstrap
3
3
  module Components
4
4
  # Bootstrap Collapse Component
5
- # https://getbootstrap.com/docs/4.1/components/collapse/
6
5
  class Collapse < NfgUi::Bootstrap::Components::Base
7
6
  include Bootstrap::Utilities::Collapsible
8
- # def collapsed
9
- # options.fetch(:collapsed, false)
10
- # end
11
7
 
12
8
  def navbar
13
9
  options.fetch(:navbar, false)
@@ -4,7 +4,6 @@ module NfgUi
4
4
  module Bootstrap
5
5
  module Components
6
6
  # Bootstrap Responsive Embed Component
7
- # https://getbootstrap.com/docs/4.1/utilities/embed/
8
7
  class Embed < NfgUi::Bootstrap::Components::Base
9
8
  def aspect_ratio
10
9
  options.fetch(:aspect_ratio, default_aspect_ratio) || default_aspect_ratio
@@ -57,20 +56,10 @@ module NfgUi
57
56
  '16:9'
58
57
  end
59
58
 
60
- # def default_iframe
61
- # ''
62
- # end
63
-
64
59
  def non_html_attribute_options
65
60
  super.push(:iframe, :aspect_ratio, :autoplay)
66
61
  end
67
62
 
68
- # def defaults
69
- # super.merge!(iframe: default_iframe,
70
- # aspect_ratio: default_aspect_ratio,
71
- # autoplay: default_autoplay)
72
- # end
73
-
74
63
  def default_autoplay
75
64
  false
76
65
  end
@@ -16,13 +16,6 @@ module NfgUi
16
16
  options.fetch(:height, nil)
17
17
  end
18
18
 
19
- def style
20
- [
21
- super,
22
- ("height: #{height}px;" if height)
23
- ].join(' ').squish
24
- end
25
-
26
19
  def render
27
20
  super do
28
21
  if body
@@ -33,6 +26,13 @@ module NfgUi
33
26
  end
34
27
  end
35
28
 
29
+ def style
30
+ [
31
+ super,
32
+ ("height: #{height}px;" if height)
33
+ ].join(' ').squish
34
+ end
35
+
36
36
  private
37
37
 
38
38
  def non_html_attribute_options
@@ -6,11 +6,59 @@ module NfgUi
6
6
  # Bootstrap Table Component
7
7
  # https://getbootstrap.com/docs/4.1/content/tables/
8
8
  class Table < NfgUi::Bootstrap::Components::Base
9
+ include Bootstrap::Utilities::Responsiveable
10
+ include Bootstrap::Utilities::Sizable
11
+
12
+ def size
13
+ if options.fetch(:size, nil) == :lg
14
+ raise ArgumentError.new I18n.t('nfg_ui.errors.argument_error.components.table.size')
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ def render
21
+ if responsive
22
+ content_tag(:div, class: responsive_css_class) { super }
23
+ else
24
+ super
25
+ end
26
+ end
27
+
28
+ def striped
29
+ options.fetch(:striped, false)
30
+ end
31
+
32
+ def bordered
33
+ options.fetch(:bordered, false)
34
+ end
35
+
9
36
  private
10
37
 
38
+ # Remove '.table-responsive' from the table element css classes
39
+ # since a real "responsive table" is actually a <table>
40
+ # wrapped in a div, example:
41
+ #
42
+ # <div class='table-responsive'>
43
+ # <table class='table'>
44
+ # ...
45
+ # </table>
46
+ # </div>
47
+ def css_classes
48
+ [
49
+ super,
50
+ ("#{component_css_class}-striped" if striped),
51
+ ("#{component_css_class}-bordered" if bordered)
52
+ ].join(' ')&.remove!(responsive_css_class)&.squish # see above note
53
+ end
54
+
11
55
  def base_element
12
56
  :table
13
57
  end
58
+
59
+ def non_html_attribute_options
60
+ super.push(:striped, :bordered)
61
+ end
14
62
  end
15
63
  end
16
64
  end
@@ -10,7 +10,6 @@ module NfgUi
10
10
  end
11
11
 
12
12
  def label
13
- # options.fetch(:label, nil)
14
13
  options[:label] == true ? "#{progress}%" : options[:label] || body
15
14
  end
16
15
 
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NfgUi
4
+ module Bootstrap
5
+ module Utilities
6
+ module Responsiveable
7
+ # Setting #responsive to true will supply the component with, at minimum,
8
+ # a '[component-name]-responsive' css class (e.g.: 'table-responsive')
9
+ def responsive
10
+ options.fetch(:responsive, default_responsive)
11
+ end
12
+
13
+ private
14
+
15
+ def css_classes
16
+ [
17
+ super,
18
+ (responsive_css_class if responsive)
19
+ ].join(' ').squish
20
+ end
21
+
22
+ def responsive_css_class
23
+ "#{component_css_class}-responsive"
24
+ end
25
+
26
+ def default_responsive
27
+ @default_responsive ||= false
28
+ end
29
+
30
+ def non_html_attribute_options
31
+ super.push(:responsive)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -8,6 +8,24 @@ module NfgUi
8
8
  include NfgUi::Components::Utilities::Traitable
9
9
  include NfgUi::Components::Utilities::Describable
10
10
  include NfgUi::Components::Utilities::Renderable
11
+
12
+ include NfgUi::Components::Traits::Responsive
13
+ include NfgUi::Components::Traits::Size
14
+ include NfgUi::Components::Traits::Table
15
+
16
+ def render
17
+ # We manually embed this caption as a typeface component
18
+ # as part of the design pattern.
19
+ if responsive
20
+ capture do
21
+ concat(NfgUi::Components::Foundations::Typeface.new({caption: I18n.t('nfg_ui.components.elements.table.responsive_caption').to_s, class: 'mb-1 text-right', traits: [:muted]}, view_context).render)
22
+
23
+ concat(super)
24
+ end
25
+ else
26
+ super
27
+ end
28
+ end
11
29
  end
12
30
  end
13
31
  end
@@ -7,7 +7,6 @@ module NfgUi
7
7
  class Illustration < NfgUi::Components::Foundations::Image
8
8
  include Bootstrap::Utilities::Sizable
9
9
  include NfgUi::Components::Traits::Size
10
- include NfgUi::Components::Traits::Illustration
11
10
 
12
11
  def size
13
12
  responsive ? nil : super
@@ -6,13 +6,8 @@ module NfgUi
6
6
  # Image doc coming soon
7
7
  class Image < NfgUi::Components::Base
8
8
  include Bootstrap::Utilities::Tooltipable
9
-
10
- def css_classes
11
- [
12
- super,
13
- ('img-fluid' if responsive)
14
- ].join(' ').squish
15
- end
9
+ include Bootstrap::Utilities::Responsiveable
10
+ include NfgUi::Components::Traits::Responsive
16
11
 
17
12
  # Prefer image, image is used
18
13
  # on other components that pull in
@@ -25,13 +20,6 @@ module NfgUi
25
20
  image_tag(view_context.image_path(image_location), **html_options)
26
21
  end
27
22
 
28
- # Flag if the image should utilize responsive settings or not.
29
- # This typically does thigns like
30
- # apply specific css classes (e.g.: 'img-fluid') to the rendered component
31
- def responsive
32
- options.fetch(:responsive, default_responsive)
33
- end
34
-
35
23
  # Allow :src to come through
36
24
  # since :src is a native and
37
25
  # viable to way source a image path / url
@@ -41,6 +29,10 @@ module NfgUi
41
29
 
42
30
  private
43
31
 
32
+ def responsive_css_class
33
+ 'img-fluid'
34
+ end
35
+
44
36
  def component_css_class
45
37
  ''
46
38
  end
@@ -64,7 +56,7 @@ module NfgUi
64
56
  #
65
57
  # the image_tag helper method automatically turns the first argument into the `src` attribute.
66
58
  def non_html_attribute_options
67
- super.push(:image, :src, :responsive)
59
+ super.push(:image, :src)
68
60
  end
69
61
  end
70
62
  end
@@ -1,8 +1,7 @@
1
1
  module NfgUi
2
2
  module Components
3
3
  module Traits
4
- # Shared Size traits
5
- module Illustration
4
+ module Responsive
6
5
  TRAITS = %i[responsive].freeze
7
6
 
8
7
  def responsive_trait
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NfgUi
4
+ module Components
5
+ module Traits
6
+ module Table
7
+ TRAITS = %i[striped bordered].freeze
8
+
9
+ def striped_trait
10
+ options[:striped] = true
11
+ end
12
+
13
+ def bordered_trait
14
+ options[:bordered] = true
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -17,7 +17,6 @@ module NfgUi
17
17
  Dismiss
18
18
  DropdownToggle
19
19
  Icon
20
- Illustration
21
20
  ListGroup
22
21
  Muted
23
22
  Nav
@@ -27,9 +26,11 @@ module NfgUi
27
26
  Pill
28
27
  ProgressBar
29
28
  Remote
29
+ Responsive
30
30
  Size
31
31
  Step
32
32
  SlatItem
33
+ Table
33
34
  Theme
34
35
  Typeface
35
36
  Vertical].freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NfgUi
4
- VERSION = '0.9.14'
4
+ VERSION = '0.9.15'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nfg_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.14
4
+ version: 0.9.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Roehm
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-12 00:00:00.000000000 Z
12
+ date: 2019-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bootstrap
@@ -343,6 +343,7 @@ files:
343
343
  - app/assets/images/nfg_ui/email/nfg-logo.png
344
344
  - app/assets/javascripts/nfg_ui/application.coffee
345
345
  - app/assets/javascripts/nfg_ui/collapsible_toggle.coffee
346
+ - app/assets/javascripts/nfg_ui/disable_with_for_links.coffee
346
347
  - app/assets/javascripts/nfg_ui/prevent_clickable_disabled_element.coffee
347
348
  - app/assets/javascripts/nfg_ui/vendor/select2.coffee
348
349
  - app/assets/javascripts/nfg_ui/vendor/tooltips.coffee
@@ -562,6 +563,7 @@ files:
562
563
  - lib/nfg_ui/bootstrap/utilities/modalable.rb
563
564
  - lib/nfg_ui/bootstrap/utilities/progressable.rb
564
565
  - lib/nfg_ui/bootstrap/utilities/remotable.rb
566
+ - lib/nfg_ui/bootstrap/utilities/responsiveable.rb
565
567
  - lib/nfg_ui/bootstrap/utilities/sizable.rb
566
568
  - lib/nfg_ui/bootstrap/utilities/themeable.rb
567
569
  - lib/nfg_ui/bootstrap/utilities/tooltipable.rb
@@ -670,7 +672,6 @@ files:
670
672
  - lib/nfg_ui/components/traits/dismiss.rb
671
673
  - lib/nfg_ui/components/traits/dropdown_toggle.rb
672
674
  - lib/nfg_ui/components/traits/icon.rb
673
- - lib/nfg_ui/components/traits/illustration.rb
674
675
  - lib/nfg_ui/components/traits/list_group.rb
675
676
  - lib/nfg_ui/components/traits/muted.rb
676
677
  - lib/nfg_ui/components/traits/nav.rb
@@ -680,9 +681,11 @@ files:
680
681
  - lib/nfg_ui/components/traits/pill.rb
681
682
  - lib/nfg_ui/components/traits/progress_bar.rb
682
683
  - lib/nfg_ui/components/traits/remote.rb
684
+ - lib/nfg_ui/components/traits/responsive.rb
683
685
  - lib/nfg_ui/components/traits/size.rb
684
686
  - lib/nfg_ui/components/traits/slat_item.rb
685
687
  - lib/nfg_ui/components/traits/step.rb
688
+ - lib/nfg_ui/components/traits/table.rb
686
689
  - lib/nfg_ui/components/traits/theme.rb
687
690
  - lib/nfg_ui/components/traits/typeface.rb
688
691
  - lib/nfg_ui/components/traits/vertical.rb