myg 2.10.3 → 2.10.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +143 -143
  4. data/app/helpers/myg/theme_helper.rb +38 -34
  5. data/app/views/mozaic/myg/_button.html.erb +5 -5
  6. data/app/views/mozaic/myg/_checkbox.html.erb +27 -27
  7. data/app/views/mozaic/myg/_drawer.html.erb +2 -2
  8. data/app/views/mozaic/myg/_form-field.html.erb +64 -64
  9. data/app/views/mozaic/myg/_hint.html.erb +7 -7
  10. data/app/views/mozaic/myg/_input.html.erb +15 -15
  11. data/app/views/mozaic/myg/_label.html.erb +12 -12
  12. data/app/views/mozaic/myg/_progress.html.erb +15 -15
  13. data/app/views/mozaic/myg/_radio.html.erb +24 -24
  14. data/app/views/mozaic/myg/_slider.html.erb +22 -22
  15. data/app/views/mozaic/myg/_switch.html.erb +24 -24
  16. data/app/views/mozaic/myg/_tabs.html.erb +43 -43
  17. data/app/views/mozaic/myg/_textarea.html.erb +14 -12
  18. data/app/views/mozaic/myg/_titlebar.html.erb +12 -12
  19. data/app/views/mozaic/myg/_toast.html.erb +10 -10
  20. data/app/views/mozaic/myg/_toolbar.html.erb +2 -2
  21. data/lib/generators/myg/install_generator.rb +72 -46
  22. data/lib/generators/myg/tabs_generator.rb +30 -23
  23. data/lib/generators/myg/theme_generator.rb +9 -5
  24. data/lib/generators/templates/install/initializer.rb +35 -36
  25. data/lib/generators/templates/install/javascripts/action-button.js +9 -9
  26. data/lib/generators/templates/install/javascripts/button.js +9 -9
  27. data/lib/generators/templates/install/javascripts/card.js +9 -9
  28. data/lib/generators/templates/install/javascripts/checkbox.js +9 -9
  29. data/lib/generators/templates/install/javascripts/dialog.js +9 -9
  30. data/lib/generators/templates/install/javascripts/drawer.js +9 -9
  31. data/lib/generators/templates/install/javascripts/dropdown.js +9 -9
  32. data/lib/generators/templates/install/javascripts/footer.js +9 -9
  33. data/lib/generators/templates/install/javascripts/form-field.js +9 -9
  34. data/lib/generators/templates/install/javascripts/index.js.erb +24 -24
  35. data/lib/generators/templates/install/javascripts/menu.js +9 -9
  36. data/lib/generators/templates/install/javascripts/modal.js +9 -9
  37. data/lib/generators/templates/install/javascripts/progress.js +9 -9
  38. data/lib/generators/templates/install/javascripts/radio.js +9 -9
  39. data/lib/generators/templates/install/javascripts/select.js +9 -9
  40. data/lib/generators/templates/install/javascripts/sidebar.js +9 -9
  41. data/lib/generators/templates/install/javascripts/slide.js +9 -9
  42. data/lib/generators/templates/install/javascripts/slider.js +9 -9
  43. data/lib/generators/templates/install/javascripts/tabs.js +9 -9
  44. data/lib/generators/templates/install/javascripts/text.js +9 -9
  45. data/lib/generators/templates/install/javascripts/theme.js +9 -9
  46. data/lib/generators/templates/install/javascripts/titlebar.js +9 -9
  47. data/lib/generators/templates/install/javascripts/toast.js +9 -9
  48. data/lib/generators/templates/install/javascripts/toolbar.js +9 -9
  49. data/lib/generators/templates/install/javascripts/tooltip.js +9 -9
  50. data/lib/generators/templates/install/stylesheets/myg.scss +107 -0
  51. data/lib/generators/templates/install/stylesheets/theme/_custom.scss +30 -0
  52. data/lib/generators/templates/install/stylesheets/theme/theme.scss +3 -0
  53. data/lib/generators/templates/install/stylesheets/variables/_action-button.scss +3 -3
  54. data/lib/generators/templates/install/stylesheets/variables/_animate.scss +15 -16
  55. data/lib/generators/templates/install/stylesheets/variables/_base.scss +16 -17
  56. data/lib/generators/templates/install/stylesheets/variables/_font.scss +6 -6
  57. data/lib/generators/templates/install/stylesheets/variables/_footer.scss +3 -3
  58. data/lib/generators/templates/install/stylesheets/variables/_grid.scss +15 -15
  59. data/lib/generators/templates/install/stylesheets/variables/_layout.scss +4 -4
  60. data/lib/generators/templates/install/stylesheets/variables/_spacing.scss +1 -1
  61. data/lib/generators/templates/install/stylesheets/variables/_text.scss +48 -48
  62. data/lib/generators/templates/install/stylesheets/variables/_theme.scss +38 -7
  63. data/lib/generators/templates/tabs/_tab.html.erb +1 -1
  64. data/lib/generators/templates/tabs/_tabs.html.erb +5 -5
  65. data/lib/generators/templates/tabs/tab.html.erb +1 -1
  66. data/lib/generators/templates/theme/stylesheets/_theme.scss.erb +30 -27
  67. data/lib/myg.rb +5 -5
  68. data/lib/myg/configuration.rb +38 -39
  69. data/lib/myg/engine.rb +8 -6
  70. data/lib/myg/railtie.rb +36 -34
  71. data/lib/myg/version.rb +3 -3
  72. data/vendor/assets/javascripts/myg.js +40 -16513
  73. data/vendor/assets/stylesheets/myg.css +33154 -696
  74. metadata +46 -36
  75. data/CHANGELOG.md +0 -170
  76. data/lib/generators/templates/install/javascripts/input.js +0 -9
  77. data/lib/generators/templates/install/stylesheets/_myg.sass +0 -77
  78. data/lib/generators/templates/install/stylesheets/_variables.sass +0 -12
  79. data/lib/generators/templates/install/stylesheets/myg.sass +0 -8
  80. data/lib/generators/templates/install/stylesheets/theme/_default.scss +0 -30
  81. data/lib/generators/templates/install/stylesheets/theme/theme.sass +0 -2
@@ -1,7 +1,7 @@
1
1
  <% html = {
2
- class: ['myg-drawer mdc-drawer mdc-drawer--temporary', options[:class]].join(' ')
2
+ class: ['myg-drawer mdc-drawer mdc-drawer--temporary', options[:class]].join(' ')
3
3
  } %>
4
4
 
5
5
  <%= content_tag 'aside', options.merge(html) do %>
6
- <%= block %>
6
+ <%= block %>
7
7
  <% end %>
@@ -1,64 +1,64 @@
1
- <% wrapper_html = {
2
- class: [('myg-form-field' unless options[:file]), ('-inline-label' if options[:inline_label]), ('-floating-label' if options[:floating_label]), ('myg-form-field--file' if options[:file]), options.dig(:wrapper_html, :class)].join(' ')
3
- } %>
4
- <% if options[:floating_label] %><% input_html = {
5
- class_name: options[:class_name],
6
- attribute: options[:attribute],
7
- identifier: options[:identifier],
8
- placeholder: options[:floating_label]
9
- } %><% else %><% input_html = {
10
- class_name: options[:class_name],
11
- attribute: options[:attribute],
12
- identifier: options[:identifier]
13
- } %><% end %>
14
- <% input_defaults = {
15
- type: ('file' if options[:file])
16
- } %>
17
- <% label_html = {
18
- class_name: options[:class_name],
19
- attribute: options[:attribute],
20
- identifier: options[:identifier]
21
- } %>
22
- <% label_secondary_html = label_html.merge({
23
- class: ['myg-label--secondary', options.dig(:label_html, :class)].join(' ')
24
- }) %>
25
- <% label_wrapper_html = {
26
- class: ['myg-label__container', options.dig(:label_wrapper_html, :class)].join(' ')
27
- } %>
28
-
29
- <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
30
- <% if options[:label] %>
31
- <% unless options[:label].is_a? Array %>
32
- <%= component 'myg/label', (options[:label_html] || {}).merge(label_html) do %><%= options[:label].html_safe %><% end %>
33
- <% else %>
34
- <%= content_tag 'div', (options[:label_wrapper_html] || {}).merge(label_wrapper_html) do %>
35
- <% options[:label].each_with_index do |label, index| %>
36
- <%= component 'myg/label', (options[:label_html] || {}).merge((index == 0 ? label_html : label_secondary_html)) do %><%= label.html_safe %><% end %>
37
- <% end %>
38
- <% end %>
39
- <% end %>
40
- <% end %>
41
- <% if options[:floating_label] %>
42
- <%= content_tag 'div', class: 'myg-input__container' do %>
43
- <%= component "myg/#{options[:as]}", input_defaults.merge((options[:input_html] || {}).merge(input_html)) %>
44
- <%= component 'myg/label', (options[:label_html] || {}).merge(label_html) do %><%= options[:floating_label] %><% end %>
45
- <% end %>
46
- <% else %>
47
- <%= component "myg/#{options[:as]}", input_defaults.merge((options[:input_html] || {}).merge(input_html)) %>
48
- <% if options[:file] %><%= component 'myg/label', (options[:label_html] || {}).merge(label_html) do %><%= options[:file] %><% end %><% end %>
49
- <% end %>
50
- <% if options[:inline_label] %>
51
- <% unless options[:inline_label].is_a? Array %>
52
- <%= component 'myg/label', (options[:label_html] || {}).merge(label_html) do %><%= options[:inline_label] %><% end %>
53
- <% else %>
54
- <%= content_tag 'div', (options[:label_wrapper_html] || {}).merge(label_wrapper_html) do %>
55
- <% options[:inline_label].each_with_index do |label, index| %>
56
- <%= component 'myg/label', (options[:label_html] || {}).merge((index == 0 ? label_html : label_secondary_html)) do %><%= label.html_safe %><% end %>
57
- <% end %>
58
- <% end %>
59
- <% end %>
60
- <% end %>
61
- <% if options[:hint] %>
62
- <%= component 'myg/hint', options[:hint_html] || {} do %><%= options[:hint].html_safe %><% end %>
63
- <% end %>
64
- <% end %>
1
+ <% wrapper_html = {
2
+ class: [('myg-form-field' unless options[:file]), ('-inline-label' if options[:inline_label]), ('-floating-label' if options[:floating_label]), ('myg-form-field--file' if options[:file]), options.dig(:wrapper_html, :class)].join(' ')
3
+ } %>
4
+ <% if options[:floating_label] %><% input_html = {
5
+ class_name: options[:class_name],
6
+ attribute: options[:attribute],
7
+ identifier: options[:identifier],
8
+ placeholder: options[:floating_label]
9
+ } %><% else %><% input_html = {
10
+ class_name: options[:class_name],
11
+ attribute: options[:attribute],
12
+ identifier: options[:identifier]
13
+ } %><% end %>
14
+ <% input_defaults = {
15
+ type: ('file' if options[:file])
16
+ } %>
17
+ <% label_html = {
18
+ class_name: options[:class_name],
19
+ attribute: options[:attribute],
20
+ identifier: options[:identifier]
21
+ } %>
22
+ <% label_secondary_html = label_html.merge({
23
+ class: ['myg-label--secondary', options.dig(:label_html, :class)].join(' ')
24
+ }) %>
25
+ <% label_wrapper_html = {
26
+ class: ['myg-label__container', options.dig(:label_wrapper_html, :class)].join(' ')
27
+ } %>
28
+
29
+ <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
30
+ <% if options[:label] %>
31
+ <% unless options[:label].is_a? Array %>
32
+ <%= component 'myg/label', (options[:label_html] || {}).merge(label_html) do %><%= options[:label].html_safe %><% end %>
33
+ <% else %>
34
+ <%= content_tag 'div', (options[:label_wrapper_html] || {}).merge(label_wrapper_html) do %>
35
+ <% options[:label].each_with_index do |label, index| %>
36
+ <%= component 'myg/label', (options[:label_html] || {}).merge((index == 0 ? label_html : label_secondary_html)) do %><%= label.html_safe %><% end %>
37
+ <% end %>
38
+ <% end %>
39
+ <% end %>
40
+ <% end %>
41
+ <% if options[:floating_label] %>
42
+ <%= content_tag 'div', class: 'myg-input__container' do %>
43
+ <%= component "myg/#{options[:as]}", input_defaults.merge((options[:input_html] || {}).merge(input_html)) %>
44
+ <%= component 'myg/label', (options[:label_html] || {}).merge(label_html) do %><%= options[:floating_label] %><% end %>
45
+ <% end %>
46
+ <% else %>
47
+ <%= component "myg/#{options[:as]}", input_defaults.merge((options[:input_html] || {}).merge(input_html)) %>
48
+ <% if options[:file] %><%= component 'myg/label', (options[:label_html] || {}).merge(label_html) do %><%= options[:file] %><% end %><% end %>
49
+ <% end %>
50
+ <% if options[:inline_label] %>
51
+ <% unless options[:inline_label].is_a? Array %>
52
+ <%= component 'myg/label', (options[:label_html] || {}).merge(label_html) do %><%= options[:inline_label] %><% end %>
53
+ <% else %>
54
+ <%= content_tag 'div', (options[:label_wrapper_html] || {}).merge(label_wrapper_html) do %>
55
+ <% options[:inline_label].each_with_index do |label, index| %>
56
+ <%= component 'myg/label', (options[:label_html] || {}).merge((index == 0 ? label_html : label_secondary_html)) do %><%= label.html_safe %><% end %>
57
+ <% end %>
58
+ <% end %>
59
+ <% end %>
60
+ <% end %>
61
+ <% if options[:hint] %>
62
+ <%= component 'myg/hint', options[:hint_html] || {} do %><%= options[:hint].html_safe %><% end %>
63
+ <% end %>
64
+ <% end %>
@@ -1,7 +1,7 @@
1
- <% html = {
2
- class: ['myg-hint', options[:class]].join(' ')
3
- } %>
4
-
5
- <%= content_tag 'div', options.merge(html) do %>
6
- <%= block.html_safe %>
7
- <% end %>
1
+ <% html = {
2
+ class: ['myg-hint', options[:class]].join(' ')
3
+ } %>
4
+
5
+ <%= content_tag 'div', options.merge(html) do %>
6
+ <%= block.html_safe %>
7
+ <% end %>
@@ -1,15 +1,15 @@
1
- <% class_name = options.delete :class_name %>
2
- <% attribute = options.delete :attribute %>
3
- <% identifier = options.delete :identifier %>
4
- <% name = class_name ? "#{class_name.to_s.downcase}[#{attribute}]" : "#{attribute}" %>
5
- <% id = [class_name, identifier, attribute].map { |s| s.to_s.downcase }.join('_').tr('[', '_').tr(']', '_') %>
6
- <% html = {
7
- class: ['myg-input', options[:class]].join(' '),
8
- name: name,
9
- id: id
10
- } %>
11
- <% defaults = {
12
- type: (attribute.to_s == 'email' || attribute.to_s == 'password' ? attribute : 'text')
13
- } %>
14
-
15
- <%= tag 'input', defaults.merge(options.merge(html)) %>
1
+ <% class_name = options.delete :class_name %>
2
+ <% attribute = options.delete :attribute %>
3
+ <% identifier = options.delete :identifier %>
4
+ <% name = class_name ? "#{class_name.to_s.downcase}[#{attribute}]" : "#{attribute}" %>
5
+ <% id = [class_name, identifier, attribute].map { |s| s.to_s.downcase }.join('_').tr('[', '_').tr(']', '_') %>
6
+ <% html = {
7
+ class: ['myg-input', options[:class]].join(' '),
8
+ name: name,
9
+ id: id
10
+ } %>
11
+ <% defaults = {
12
+ type: (attribute.to_s == 'email' || attribute.to_s == 'password' ? attribute : 'text')
13
+ } %>
14
+
15
+ <%= tag 'input', defaults.merge(options.merge(html)) %>
@@ -1,12 +1,12 @@
1
- <% class_name = options.delete :class_name %>
2
- <% attribute = options.delete :attribute %>
3
- <% identifier = options.delete :identifier %>
4
- <% id = [class_name, identifier, attribute].map { |s| s.to_s.downcase }.join('_').tr('[', '_').tr(']', '_') %>
5
- <% html = {
6
- class: ['myg-label', options[:class]].join(' '),
7
- for: id
8
- } %>
9
-
10
- <%= content_tag 'label', options.merge(html) do %>
11
- <%= block.html_safe %>
12
- <% end %>
1
+ <% class_name = options.delete :class_name %>
2
+ <% attribute = options.delete :attribute %>
3
+ <% identifier = options.delete :identifier %>
4
+ <% id = [class_name, identifier, attribute].map { |s| s.to_s.downcase }.join('_').tr('[', '_').tr(']', '_') %>
5
+ <% html = {
6
+ class: ['myg-label', options[:class]].join(' '),
7
+ for: id
8
+ } %>
9
+
10
+ <%= content_tag 'label', options.merge(html) do %>
11
+ <%= block.html_safe %>
12
+ <% end %>
@@ -1,15 +1,15 @@
1
- <% html = {
2
- class: ['myg-progress mdc-linear-progress', ('mdc-linear-progress--indeterminate' if options.delete(:indeterminate)), options[:class]].join(' '),
3
- role: 'progressbar'
4
- } %>
5
-
6
- <%= content_tag 'div', options.merge(html) do %>
7
- <div class="mdc-linear-progress__buffering-dots"></div>
8
- <div class="mdc-linear-progress__buffer"></div>
9
- <div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar">
10
- <span class="mdc-linear-progress__bar-inner"></span>
11
- </div>
12
- <div class="mdc-linear-progress__bar mdc-linear-progress__secondary-bar">
13
- <span class="mdc-linear-progress__bar-inner"></span>
14
- </div>
15
- <% end %>
1
+ <% html = {
2
+ class: ['myg-progress mdc-linear-progress', ('mdc-linear-progress--indeterminate' if options.delete(:indeterminate)), options[:class]].join(' '),
3
+ role: 'progressbar'
4
+ } %>
5
+
6
+ <%= content_tag 'div', options.merge(html) do %>
7
+ <div class="mdc-linear-progress__buffering-dots"></div>
8
+ <div class="mdc-linear-progress__buffer"></div>
9
+ <div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar">
10
+ <span class="mdc-linear-progress__bar-inner"></span>
11
+ </div>
12
+ <div class="mdc-linear-progress__bar mdc-linear-progress__secondary-bar">
13
+ <span class="mdc-linear-progress__bar-inner"></span>
14
+ </div>
15
+ <% end %>
@@ -1,24 +1,24 @@
1
- <% class_name = options.delete :class_name %>
2
- <% attribute = options.delete :attribute %>
3
- <% identifier = options.delete :identifier %>
4
- <% value = options.delete :value %>
5
- <% name = class_name ? "#{class_name.to_s.downcase}[#{attribute}]" : "#{attribute}" %>
6
- <% id = [class_name, identifier, attribute, value].map { |s| s.to_s.downcase }.join('_').tr('[', '_').tr(']', '_') %>
7
- <% wrapper_html = {
8
- class: ['myg-radio mdc-radio', options.dig(:wrapper_html, :class), ('mdc-radio--disabled' if options.dig(:input_html, :disabled))].join(' ')
9
- } %>
10
- <% input_html = {
11
- type: 'radio',
12
- class: ['mdc-radio__native-control', options.dig(:input_html, :class)].join(' '),
13
- value: value,
14
- name: name,
15
- id: id
16
- } %>
17
-
18
- <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
19
- <%= tag 'input', (options[:input_html] || {}).merge(input_html) %>
20
- <div class="mdc-radio__background">
21
- <div class="mdc-radio__outer-circle"></div>
22
- <div class="mdc-radio__inner-circle"></div>
23
- </div>
24
- <% end %>
1
+ <% class_name = options.delete :class_name %>
2
+ <% attribute = options.delete :attribute %>
3
+ <% identifier = options.delete :identifier %>
4
+ <% value = options.delete :value %>
5
+ <% name = class_name ? "#{class_name.to_s.downcase}[#{attribute}]" : "#{attribute}" %>
6
+ <% id = [class_name, identifier, attribute, value].map { |s| s.to_s.downcase }.join('_').tr('[', '_').tr(']', '_') %>
7
+ <% wrapper_html = {
8
+ class: ['myg-radio mdc-radio', options.dig(:wrapper_html, :class), ('mdc-radio--disabled' if options.dig(:input_html, :disabled))].join(' ')
9
+ } %>
10
+ <% input_html = {
11
+ type: 'radio',
12
+ class: ['mdc-radio__native-control', options.dig(:input_html, :class)].join(' '),
13
+ value: value,
14
+ name: name,
15
+ id: id
16
+ } %>
17
+
18
+ <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
19
+ <%= tag 'input', (options[:input_html] || {}).merge(input_html) %>
20
+ <div class="mdc-radio__background">
21
+ <div class="mdc-radio__outer-circle"></div>
22
+ <div class="mdc-radio__inner-circle"></div>
23
+ </div>
24
+ <% end %>
@@ -1,27 +1,27 @@
1
1
  <% html = {
2
- class: ['myg-slider mdc-slider', options[:class], ('mdc-slider--discrete' if options[:discrete])].join(' '),
3
- tabindex: 0,
4
- role: 'slider',
5
- aria: {
6
- valuemin: options[:min],
7
- valuemax: options[:max],
8
- valuenow: options[:value],
9
- label: options[:label],
10
- disabled: options[:disabled]
11
- }
2
+ class: ['myg-slider mdc-slider', options[:class], ('mdc-slider--discrete' if options[:discrete])].join(' '),
3
+ tabindex: 0,
4
+ role: 'slider',
5
+ aria: {
6
+ valuemin: options[:min],
7
+ valuemax: options[:max],
8
+ valuenow: options[:value],
9
+ label: options[:label],
10
+ disabled: options[:disabled]
11
+ }
12
12
  } %>
13
13
 
14
14
  <%= content_tag 'div', options.merge(html) do %>
15
- <div class="mdc-slider__track-container">
16
- <div class="mdc-slider__track"></div>
17
- </div>
18
- <div class="mdc-slider__thumb-container">
19
- <% if options[:discrete] %><div class="mdc-slider__pin">
20
- <span class="mdc-slider__pin-value-marker"></span>
21
- </div><% end %>
22
- <svg class="mdc-slider__thumb" width="21" height="21">
23
- <circle cx="10.5" cy="10.5" r="7.875"></circle>
24
- </svg>
25
- <div class="mdc-slider__focus-ring"></div>
26
- </div>
15
+ <div class="mdc-slider__track-container">
16
+ <div class="mdc-slider__track"></div>
17
+ </div>
18
+ <div class="mdc-slider__thumb-container">
19
+ <% if options[:discrete] %><div class="mdc-slider__pin">
20
+ <span class="mdc-slider__pin-value-marker"></span>
21
+ </div><% end %>
22
+ <svg class="mdc-slider__thumb" width="21" height="21">
23
+ <circle cx="10.5" cy="10.5" r="7.875"></circle>
24
+ </svg>
25
+ <div class="mdc-slider__focus-ring"></div>
26
+ </div>
27
27
  <% end %>
@@ -1,24 +1,24 @@
1
- <% class_name = options.delete :class_name %>
2
- <% attribute = options.delete :attribute %>
3
- <% identifier = options.delete :identifier %>
4
- <% values = options.delete(:values) || [0, 1] %>
5
- <% name = class_name ? "#{class_name.to_s.downcase}[#{attribute}]" : "#{attribute}" %>
6
- <% id = [class_name, identifier, attribute].map { |s| s.to_s.downcase }.join('_').tr('[', '_').tr(']', '_') %>
7
- <% wrapper_html = {
8
- class: ['myg-switch mdc-switch', options.dig(:wrapper_html, :class)].join(' ')
9
- } %>
10
- <% input_html = {
11
- type: 'checkbox',
12
- class: ['mdc-switch__native-control', options.dig(:input_html, :class)].join(' '),
13
- name: name,
14
- id: id,
15
- value: values.last
16
- } %>
17
-
18
- <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
19
- <input value="<%= values.first %>" type="hidden" name="<%= name %>" />
20
- <%= tag 'input', (options[:input_html] || {}).merge(input_html) %>
21
- <div class="mdc-switch__background">
22
- <div class="mdc-switch__knob"></div>
23
- </div>
24
- <% end %>
1
+ <% class_name = options.delete :class_name %>
2
+ <% attribute = options.delete :attribute %>
3
+ <% identifier = options.delete :identifier %>
4
+ <% values = options.delete(:values) || [0, 1] %>
5
+ <% name = class_name ? "#{class_name.to_s.downcase}[#{attribute}]" : "#{attribute}" %>
6
+ <% id = [class_name, identifier, attribute].map { |s| s.to_s.downcase }.join('_').tr('[', '_').tr(']', '_') %>
7
+ <% wrapper_html = {
8
+ class: ['myg-switch mdc-switch', options.dig(:wrapper_html, :class)].join(' ')
9
+ } %>
10
+ <% input_html = {
11
+ type: 'checkbox',
12
+ class: ['mdc-switch__native-control', options.dig(:input_html, :class)].join(' '),
13
+ name: name,
14
+ id: id,
15
+ value: values.last
16
+ } %>
17
+
18
+ <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
19
+ <input value="<%= values.first %>" type="hidden" name="<%= name %>" />
20
+ <%= tag 'input', (options[:input_html] || {}).merge(input_html) %>
21
+ <div class="mdc-switch__background">
22
+ <div class="mdc-switch__knob"></div>
23
+ </div>
24
+ <% end %>
@@ -1,43 +1,43 @@
1
- <% nav_html = {
2
- class: ['myg-tabs mdc-tab-bar', options.dig(:nav_html, :class)].join(' ')
3
- } %>
4
- <% wrapper_html = {
5
- class: ['myg-tabs__panels', options.dig(:wrapper_html, :class)].join(' ')
6
- } %>
7
-
8
- <%= content_tag 'nav', (options[:nav_html] || {}).merge(nav_html) do %>
9
- <% options[:tabs]&.each do |tab| %>
10
- <% tab_html = {
11
- class: ['mdc-tab', options.dig(:tab_html, :class), ('mdc-tab--active' if tab[:active])].join(' '),
12
- aria: {
13
- controls: tab[:id] || tab[:name].underscore
14
- },
15
- role: 'tab'
16
- } %>
17
- <%= link_to tab[:name], tab[:href] || "##{tab[:id] || tab[:name].underscore}", (options[:tab_html] || {}).merge(tab_html) %>
18
- <% end %>
19
- <span class="mdc-tab-bar__indicator"></span>
20
- <% end %>
21
- <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
22
- <% if options[:async] %>
23
- <div class="myg-tabs__loader">
24
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24"><g transform="translate(0, 0)"><g class="nc-loop_bars-rotate-24" transform="rotate(270 12 12)"> <rect x="11" fill="#444444" width="2" height="6"></rect> <rect x="17.3639603" y="2.636039" transform="matrix(0.7071068 0.7071068 -0.7071068 0.7071068 9.3639612 -11.3345242)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="18" y="11" fill="#444444" width="6" height="2" style="opacity: 0.4;"></rect> <rect x="17.3639603" y="15.3639612" transform="matrix(-0.7071068 0.7071068 -0.7071068 -0.7071068 44.3345222 18.3639603)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="11" y="18" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="4.6360388" y="15.3639612" transform="matrix(-0.7071068 -0.7071068 0.7071068 -0.7071068 -3.363961 35.3345222)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="0" y="11" fill="#444444" width="6" height="2" style="opacity: 0.5;"></rect> <rect x="4.6360388" y="2.636039" transform="matrix(0.7071068 -0.7071068 0.7071068 0.7071068 -2.3345237 5.6360388)" fill="#444444" width="2" height="6" style="opacity: 0.8;"></rect> </g> <script>!function(){function t(t){this.element=t,this.animationId,this.start=null,this.init()}if(!window.requestAnimationFrame){var i=null;window.requestAnimationFrame=function(t,n){var e=(new Date).getTime();i||(i=e);var a=Math.max(0,16-(e-i)),o=window.setTimeout(function(){t(e+a)},a);return i=e+a,o}}t.prototype.init=function(){var t=this;this.animationId=window.requestAnimationFrame(t.triggerAnimation.bind(t))},t.prototype.reset=function(){var t=this;window.cancelAnimationFrame(t.animationId)},t.prototype.triggerAnimation=function(t){var i=this;this.start||(this.start=t);var n=t-this.start;800&gt;n||(this.start=this.start+800),this.element.setAttribute("transform","rotate("+parseInt(Math.min(n/100,8))%8*45+" 12 12)");if(document.documentElement.contains(this.element))window.requestAnimationFrame(i.triggerAnimation.bind(i))};var n=document.getElementsByClassName("nc-loop_bars-rotate-24"),e=[];if(n)for(var a=0;n.length&gt;a;a++)!function(i){e.push(new t(n[i]))}(a);document.addEventListener("visibilitychange",function(){"hidden"==document.visibilityState?e.forEach(function(t){t.reset()}):e.forEach(function(t){t.init()})})}();</script></g></svg>
25
- </div>
26
- <div class="myg-tabs__panel" id="myg-tabs__panel--success" role="tabpanel" aria-hidden="true"><%= options.dig(:success, :content) || render(partial: options.dig(:success, :partial), locals: options.dig(:success, :partial_locals)) %></div>
27
- <div class="myg-tabs__panel" id="myg-tabs__panel--error" role="tabpanel" aria-hidden="true"><%= block %></div>
28
- <% else %>
29
- <% options[:tabs]&.each do |tab| %>
30
- <% panel_html = {
31
- class: ['myg-tabs__panel', options.dig(:panel_html, :class), ('-shown' if tab[:active])].join(' '),
32
- id: tab[:id] || tab[:name].underscore,
33
- role: 'tabpanel',
34
- aria: {
35
- hidden: (tab[:active] ? false : true)
36
- }
37
- } %>
38
- <%= content_tag 'div', (options[:panel_html] || {}).merge(panel_html) do %>
39
- <%= tab[:content] || render(partial: tab[:partial], locals: tab[:partial_locals]) %>
40
- <% end %>
41
- <% end %>
42
- <% end %>
43
- <% end %>
1
+ <% nav_html = {
2
+ class: ['myg-tabs mdc-tab-bar', options.dig(:nav_html, :class)].join(' ')
3
+ } %>
4
+ <% wrapper_html = {
5
+ class: ['myg-tabs__panels', options.dig(:wrapper_html, :class)].join(' ')
6
+ } %>
7
+
8
+ <%= content_tag 'nav', (options[:nav_html] || {}).merge(nav_html) do %>
9
+ <% options[:tabs]&.each do |tab| %>
10
+ <% tab_html = {
11
+ class: ['mdc-tab', options.dig(:tab_html, :class), ('mdc-tab--active' if tab[:active])].join(' '),
12
+ aria: {
13
+ controls: tab[:id] || tab[:name].underscore
14
+ },
15
+ role: 'tab'
16
+ } %>
17
+ <%= link_to tab[:name], tab[:href] || "##{tab[:id] || tab[:name].underscore}", (options[:tab_html] || {}).merge(tab_html) %>
18
+ <% end %>
19
+ <span class="mdc-tab-bar__indicator"></span>
20
+ <% end %>
21
+ <%= content_tag 'div', (options[:wrapper_html] || {}).merge(wrapper_html) do %>
22
+ <% if options[:async] %>
23
+ <div class="myg-tabs__loader">
24
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24"><g transform="translate(0, 0)"><g class="nc-loop_bars-rotate-24" transform="rotate(270 12 12)"> <rect x="11" fill="#444444" width="2" height="6"></rect> <rect x="17.3639603" y="2.636039" transform="matrix(0.7071068 0.7071068 -0.7071068 0.7071068 9.3639612 -11.3345242)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="18" y="11" fill="#444444" width="6" height="2" style="opacity: 0.4;"></rect> <rect x="17.3639603" y="15.3639612" transform="matrix(-0.7071068 0.7071068 -0.7071068 -0.7071068 44.3345222 18.3639603)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="11" y="18" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="4.6360388" y="15.3639612" transform="matrix(-0.7071068 -0.7071068 0.7071068 -0.7071068 -3.363961 35.3345222)" fill="#444444" width="2" height="6" style="opacity: 0.4;"></rect> <rect x="0" y="11" fill="#444444" width="6" height="2" style="opacity: 0.5;"></rect> <rect x="4.6360388" y="2.636039" transform="matrix(0.7071068 -0.7071068 0.7071068 0.7071068 -2.3345237 5.6360388)" fill="#444444" width="2" height="6" style="opacity: 0.8;"></rect> </g> <script>!function(){function t(t){this.element=t,this.animationId,this.start=null,this.init()}if(!window.requestAnimationFrame){var i=null;window.requestAnimationFrame=function(t,n){var e=(new Date).getTime();i||(i=e);var a=Math.max(0,16-(e-i)),o=window.setTimeout(function(){t(e+a)},a);return i=e+a,o}}t.prototype.init=function(){var t=this;this.animationId=window.requestAnimationFrame(t.triggerAnimation.bind(t))},t.prototype.reset=function(){var t=this;window.cancelAnimationFrame(t.animationId)},t.prototype.triggerAnimation=function(t){var i=this;this.start||(this.start=t);var n=t-this.start;800&gt;n||(this.start=this.start+800),this.element.setAttribute("transform","rotate("+parseInt(Math.min(n/100,8))%8*45+" 12 12)");if(document.documentElement.contains(this.element))window.requestAnimationFrame(i.triggerAnimation.bind(i))};var n=document.getElementsByClassName("nc-loop_bars-rotate-24"),e=[];if(n)for(var a=0;n.length&gt;a;a++)!function(i){e.push(new t(n[i]))}(a);document.addEventListener("visibilitychange",function(){"hidden"==document.visibilityState?e.forEach(function(t){t.reset()}):e.forEach(function(t){t.init()})})}();</script></g></svg>
25
+ </div>
26
+ <div class="myg-tabs__panel" id="myg-tabs__panel--success" role="tabpanel" aria-hidden="true"><%= options.dig(:success, :content) || render(partial: options.dig(:success, :partial), locals: options.dig(:success, :partial_locals)) %></div>
27
+ <div class="myg-tabs__panel" id="myg-tabs__panel--error" role="tabpanel" aria-hidden="true"><%= block %></div>
28
+ <% else %>
29
+ <% options[:tabs]&.each do |tab| %>
30
+ <% panel_html = {
31
+ class: ['myg-tabs__panel', options.dig(:panel_html, :class), ('-shown' if tab[:active])].join(' '),
32
+ id: tab[:id] || tab[:name].underscore,
33
+ role: 'tabpanel',
34
+ aria: {
35
+ hidden: (tab[:active] ? false : true)
36
+ }
37
+ } %>
38
+ <%= content_tag 'div', (options[:panel_html] || {}).merge(panel_html) do %>
39
+ <%= tab[:content] || render(partial: tab[:partial], locals: tab[:partial_locals]) %>
40
+ <% end %>
41
+ <% end %>
42
+ <% end %>
43
+ <% end %>