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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0708575b18bab6b332bdc52351033190360a2ae1a60b6bf905617c0cd79fcf96'
4
- data.tar.gz: d384c57c3cb1ed97c2101acb3149ac3455a8cb8de9a91ce901ee88705c32eeb7
3
+ metadata.gz: c034f5074f1f9f8e7097d74b616af7c0ea299e30d40d6665ea6658df5a1a8fed
4
+ data.tar.gz: ee7625b88d7775a0ef361edcaddaeeac8330eac841fa119718ffa060ed3ac865
5
5
  SHA512:
6
- metadata.gz: 0f2a9ab1a3b3f6aa14ce235a2c61c327e792096d4fc3c3c0fee0deb91677df917c0932543e6ec39cde8d7416fc19bb90df2316951f565ba1263fc531c6aa8a88
7
- data.tar.gz: a5c99125357b3195c7e1162580f7a80731c5dbecf698c7d214891a17aef38b2b5d63710813288bb0e3f9bfddc8ad3bab2aaa6ddfcbfb86f106488a573a7eb7b7
6
+ metadata.gz: ac101a115bc5aa703294fc882db1ae620a8855b98cb45418cdc985140daf8e03d9a5a1887cd33c78267e5ebc852052c4a0bb940673ed169478d4e548a01549d6
7
+ data.tar.gz: 51392d7d38c8a2a4ab66d379d0d3fe7c01133af3181f7e68eb95cb3f0cc99ff3813a8a0a38a228cbb971c5859749f51d4df3567d8f6c8427c83745383d1b932d
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Jonas Hübotter
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Jonas Hübotter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,143 +1,143 @@
1
- # Myg on Rails
2
-
3
- [![Gem Version](https://badge.fury.io/rb/myg.svg)](https://badge.fury.io/rb/myg) <img src="https://travis-ci.org/jonhue/myg-rails.svg?branch=master" />
4
-
5
- ---
6
-
7
- ## Table of Contents
8
-
9
- * [Installation](#installation)
10
- * [Philosophy](#philosophy)
11
- * [Usage](#usage)
12
- * [Mozaic components](#mozaic-components)
13
- * [To Do](#to-do)
14
- * [Contributing](#contributing)
15
- * [Contributors](#contributors)
16
- * [Semantic versioning](#semantic-versioning)
17
- * [License](#license)
18
-
19
- ---
20
-
21
- ## Installation
22
-
23
- Myg on Rails works with Rails 5 onwards. You can add it to your `Gemfile` with:
24
-
25
- ```ruby
26
- gem 'myg-rails'
27
- ```
28
-
29
- And then execute:
30
-
31
- $ bundle
32
-
33
- Or install it yourself as:
34
-
35
- $ gem install myg
36
-
37
- If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
38
-
39
- ```ruby
40
- gem 'myg', github: 'jonhue/myg-rails'
41
- ```
42
-
43
- Now run the generator
44
-
45
- $ rails g myg:install
46
-
47
- Then add [Myg](https://github.com/jonhue/myg) to your asset pipeline:
48
-
49
- ```js
50
- //= require myg
51
- ```
52
- ```css
53
- /*
54
- *= require myg
55
- */
56
- ```
57
-
58
- **Note:** If you are using a package manager like Yarn, make sure to fetch the latest versions instead.
59
-
60
- ---
61
-
62
- ## Philosophy
63
-
64
- ...
65
-
66
- ---
67
-
68
- ## Usage
69
-
70
- ...
71
-
72
- ### Mozaic components
73
-
74
- These are the components currently supported by Myg on Rails:
75
-
76
- * [`button`](components/myg/button.md)
77
- * [`checkbox`](components/myg/checkbox.md)
78
- * [`drawer`](components/myg/drawer.md)
79
- * [`form-field`](components/myg/form-field.md)
80
- * [`hint`](components/myg/hint.md)
81
- * [`input`](components/myg/input.md)
82
- * [`label`](components/myg/label.md)
83
- * [`progress`](components/myg/progress.md)
84
- * [`radio`](components/myg/radio.md)
85
- * [`slider`](components/myg/slider.md)
86
- * [`switch`](components/myg/switch.md)
87
- * [`tabs`](components/myg/tabs.md)
88
- * [`textarea`](components/myg/textarea.md)
89
- * [`titlebar`](components/myg/titlebar.md)
90
- * [`toast`](components/myg/toast.md)
91
- * [`toolbar`](components/myg/toolbar.md)
92
-
93
- You feel a component is missing? Create an issue to make us aware, or implement it yourself. Pull requests are welcome.
94
-
95
- ---
96
-
97
- ## To Do
98
-
99
- [Here](https://github.com/jonhue/myg-rails/projects/1) is the full list of current projects.
100
-
101
- To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/myg-rails/issues/new).
102
-
103
- ---
104
-
105
- ## Contributing
106
-
107
- We hope that you will consider contributing to Myg on Rails. Please read this short overview for some information about how to get started:
108
-
109
- [Learn more about contributing to this repository](CONTRIBUTING.md), [Code of Conduct](CODE_OF_CONDUCT.md)
110
-
111
- ### Contributors
112
-
113
- Give the people some :heart: who are working on this project. See them all at:
114
-
115
- https://github.com/jonhue/myg-rails/graphs/contributors
116
-
117
- ### Semantic Versioning
118
-
119
- Myg on Rails follows Semantic Versioning 2.0 as defined at http://semver.org.
120
-
121
- ## License
122
-
123
- MIT License
124
-
125
- Copyright (c) 2018 Jonas Hübotter
126
-
127
- Permission is hereby granted, free of charge, to any person obtaining a copy
128
- of this software and associated documentation files (the "Software"), to deal
129
- in the Software without restriction, including without limitation the rights
130
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
131
- copies of the Software, and to permit persons to whom the Software is
132
- furnished to do so, subject to the following conditions:
133
-
134
- The above copyright notice and this permission notice shall be included in all
135
- copies or substantial portions of the Software.
136
-
137
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
138
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
139
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
140
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
141
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
142
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
143
- SOFTWARE.
1
+ # Myg on Rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/myg.svg)](https://badge.fury.io/rb/myg) <img src="https://travis-ci.org/jonhue/myg-rails.svg?branch=master" />
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ * [Installation](#installation)
10
+ * [Philosophy](#philosophy)
11
+ * [Usage](#usage)
12
+ * [Mozaic components](#mozaic-components)
13
+ * [To Do](#to-do)
14
+ * [Contributing](#contributing)
15
+ * [Contributors](#contributors)
16
+ * [Semantic versioning](#semantic-versioning)
17
+ * [License](#license)
18
+
19
+ ---
20
+
21
+ ## Installation
22
+
23
+ Myg on Rails works with Rails 5 onwards. You can add it to your `Gemfile` with:
24
+
25
+ ```ruby
26
+ gem 'myg-rails'
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install myg
36
+
37
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
38
+
39
+ ```ruby
40
+ gem 'myg', github: 'jonhue/myg-rails'
41
+ ```
42
+
43
+ Now run the generator
44
+
45
+ $ rails g myg:install
46
+
47
+ Then add [Myg](https://github.com/jonhue/myg) to your asset pipeline:
48
+
49
+ ```js
50
+ //= require myg
51
+ ```
52
+ ```css
53
+ /*
54
+ *= require myg
55
+ */
56
+ ```
57
+
58
+ **Note:** If you are using a package manager like Yarn, make sure to fetch the latest versions instead.
59
+
60
+ ---
61
+
62
+ ## Philosophy
63
+
64
+ ...
65
+
66
+ ---
67
+
68
+ ## Usage
69
+
70
+ ...
71
+
72
+ ### Mozaic components
73
+
74
+ These are the components currently supported by Myg on Rails:
75
+
76
+ * [`button`](components/myg/button.md)
77
+ * [`checkbox`](components/myg/checkbox.md)
78
+ * [`drawer`](components/myg/drawer.md)
79
+ * [`form-field`](components/myg/form-field.md)
80
+ * [`hint`](components/myg/hint.md)
81
+ * [`input`](components/myg/input.md)
82
+ * [`label`](components/myg/label.md)
83
+ * [`progress`](components/myg/progress.md)
84
+ * [`radio`](components/myg/radio.md)
85
+ * [`slider`](components/myg/slider.md)
86
+ * [`switch`](components/myg/switch.md)
87
+ * [`tabs`](components/myg/tabs.md)
88
+ * [`textarea`](components/myg/textarea.md)
89
+ * [`titlebar`](components/myg/titlebar.md)
90
+ * [`toast`](components/myg/toast.md)
91
+ * [`toolbar`](components/myg/toolbar.md)
92
+
93
+ You feel a component is missing? Create an issue to make us aware, or implement it yourself. Pull requests are welcome.
94
+
95
+ ---
96
+
97
+ ## To Do
98
+
99
+ [Here](https://github.com/jonhue/myg-rails/projects/1) is the full list of current projects.
100
+
101
+ To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/myg-rails/issues/new).
102
+
103
+ ---
104
+
105
+ ## Contributing
106
+
107
+ We hope that you will consider contributing to Myg on Rails. Please read this short overview for some information about how to get started:
108
+
109
+ [Learn more about contributing to this repository](CONTRIBUTING.md), [Code of Conduct](CODE_OF_CONDUCT.md)
110
+
111
+ ### Contributors
112
+
113
+ Give the people some :heart: who are working on this project. See them all at:
114
+
115
+ https://github.com/jonhue/myg-rails/graphs/contributors
116
+
117
+ ### Semantic Versioning
118
+
119
+ Myg on Rails follows Semantic Versioning 2.0 as defined at http://semver.org.
120
+
121
+ ## License
122
+
123
+ MIT License
124
+
125
+ Copyright (c) 2018 Jonas Hübotter
126
+
127
+ Permission is hereby granted, free of charge, to any person obtaining a copy
128
+ of this software and associated documentation files (the "Software"), to deal
129
+ in the Software without restriction, including without limitation the rights
130
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
131
+ copies of the Software, and to permit persons to whom the Software is
132
+ furnished to do so, subject to the following conditions:
133
+
134
+ The above copyright notice and this permission notice shall be included in all
135
+ copies or substantial portions of the Software.
136
+
137
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
138
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
139
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
140
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
141
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
142
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
143
+ SOFTWARE.
@@ -1,34 +1,38 @@
1
- module Myg
2
- module ThemeHelper
3
-
4
- def theme theme = nil
5
- theme ||= cookies[:theme] || Myg.configuration.theme
6
- if Myg.configuration.auto && theme == 'auto'
7
- if Time.now < Time.parse(Myg.configuration.theme_day_time) || Time.now > Time.parse(Myg.configuration.theme_night_time)
8
- theme = Myg.configuration.theme_day
9
- else
10
- theme = Myg.configuration.theme_night
11
- end
12
- end
13
- theme
14
- end
15
-
16
- def set_theme theme
17
- cookies[:theme] = theme
18
- theme
19
- end
20
-
21
- def theme_class
22
- begin
23
- "myg-theme--#{current_theme}"
24
- rescue NoMethodError
25
- "myg-theme--#{theme}"
26
- end
27
- end
28
-
29
- def theme_available? theme
30
- Myg.configuration.themes.include? theme
31
- end
32
-
33
- end
34
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Myg
4
+ module ThemeHelper
5
+ def theme(theme: nil)
6
+ theme ||= cookies[:theme] || Myg.configuration.theme
7
+ theme = automatic_theme if Myg.configuration.auto && theme == 'auto'
8
+ save_theme(theme: theme)
9
+ end
10
+
11
+ def save_theme(theme:)
12
+ cookies[:theme] = theme
13
+ end
14
+
15
+ def theme_class
16
+ "myg-theme--#{current_theme}"
17
+ rescue NoMethodError
18
+ "myg-theme--#{theme}"
19
+ end
20
+
21
+ def theme_available?(theme:)
22
+ Myg.configuration.themes.include?(theme)
23
+ end
24
+
25
+ private
26
+
27
+ def automatic_theme
28
+ return Myg.configuration.theme_day if day?
29
+
30
+ Myg.configuration.theme_night
31
+ end
32
+
33
+ def day?
34
+ Time.zone.now < Time.zone.parse(Myg.configuration.theme_day_time) ||
35
+ Time.zone.now > Time.zone.parse(Myg.configuration.theme_night_time)
36
+ end
37
+ end
38
+ end
@@ -1,13 +1,13 @@
1
1
  <% href = options.delete :href %>
2
2
  <% value = options.delete :value %>
3
3
  <% link_html = {
4
- class: ['myg-button', options[:class]].join(' ')
4
+ class: ['myg-button', options[:class]].join(' ')
5
5
  } %>
6
6
  <% input_html = {
7
- class: ['myg-button', options[:class]].join(' '),
8
- type: 'submit',
9
- name: 'commit',
10
- value: value
7
+ class: ['myg-button', options[:class]].join(' '),
8
+ type: 'submit',
9
+ name: 'commit',
10
+ value: value
11
11
  } %>
12
12
 
13
13
  <% if href %><%= link_to value, href, options.merge(link_html) %><% else %><%= tag 'input', options.merge(input_html) %><% end %>
@@ -1,27 +1,27 @@
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-checkbox mdc-checkbox', options.dig(:wrapper_html, :class), ('mdc-checkbox--disabled' if options.dig(:input_html, :disabled))].join(' ')
9
- } %>
10
- <% input_html = {
11
- type: 'checkbox',
12
- class: ['mdc-checkbox__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-checkbox__background">
22
- <svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
23
- <path class="mdc-checkbox__checkmark__path" fill="none" stroke="white" d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
24
- </svg>
25
- <div class="mdc-checkbox__mixedmark"></div>
26
- </div>
27
- <% 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-checkbox mdc-checkbox', options.dig(:wrapper_html, :class), ('mdc-checkbox--disabled' if options.dig(:input_html, :disabled))].join(' ')
9
+ } %>
10
+ <% input_html = {
11
+ type: 'checkbox',
12
+ class: ['mdc-checkbox__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-checkbox__background">
22
+ <svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
23
+ <path class="mdc-checkbox__checkmark__path" fill="none" stroke="white" d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
24
+ </svg>
25
+ <div class="mdc-checkbox__mixedmark"></div>
26
+ </div>
27
+ <% end %>