simple_form_materialize 1.0.0.rc1

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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +18 -0
  3. data/.gitignore +55 -0
  4. data/.rubocop.yml +862 -0
  5. data/.ruby-version +1 -0
  6. data/.yardopts +1 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/Gemfile +14 -0
  9. data/Gemfile.lock +147 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +33 -0
  12. data/Rakefile +31 -0
  13. data/bin/console +7 -0
  14. data/bin/setup +6 -0
  15. data/circle.yml +21 -0
  16. data/lib/generators/simple_form_materialize/install_generator.rb +17 -0
  17. data/lib/generators/templates/assets/javascripts/init_form_materialize.coffee +16 -0
  18. data/lib/generators/templates/config/initializers/simple_form_components.rb +18 -0
  19. data/lib/generators/templates/config/initializers/simple_form_materialize.rb +244 -0
  20. data/lib/simple_form_materialize/version.rb +4 -0
  21. data/lib/simple_form_materialize.rb +5 -0
  22. data/simple_form_materialize.gemspec +28 -0
  23. data/test/lib/install_generator_test.rb +19 -0
  24. data/test/rails_app/Rakefile +8 -0
  25. data/test/rails_app/app/controllers/application_controller.rb +7 -0
  26. data/test/rails_app/app/controllers/home_controller.rb +5 -0
  27. data/test/rails_app/app/helpers/application_helper.rb +4 -0
  28. data/test/rails_app/app/views/home/index.html.erb +1 -0
  29. data/test/rails_app/app/views/layouts/application.html.erb +13 -0
  30. data/test/rails_app/bin/bundle +4 -0
  31. data/test/rails_app/bin/rails +5 -0
  32. data/test/rails_app/bin/rake +5 -0
  33. data/test/rails_app/config/application.rb +13 -0
  34. data/test/rails_app/config/boot.rb +15 -0
  35. data/test/rails_app/config/database.yml +18 -0
  36. data/test/rails_app/config/environment.rb +6 -0
  37. data/test/rails_app/config/environments/development.rb +31 -0
  38. data/test/rails_app/config/environments/production.rb +87 -0
  39. data/test/rails_app/config/environments/test.rb +46 -0
  40. data/test/rails_app/config/initializers/backtrace_silencers.rb +8 -0
  41. data/test/rails_app/config/initializers/inflections.rb +3 -0
  42. data/test/rails_app/config/initializers/secret_token.rb +4 -0
  43. data/test/rails_app/config/initializers/session_store.rb +2 -0
  44. data/test/rails_app/config/routes.rb +4 -0
  45. data/test/rails_app/config.ru +5 -0
  46. data/test/rails_app/public/404.html +26 -0
  47. data/test/rails_app/public/422.html +26 -0
  48. data/test/rails_app/public/500.html +26 -0
  49. data/test/rails_app/public/favicon.ico +0 -0
  50. data/test/simple_form_materialize_test.rb +5 -0
  51. data/test/test_helper.rb +31 -0
  52. metadata +143 -0
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.0
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --exclude /templates/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at pezza.chris@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ source "https://rubygems.org"
3
+
4
+ gemspec
5
+
6
+ gem "minitest-ci"
7
+ gem "rails", "~> 5.0.0"
8
+ gem "rubocop"
9
+ gem "simplecov"
10
+ gem "yard"
11
+
12
+ group :test do
13
+ gem "codeclimate-test-reporter", require: false
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,147 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simple_form_materialize (1.0.0.rc1)
5
+ railties (>= 4.1.0, < 5.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.0.1)
11
+ actionpack (= 5.0.1)
12
+ nio4r (~> 1.2)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.0.1)
15
+ actionpack (= 5.0.1)
16
+ actionview (= 5.0.1)
17
+ activejob (= 5.0.1)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.0.1)
21
+ actionview (= 5.0.1)
22
+ activesupport (= 5.0.1)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.0.1)
28
+ activesupport (= 5.0.1)
29
+ builder (~> 3.1)
30
+ erubis (~> 2.7.0)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
+ activejob (5.0.1)
34
+ activesupport (= 5.0.1)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.0.1)
37
+ activesupport (= 5.0.1)
38
+ activerecord (5.0.1)
39
+ activemodel (= 5.0.1)
40
+ activesupport (= 5.0.1)
41
+ arel (~> 7.0)
42
+ activesupport (5.0.1)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
47
+ arel (7.1.4)
48
+ ast (2.3.0)
49
+ builder (3.2.3)
50
+ codeclimate-test-reporter (1.0.5)
51
+ simplecov
52
+ concurrent-ruby (1.0.4)
53
+ docile (1.1.5)
54
+ erubis (2.7.0)
55
+ globalid (0.3.7)
56
+ activesupport (>= 4.1.0)
57
+ i18n (0.8.0)
58
+ json (2.0.3)
59
+ loofah (2.0.3)
60
+ nokogiri (>= 1.5.9)
61
+ mail (2.6.4)
62
+ mime-types (>= 1.16, < 4)
63
+ method_source (0.8.2)
64
+ mime-types (3.1)
65
+ mime-types-data (~> 3.2015)
66
+ mime-types-data (3.2016.0521)
67
+ mini_portile2 (2.1.0)
68
+ minitest (5.10.1)
69
+ minitest-ci (3.1.0)
70
+ minitest (~> 5.0, >= 5.0.6)
71
+ nio4r (1.2.1)
72
+ nokogiri (1.7.0.1)
73
+ mini_portile2 (~> 2.1.0)
74
+ parser (2.3.3.1)
75
+ ast (~> 2.2)
76
+ powerpack (0.1.1)
77
+ rack (2.0.1)
78
+ rack-test (0.6.3)
79
+ rack (>= 1.0)
80
+ rails (5.0.1)
81
+ actioncable (= 5.0.1)
82
+ actionmailer (= 5.0.1)
83
+ actionpack (= 5.0.1)
84
+ actionview (= 5.0.1)
85
+ activejob (= 5.0.1)
86
+ activemodel (= 5.0.1)
87
+ activerecord (= 5.0.1)
88
+ activesupport (= 5.0.1)
89
+ bundler (>= 1.3.0, < 2.0)
90
+ railties (= 5.0.1)
91
+ sprockets-rails (>= 2.0.0)
92
+ rails-dom-testing (2.0.2)
93
+ activesupport (>= 4.2.0, < 6.0)
94
+ nokogiri (~> 1.6)
95
+ rails-html-sanitizer (1.0.3)
96
+ loofah (~> 2.0)
97
+ railties (5.0.1)
98
+ actionpack (= 5.0.1)
99
+ activesupport (= 5.0.1)
100
+ method_source
101
+ rake (>= 0.8.7)
102
+ thor (>= 0.18.1, < 2.0)
103
+ rainbow (2.2.1)
104
+ rake (12.0.0)
105
+ rubocop (0.47.1)
106
+ parser (>= 2.3.3.1, < 3.0)
107
+ powerpack (~> 0.1)
108
+ rainbow (>= 1.99.1, < 3.0)
109
+ ruby-progressbar (~> 1.7)
110
+ unicode-display_width (~> 1.0, >= 1.0.1)
111
+ ruby-progressbar (1.8.1)
112
+ simplecov (0.13.0)
113
+ docile (~> 1.1.0)
114
+ json (>= 1.8, < 3)
115
+ simplecov-html (~> 0.10.0)
116
+ simplecov-html (0.10.0)
117
+ sprockets (3.7.1)
118
+ concurrent-ruby (~> 1.0)
119
+ rack (> 1, < 3)
120
+ sprockets-rails (3.2.0)
121
+ actionpack (>= 4.0)
122
+ activesupport (>= 4.0)
123
+ sprockets (>= 3.0.0)
124
+ thor (0.19.4)
125
+ thread_safe (0.3.5)
126
+ tzinfo (1.2.2)
127
+ thread_safe (~> 0.1)
128
+ unicode-display_width (1.1.3)
129
+ websocket-driver (0.6.5)
130
+ websocket-extensions (>= 0.1.0)
131
+ websocket-extensions (0.1.2)
132
+ yard (0.9.8)
133
+
134
+ PLATFORMS
135
+ ruby
136
+
137
+ DEPENDENCIES
138
+ codeclimate-test-reporter
139
+ minitest-ci
140
+ rails (~> 5.0.0)
141
+ rubocop
142
+ simple_form_materialize!
143
+ simplecov
144
+ yard
145
+
146
+ BUNDLED WITH
147
+ 1.13.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Christopher Pezza
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Simple Form Materialize
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/simple_form_materialize`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'simple_form_materialize'
13
+ ```
14
+
15
+
16
+ ## Usage
17
+
18
+ TODO: Write usage instructions here
19
+
20
+ ## Development
21
+
22
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
+
24
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/simple_form_materialize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
29
+
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "rubocop/rake_task"
4
+
5
+ if ENV['CIRCLECI']
6
+ dir = File.join(ENV['CIRCLE_ARTIFACTS'], 'linters')
7
+ end
8
+
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << "test"
11
+ t.libs << "lib"
12
+ t.test_files = FileList['test/**/*_test.rb']
13
+ end
14
+
15
+ desc 'Rubocop Task'
16
+ task (:rubocop) do
17
+ outputpath =
18
+ if ENV['CIRCLECI']
19
+ "#{dir}/rubocop-results.html"
20
+ else
21
+ 'rubocop-results.html'
22
+ end
23
+ RuboCop::RakeTask.new do |t|
24
+ t.options = [
25
+ '-c', '.rubocop.yml', '-D', '-f', 'html', '-o', outputpath,
26
+ ]
27
+ t.fail_on_error = true
28
+ end
29
+ end
30
+
31
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "simple_form_materialize"
6
+ require "pry"
7
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
data/circle.yml ADDED
@@ -0,0 +1,21 @@
1
+ machine:
2
+ timezone: America/New_York
3
+ ruby:
4
+ version: 2.4.0
5
+
6
+ dependencies:
7
+ pre:
8
+ - gem update --system
9
+ - gem install rainbow -v "2.2.1"
10
+ - gem install bundler
11
+
12
+ test:
13
+ override:
14
+ - bundle exec rake test:
15
+ parallel: true
16
+ files:
17
+ - test/**/*_test.rb
18
+
19
+ post:
20
+ - bundle exec codeclimate-test-reporter
21
+ - bundle exec rake rubocop
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ require "rails/generators"
3
+
4
+ module SimpleFormMaterialize
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../templates", __FILE__)
7
+
8
+ desc "Creates a Simple Form Materialize config file"
9
+
10
+ def generate_config_files
11
+ puts "Generating Config..."
12
+ directory "config", "config/"
13
+ puts "Generating Javascript..."
14
+ directory "assets", "app/assets/"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ $(document).ready ->
2
+ $('input, textarea').characterCounter()
3
+ $('textarea').trigger('autoresize')
4
+ $('select').material_select()
5
+ $('.datepicker').pickadate
6
+ selectMonths: true
7
+ selectYears: 15
8
+
9
+ $('span.help-text').each ->
10
+ $value = $(this)[0].innerHTML
11
+ $(this).addClass 'hide'
12
+ $(this).parents('div.input-field').children('label').attr(
13
+ 'data-hint', $value
14
+ )
15
+ return
16
+ return
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ module SimpleForm
3
+ module Components
4
+ module Icons
5
+ def icon(_wrapper_options = nil)
6
+ return icon_class unless options[:icon].nil?
7
+ end
8
+
9
+ def icon_class
10
+ template.content_tag(:i, "", class: "material-icons prefix") do
11
+ options[:icon]
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ SimpleForm::Inputs::Base.send(:include, SimpleForm::Components::Icons)
@@ -0,0 +1,244 @@
1
+ # frozen_string_literal: true
2
+ # Use this setup block to configure all options available in SimpleForm.
3
+ SimpleForm.setup do |config|
4
+ config.error_notification_class = "alert alert-danger"
5
+ config.button_class = "btn waves-effect"
6
+ config.boolean_label_class = nil
7
+ config.boolean_style = :inline
8
+
9
+ # Form Initialization
10
+ config.wrappers :materialize_form,
11
+ tag: "div", class: "input-field col s12" do |b|
12
+ # Form Extensions
13
+ b.use :html5
14
+ b.use :placeholder
15
+ b.optional :maxlength
16
+ b.optional :pattern
17
+ b.optional :min_max
18
+ b.optional :readonly
19
+ b.optional :icon
20
+
21
+ # Form Components
22
+ b.use :input, class: "validate", error_class: "invalid"
23
+ b.use :label
24
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
25
+ end
26
+
27
+ # String Input
28
+ config.wrappers :materialize_string,
29
+ tag: "div", class: "input-field col s12" do |b|
30
+ # Form Extensions
31
+ b.use :html5
32
+ b.use :placeholder
33
+ b.optional :maxlength
34
+ b.optional :pattern
35
+ b.optional :min_max
36
+ b.optional :readonly
37
+ b.optional :icon
38
+
39
+ # Form Components
40
+ b.use :input, class: "validate", error_class: "invalid"
41
+ b.use :label
42
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
43
+ end
44
+
45
+ # Email Input
46
+ config.wrappers :materialize_email,
47
+ tag: "div", class: "input-field col s12", icon: "email" do |b|
48
+ # Form Extensions
49
+ b.use :html5
50
+ b.use :placeholder
51
+ b.optional :maxlength
52
+ b.optional :pattern
53
+ b.optional :min_max
54
+ b.optional :readonly
55
+ b.use :icon
56
+
57
+ # Form Components
58
+ b.use :input, class: "validate", error_class: "invalid"
59
+ b.use :label
60
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
61
+ end
62
+
63
+ # URL Input
64
+ config.wrappers :materialize_url,
65
+ tag: "div", class: "input-field col s12", icon: "link" do |b|
66
+ # Form Extensions
67
+ b.use :html5
68
+ b.use :placeholder
69
+ b.optional :maxlength
70
+ b.optional :pattern
71
+ b.optional :min_max
72
+ b.optional :readonly
73
+ b.use :icon
74
+
75
+ # Form Components
76
+ b.use :input, class: "validate", error_class: "invalid"
77
+ b.use :label
78
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
79
+ end
80
+
81
+ # Telephone Input
82
+ config.wrappers :materialize_tel,
83
+ tag: "div", class: "input-field col s12", icon: "phone" do |b|
84
+ # Form Extensions
85
+ b.use :html5
86
+ b.use :placeholder
87
+ b.optional :maxlength
88
+ b.optional :pattern
89
+ b.optional :min_max
90
+ b.optional :readonly
91
+ b.use :icon
92
+
93
+ # Form Components
94
+ b.use :input, class: "validate", error_class: "invalid"
95
+ b.use :label
96
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
97
+ end
98
+
99
+ # Date Picker Input
100
+ config.wrappers :materialize_date,
101
+ tag: "div", class: "input-field col s12", icon: "event" do |b|
102
+ # Form Extensions
103
+ b.use :html5
104
+ b.use :placeholder
105
+ b.optional :readonly
106
+ b.use :icon
107
+
108
+ # Form Components
109
+ b.use :input, class: "datepicker validate", error_class: "invalid"
110
+ b.use :label
111
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
112
+ end
113
+
114
+ # Textarea Input Field
115
+ config.wrappers :materialize_text_area,
116
+ tag: "div", class: "input-field col s12" do |b|
117
+ # Form Extensions
118
+ b.use :html5
119
+ b.use :placeholder
120
+ b.optional :maxlength
121
+ b.optional :pattern
122
+ b.optional :min_max
123
+ b.optional :readonly
124
+ b.optional :icon
125
+
126
+ # Form Components
127
+ b.use :input, class: "materialize-textarea validate", error_class: "invalid"
128
+ b.use :label
129
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
130
+ end
131
+
132
+ # Boolean Type
133
+ config.wrappers :materialize_boolean, tag: "p", class: "col s12" do |b|
134
+ # Form Extensions
135
+ b.use :html5
136
+ b.optional :readonly
137
+
138
+ # Form Components
139
+ b.use :input
140
+ b.use :label
141
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
142
+ end
143
+
144
+ # Toggle Input Type
145
+ config.wrappers :materialize_switch,
146
+ tag: "p", class: "col s12 switch" do |b|
147
+ # Form Extensions
148
+ b.use :html5
149
+ b.optional :readonly
150
+
151
+ # Form Components
152
+ b.use :label
153
+ b.wrapper tag: "label" do |ba|
154
+ ba.use :input
155
+ ba.use :tag, tag: "span", class: "lever"
156
+ end
157
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
158
+ end
159
+
160
+ # Range Input Type
161
+ config.wrappers :materialize_range,
162
+ tag: "p", class: "range-field" do |b|
163
+ # Form Extensions
164
+ b.use :html5
165
+ b.optional :readonly
166
+ b.optional :min_max
167
+
168
+ # Form Components
169
+ b.use :label
170
+ b.use :input
171
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
172
+ end
173
+
174
+ # Radio & Checkbox Input Collections
175
+ config.wrappers :materialize_radio_and_checkboxes,
176
+ tag: "div", class: "col s12" do |b|
177
+ # Form Extensions
178
+ b.use :html5
179
+ b.optional :readonly
180
+
181
+ # Form Components
182
+ b.use :label
183
+ b.use :input
184
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
185
+ end
186
+
187
+ # File Upload
188
+ config.wrappers :materialize_file_input,
189
+ tag: "div", class: "file-field input-field col s12" do |b|
190
+ # Form Extensions
191
+ b.use :html5
192
+
193
+ # Form Components
194
+ b.wrapper tag: :div, class: "btn" do |ba|
195
+ ba.use :tag, tag: :span, text: :label_text
196
+ ba.use :input
197
+ end
198
+ b.wrapper tag: :div, class: "file-path-wrapper" do |ba|
199
+ ba.use :tag, tag: :input, class: "file-path validate", type: "text",
200
+ placeholder: "Browse...", error_class: "invalid"
201
+ end
202
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
203
+ end
204
+
205
+ # Multiple File Upload
206
+ config.wrappers :materialize_multiple_file_input,
207
+ tag: "div", class: "file-field input-field col s12" do |b|
208
+ # Form Extensions
209
+ b.use :html5
210
+
211
+ # Form Components
212
+ b.wrapper tag: :div, class: "btn" do |ba|
213
+ ba.use :tag, tag: :span, text: :label_text
214
+ ba.use :input, multiple: true
215
+ end
216
+ b.wrapper tag: :div, class: "file-path-wrapper" do |ba|
217
+ ba.use :tag, tag: :input, class: "file-path validate", type: "text",
218
+ placeholder: "Upload one or more files",
219
+ error_class: "invalid"
220
+ end
221
+ b.use :hint, wrap_with: { tag: "span", class: "help-text" }
222
+ end
223
+
224
+ config.default_wrapper = :materialize_form
225
+ config.wrapper_mappings = {
226
+ boolean: :materialize_boolean,
227
+ string: :materialize_string,
228
+ email: :materialize_email,
229
+ url: :materialize_url,
230
+ tel: :materialize_tel,
231
+ password: :materialize_string,
232
+ search: :materialize_string,
233
+ uuid: :materialize_string,
234
+ text: :materialize_text_area,
235
+ file: :materialize_file_input,
236
+ integer: :materialize_string,
237
+ float: :materialize_string,
238
+ decimal: :materialize_string,
239
+ range: :materialize_range,
240
+ date: :materialize_date,
241
+ check_boxes: :materialize_radio_and_checkboxes,
242
+ radio_buttons: :materialize_radio_and_checkboxes
243
+ }
244
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module SimpleFormMaterialize
3
+ VERSION = "1.0.0.rc1"
4
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ require "simple_form_materialize/version"
3
+
4
+ module SimpleFormMaterialize
5
+ end