simple_form-bulma 0.1.0

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 (29) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +34 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/simple_form_bulma_manifest.js +1 -0
  6. data/app/assets/stylesheets/simple_form/bulma/application.css +15 -0
  7. data/app/controllers/simple_form/bulma/application_controller.rb +6 -0
  8. data/app/controllers/simple_form/bulma/items_controller.rb +36 -0
  9. data/app/helpers/simple_form/bulma/application_helper.rb +6 -0
  10. data/app/jobs/simple_form/bulma/application_job.rb +6 -0
  11. data/app/mailers/simple_form/bulma/application_mailer.rb +8 -0
  12. data/app/models/simple_form/bulma/application_record.rb +7 -0
  13. data/app/models/simple_form/bulma/item.rb +23 -0
  14. data/app/views/layouts/simple_form/bulma/application.html.erb +16 -0
  15. data/app/views/simple_form/bulma/items/_form.html.erb +15 -0
  16. data/app/views/simple_form/bulma/items/index.html.erb +25 -0
  17. data/app/views/simple_form/bulma/items/new.html.erb +5 -0
  18. data/config/initializers/simple_form.rb +176 -0
  19. data/config/initializers/simple_form_bulma.rb +126 -0
  20. data/config/locales/simple_form.en.yml +31 -0
  21. data/config/routes.rb +7 -0
  22. data/lib/generators/simple_form/bulma/USAGE +3 -0
  23. data/lib/generators/simple_form/bulma/install_generator.rb +20 -0
  24. data/lib/generators/simple_form/bulma/templates/config/initializers/simple_form_bulma.rb +126 -0
  25. data/lib/simple_form/bulma/engine.rb +7 -0
  26. data/lib/simple_form/bulma/version.rb +5 -0
  27. data/lib/simple_form/bulma.rb +10 -0
  28. data/lib/tasks/simple_form/bulma_tasks.rake +4 -0
  29. metadata +108 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4708d7183082a8f605e99d7ea09c5da530583389256f880877055ee45ec0e20e
4
+ data.tar.gz: 0fbe541e33e9fb3781c7941ce3dd93a9171f2562466d9769922bac14a4fedab9
5
+ SHA512:
6
+ metadata.gz: 789e6ab35bef3e00a201daada255f00a8642ec6c10dc79e99c084a1178010fcd49c6dddf4317dda9933f7faa0fcdc3b3c4b695e860152e1714fe10293f031ba4
7
+ data.tar.gz: ecb71e0d4b476ce0956bddef4c43734749bfcd45b130d9bf9b5acaee94d5191ce36bb4a1185931acfee0783bfa4777534ababd0a80790f0c117af3dd26718771
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2024 Juan Vasquez
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # SimpleForm::Bulma
2
+ The easiest way to use Bulma with SimpleForm.
3
+
4
+ ## Installation
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'simple_form-bulma'
9
+ ```
10
+
11
+ And then execute:
12
+ ```bash
13
+ bundle
14
+ ```
15
+
16
+ Or install it yourself as:
17
+ ```bash
18
+ $ gem install simple_form-bulma
19
+ ```
20
+
21
+ ## Usage
22
+ To copy the Bulma theme for SimpleForm, run the following command:
23
+
24
+ ```bash
25
+ bin/rails generate simple_form:bulma:install
26
+ ```
27
+
28
+ Or you can copy the theme manually by copying the `config/initializers/simple_form_bulma.rb` file to your `config/initializers` directory.
29
+
30
+ ## Contributing
31
+ Contribution directions go here.
32
+
33
+ ## License
34
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'bundler/setup'
2
+
3
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
4
+ load 'rails/tasks/engine.rake'
5
+
6
+ load 'rails/tasks/statistics.rake'
7
+
8
+ require 'bundler/gem_tasks'
9
+
10
+ require 'rake/testtask'
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/simple_form/bulma .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,6 @@
1
+ module SimpleForm
2
+ module Bulma
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,36 @@
1
+ require_dependency 'simple_form/bulma/application_controller'
2
+
3
+ module SimpleForm::Bulma
4
+ class ItemsController < ApplicationController
5
+ # GET /items
6
+ def index
7
+ @items = Item.all
8
+ end
9
+
10
+ # GET /items/new
11
+ def new
12
+ @item = Item.new
13
+ end
14
+
15
+ # POST /items
16
+ def create
17
+ @item = Item.new(item_params)
18
+
19
+ if @item.valid?
20
+ Item.all << @item
21
+ redirect_to @item, notice: 'Item was successfully created.'
22
+ else
23
+ render :new
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def item_params
30
+ params.require(:item)
31
+ .permit(:name, :url, :secret_key, :active, :description, :background,
32
+ :serial_number, :quantity, :published_at, :expired_at,
33
+ :daily_check_at)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,6 @@
1
+ module SimpleForm
2
+ module Bulma
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module SimpleForm
2
+ module Bulma
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module SimpleForm
2
+ module Bulma
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module SimpleForm
2
+ module Bulma
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleForm::Bulma
4
+ class Item
5
+ include ActiveModel::Model
6
+ include ActiveModel::Attributes
7
+
8
+ attr_accessor :id, :name, :url, :secret_key, :description,
9
+ :background, :serial_number, :quantity
10
+
11
+ attribute :active, :boolean, default: true
12
+ attribute :published_at, :datetime, default: -> { DateTime.current }
13
+ attribute :expired_at, :date
14
+ attribute :daily_check_at, :time
15
+
16
+ validates :name, :url, presence: true
17
+ validates :url, format: URI::DEFAULT_PARSER.make_regexp(%w[http https])
18
+
19
+ def self.all
20
+ @all ||= []
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Simple form bulma</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "simple_form/bulma/application", media: "all" %>
9
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.0/css/bulma.min.css">
10
+ </head>
11
+ <body>
12
+ <div class="container is-widescreen is-fullhd">
13
+ <%= yield %>
14
+ </div>
15
+ </body>
16
+ </html>
@@ -0,0 +1,15 @@
1
+ <%= simple_form_for(item) do |f| %>
2
+ <%= f.input :name %>
3
+ <%= f.input :url, placeholder: "URL should start with http or https" %>
4
+ <%= f.input :secret_key, as: :password %>
5
+ <%= f.input :active, as: :boolean %>
6
+ <%= f.input :description, as: :text %>
7
+ <%= f.input :background, as: :color %>
8
+ <%= f.input :serial_number, as: :integer %>
9
+ <%= f.input :quantity, as: :decimal %>
10
+ <%= f.input :published_at, as: :datetime, html5: true %>
11
+ <%= f.input :expired_at, as: :date, html5: true %>
12
+ <%= f.input :daily_check_at, as: :time, html5: true %>
13
+
14
+ <%= f.button :submit %>
15
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Items</h1>
4
+
5
+ <%= link_to 'New Item', new_item_path %>
6
+
7
+ <table>
8
+ <thead>
9
+ <tr>
10
+ <th>Name</th>
11
+ <th>Active</th>
12
+ <th>URL</th>
13
+ </tr>
14
+ </thead>
15
+
16
+ <tbody>
17
+ <% @items.each do |item| %>
18
+ <tr>
19
+ <td><%= item.name %></td>
20
+ <td><%= item.active ? "true" : "false" %></td>
21
+ <td><%= item.url %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
@@ -0,0 +1,5 @@
1
+ <h1>New Item</h1>
2
+
3
+ <%= render 'form', item: @item %>
4
+
5
+ <%= link_to 'Back', items_path %>
@@ -0,0 +1,176 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Uncomment this and change the path if necessary to include your own
4
+ # components.
5
+ # See https://github.com/heartcombo/simple_form#custom-components to know
6
+ # more about custom components.
7
+ # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
8
+ #
9
+ # Use this setup block to configure all options available in SimpleForm.
10
+ SimpleForm.setup do |config|
11
+ # Wrappers are used by the form builder to generate a
12
+ # complete input. You can remove any component from the
13
+ # wrapper, change the order or even add your own to the
14
+ # stack. The options given below are used to wrap the
15
+ # whole input.
16
+ config.wrappers :default, class: :input,
17
+ hint_class: :field_with_hint, error_class: :field_with_errors, valid_class: :field_without_errors do |b|
18
+ ## Extensions enabled by default
19
+ # Any of these extensions can be disabled for a
20
+ # given input by passing: `f.input EXTENSION_NAME => false`.
21
+ # You can make any of these extensions optional by
22
+ # renaming `b.use` to `b.optional`.
23
+
24
+ # Determines whether to use HTML5 (:email, :url, ...)
25
+ # and required attributes
26
+ b.use :html5
27
+
28
+ # Calculates placeholders automatically from I18n
29
+ # You can also pass a string as f.input placeholder: "Placeholder"
30
+ b.use :placeholder
31
+
32
+ ## Optional extensions
33
+ # They are disabled unless you pass `f.input EXTENSION_NAME => true`
34
+ # to the input. If so, they will retrieve the values from the model
35
+ # if any exists. If you want to enable any of those
36
+ # extensions by default, you can change `b.optional` to `b.use`.
37
+
38
+ # Calculates maxlength from length validations for string inputs
39
+ # and/or database column lengths
40
+ b.optional :maxlength
41
+
42
+ # Calculate minlength from length validations for string inputs
43
+ b.optional :minlength
44
+
45
+ # Calculates pattern from format validations for string inputs
46
+ b.optional :pattern
47
+
48
+ # Calculates min and max from length validations for numeric inputs
49
+ b.optional :min_max
50
+
51
+ # Calculates readonly automatically from readonly attributes
52
+ b.optional :readonly
53
+
54
+ ## Inputs
55
+ # b.use :input, class: 'input', error_class: 'is-invalid', valid_class: 'is-valid'
56
+ b.use :label_input
57
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
58
+ b.use :error, wrap_with: { tag: :span, class: :error }
59
+
60
+ ## full_messages_for
61
+ # If you want to display the full error message for the attribute, you can
62
+ # use the component :full_error, like:
63
+ #
64
+ # b.use :full_error, wrap_with: { tag: :span, class: :error }
65
+ end
66
+
67
+ # The default wrapper to be used by the FormBuilder.
68
+ config.default_wrapper = :default
69
+
70
+ # Define the way to render check boxes / radio buttons with labels.
71
+ # Defaults to :nested for bootstrap config.
72
+ # inline: input + label
73
+ # nested: label > input
74
+ config.boolean_style = :nested
75
+
76
+ # Default class for buttons
77
+ config.button_class = 'btn'
78
+
79
+ # Method used to tidy up errors. Specify any Rails Array method.
80
+ # :first lists the first message for each field.
81
+ # Use :to_sentence to list all errors for each field.
82
+ # config.error_method = :first
83
+
84
+ # Default tag used for error notification helper.
85
+ config.error_notification_tag = :div
86
+
87
+ # CSS class to add for error notification helper.
88
+ config.error_notification_class = 'error_notification'
89
+
90
+ # Series of attempts to detect a default label method for collection.
91
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
92
+
93
+ # Series of attempts to detect a default value method for collection.
94
+ # config.collection_value_methods = [ :id, :to_s ]
95
+
96
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
97
+ # config.collection_wrapper_tag = nil
98
+
99
+ # You can define the class to use on all collection wrappers. Defaulting to none.
100
+ # config.collection_wrapper_class = nil
101
+
102
+ # You can wrap each item in a collection of radio/check boxes with a tag,
103
+ # defaulting to :span.
104
+ # config.item_wrapper_tag = :span
105
+
106
+ # You can define a class to use in all item wrappers. Defaulting to none.
107
+ # config.item_wrapper_class = nil
108
+
109
+ # How the label text should be generated altogether with the required text.
110
+ # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
111
+
112
+ # You can define the class to use on all labels. Default is nil.
113
+ # config.label_class = nil
114
+
115
+ # You can define the default class to be used on forms. Can be overridden
116
+ # with `html: { :class }`. Defaulting to none.
117
+ # config.default_form_class = nil
118
+
119
+ # You can define which elements should obtain additional classes
120
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
121
+
122
+ # Whether attributes are required by default (or not). Default is true.
123
+ # config.required_by_default = true
124
+
125
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
126
+ # These validations are enabled in SimpleForm's internal config but disabled by default
127
+ # in this configuration, which is recommended due to some quirks from different browsers.
128
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
129
+ # change this configuration to true.
130
+ config.browser_validations = false
131
+
132
+ # Custom mappings for input types. This should be a hash containing a regexp
133
+ # to match as key, and the input type that will be used when the field name
134
+ # matches the regexp as value.
135
+ # config.input_mappings = { /count/ => :integer }
136
+
137
+ # Custom wrappers for input types. This should be a hash containing an input
138
+ # type as key and the wrapper that will be used for all inputs with specified type.
139
+ # config.wrapper_mappings = { string: :prepend }
140
+
141
+ # Namespaces where SimpleForm should look for custom input classes that
142
+ # override default inputs.
143
+ # config.custom_inputs_namespaces << "CustomInputs"
144
+
145
+ # Default priority for time_zone inputs.
146
+ # config.time_zone_priority = nil
147
+
148
+ # Default priority for country inputs.
149
+ # config.country_priority = nil
150
+
151
+ # When false, do not use translations for labels.
152
+ # config.translate_labels = true
153
+
154
+ # Automatically discover new inputs in Rails' autoload path.
155
+ # config.inputs_discovery = true
156
+
157
+ # Cache SimpleForm inputs discovery
158
+ # config.cache_discovery = !Rails.env.development?
159
+
160
+ # Default class for inputs
161
+ # config.input_class = nil
162
+
163
+ # Define the default class of the input wrapper of the boolean input.
164
+ config.boolean_label_class = 'checkbox'
165
+
166
+ # Defines if the default input wrapper class should be included in radio
167
+ # collection wrappers.
168
+ # config.include_default_input_wrapper_class = true
169
+
170
+ # Defines which i18n scope will be used in Simple Form.
171
+ # config.i18n_scope = 'simple_form'
172
+
173
+ # Defines validation classes to the input_field. By default it's nil.
174
+ # config.input_field_valid_class = 'is-valid'
175
+ # config.input_field_error_class = 'is-invalid'
176
+ end
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Use this setup block to configure all options available in SimpleForm.
4
+ SimpleForm.setup do |config|
5
+ # Default class for buttons
6
+ config.button_class = 'button'
7
+
8
+ # Define the default class of the input wrapper of the boolean input.
9
+ config.boolean_label_class = 'checkbox'
10
+
11
+ # How the label text should be generated altogether with the required text.
12
+ config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
13
+
14
+ # Define the way to render check boxes / radio buttons with labels.
15
+ config.boolean_style = :inline
16
+
17
+ # You can wrap each item in a collection of radio/check boxes with a tag
18
+ config.item_wrapper_tag = :div
19
+
20
+ # Defines if the default input wrapper class should be included in radio
21
+ # collection wrappers.
22
+ config.include_default_input_wrapper_class = false
23
+
24
+ # CSS class to add for error notification helper.
25
+ config.error_notification_class = 'notification is-danger'
26
+
27
+ # Method used to tidy up errors. Specify any Rails Array method.
28
+ # :first lists the first message for each field.
29
+ # :to_sentence to list all errors for each field.
30
+ config.error_method = :to_sentence
31
+
32
+ # add validation classes to `input_field`
33
+ config.input_field_error_class = 'is-danger'
34
+ config.input_field_valid_class = 'is-success'
35
+
36
+ # vertical forms
37
+ #
38
+ # bulma vertical default_wrapper
39
+ config.wrappers :vertical_form, tag: 'div', class: 'field' do |b|
40
+ b.use :html5
41
+ b.use :placeholder
42
+ b.optional :maxlength
43
+ b.optional :minlength
44
+ b.optional :pattern
45
+ b.optional :min_max
46
+ b.optional :readonly
47
+ b.use :label, class: 'label'
48
+ b.use :input, class: 'input', wrap_with: { tag: 'div', class: 'control' }, error_class: 'is-danger', valid_class: 'is-success'
49
+ b.use :full_error, wrap_with: { tag: 'div', class: 'help is-danger' }
50
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
51
+ end
52
+
53
+ # bulma vertical select_form
54
+ config.wrappers :select_form, tag: 'div', class: 'control' do |b|
55
+ b.use :html5
56
+ b.use :placeholder
57
+ b.optional :pattern
58
+ b.optional :readonly
59
+ b.use :input, wrap_with: { tag: 'div', class: 'select' }
60
+ b.use :full_error, wrap_with: { tag: 'div', class: 'help is-danger' }
61
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
62
+ end
63
+
64
+ # bulma extension vertical input for boolean
65
+ config.wrappers :vertical_boolean, tag: 'div', class: 'field' do |b|
66
+ b.use :html5
67
+ b.optional :readonly
68
+ b.use :input, class: 'is-checkradio is-info'
69
+ b.use :label
70
+ # b.wrapper :form_check_wrapper, tag: 'div', class: 'control' do |bb|
71
+ # bb.use :input, wrap_with: { tag: 'label', class: 'checkbox' }
72
+ # bb.use :label, class: 'checkbox'
73
+ # bb.use :full_error, wrap_with: { tag: 'div', class: 'help is-danger' }
74
+ # bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
75
+ # end
76
+ end
77
+
78
+ ## vertical input for radio buttons and check boxes
79
+ config.wrappers :vertical_collection, item_wrapper_class: 'form-check', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
80
+ b.use :html5
81
+ b.optional :readonly
82
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
83
+ ba.use :label_text
84
+ end
85
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
86
+ b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
87
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
88
+ end
89
+
90
+ ## bulma vertical file input
91
+ config.wrappers :vertical_file, tag: 'div', class: 'file' do |b|
92
+ b.use :html5
93
+ b.optional :readonly
94
+ b.use :input, class: 'file-input', wrap_with: { tag: 'label', class: 'file-label' }
95
+ b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
96
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
97
+ end
98
+
99
+ ## bulma vertical multi select
100
+ config.wrappers :vertical_multi_select, tag: 'div', class: 'field' do |b|
101
+ b.use :html5
102
+ b.optional :readonly
103
+ b.use :label, class: 'label'
104
+ b.wrapper tag: 'div', class: 'control' do |ba|
105
+ ba.use :input, class: 'input', error_class: 'is-danger', valid_class: 'is-success'
106
+ end
107
+ b.use :full_error, wrap_with: { tag: 'div', class: 'is-danger' }
108
+ b.use :hint, wrap_with: { tag: 'small', class: 'help' }
109
+ end
110
+
111
+ # The default wrapper to be used by the FormBuilder.
112
+ config.default_wrapper = :vertical_form
113
+
114
+ # Custom wrappers for input types. This should be a hash containing an input
115
+ # type as key and the wrapper that will be used for all inputs with specified type.
116
+ config.wrapper_mappings = {
117
+ boolean: :vertical_boolean,
118
+ check_boxes: :vertical_collection,
119
+ date: :vertical_multi_select,
120
+ datetime: :vertical_multi_select,
121
+ file: :vertical_file,
122
+ radio_buttons: :vertical_collection,
123
+ range: :vertical_range,
124
+ time: :vertical_multi_select
125
+ }
126
+ end
@@ -0,0 +1,31 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Examples
14
+ # labels:
15
+ # defaults:
16
+ # password: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+ # include_blanks:
27
+ # defaults:
28
+ # age: 'Rather not say'
29
+ # prompts:
30
+ # defaults:
31
+ # age: 'Select your age'
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ SimpleForm::Bulma::Engine.routes.draw do
4
+ resources :items, only: %i[index new create]
5
+
6
+ root to: 'items#index'
7
+ end
@@ -0,0 +1,3 @@
1
+ To copy the SimpleForm::Bulma initializer to your Rails App, with the proper configuration, just run the following command:
2
+
3
+ rails generate simple_form:bulma:install
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+
5
+ module SimpleForm
6
+ module Bulma
7
+ module Generators
8
+ # bin/rails generate simple_form:bulma:install
9
+ class InstallGenerator < Rails::Generators::Base
10
+ source_root File.expand_path('templates', __dir__)
11
+
12
+ desc 'Copy SimpleForm Bulma configuration to your application'
13
+
14
+ def copy_config
15
+ template 'config/initializers/simple_form_bulma.rb'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Use this setup block to configure all options available in SimpleForm.
4
+ SimpleForm.setup do |config|
5
+ # Default class for buttons
6
+ config.button_class = 'button'
7
+
8
+ # Define the default class of the input wrapper of the boolean input.
9
+ config.boolean_label_class = 'checkbox'
10
+
11
+ # How the label text should be generated altogether with the required text.
12
+ config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }
13
+
14
+ # Define the way to render check boxes / radio buttons with labels.
15
+ config.boolean_style = :inline
16
+
17
+ # You can wrap each item in a collection of radio/check boxes with a tag
18
+ config.item_wrapper_tag = :div
19
+
20
+ # Defines if the default input wrapper class should be included in radio
21
+ # collection wrappers.
22
+ config.include_default_input_wrapper_class = false
23
+
24
+ # CSS class to add for error notification helper.
25
+ config.error_notification_class = 'notification is-danger'
26
+
27
+ # Method used to tidy up errors. Specify any Rails Array method.
28
+ # :first lists the first message for each field.
29
+ # :to_sentence to list all errors for each field.
30
+ config.error_method = :to_sentence
31
+
32
+ # add validation classes to `input_field`
33
+ config.input_field_error_class = 'is-danger'
34
+ config.input_field_valid_class = 'is-success'
35
+
36
+ # vertical forms
37
+ #
38
+ # bulma vertical default_wrapper
39
+ config.wrappers :vertical_form, tag: 'div', class: 'field' do |b|
40
+ b.use :html5
41
+ b.use :placeholder
42
+ b.optional :maxlength
43
+ b.optional :minlength
44
+ b.optional :pattern
45
+ b.optional :min_max
46
+ b.optional :readonly
47
+ b.use :label, class: 'label'
48
+ b.use :input, class: 'input', wrap_with: { tag: 'div', class: 'control' }, error_class: 'is-danger', valid_class: 'is-success'
49
+ b.use :full_error, wrap_with: { tag: 'div', class: 'help is-danger' }
50
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
51
+ end
52
+
53
+ # bulma vertical select_form
54
+ config.wrappers :select_form, tag: 'div', class: 'control' do |b|
55
+ b.use :html5
56
+ b.use :placeholder
57
+ b.optional :pattern
58
+ b.optional :readonly
59
+ b.use :input, wrap_with: { tag: 'div', class: 'select' }
60
+ b.use :full_error, wrap_with: { tag: 'div', class: 'help is-danger' }
61
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
62
+ end
63
+
64
+ # bulma extension vertical input for boolean
65
+ config.wrappers :vertical_boolean, tag: 'div', class: 'field' do |b|
66
+ b.use :html5
67
+ b.optional :readonly
68
+ b.use :input, class: 'is-checkradio is-info'
69
+ b.use :label
70
+ # b.wrapper :form_check_wrapper, tag: 'div', class: 'control' do |bb|
71
+ # bb.use :input, wrap_with: { tag: 'label', class: 'checkbox' }
72
+ # bb.use :label, class: 'checkbox'
73
+ # bb.use :full_error, wrap_with: { tag: 'div', class: 'help is-danger' }
74
+ # bb.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
75
+ # end
76
+ end
77
+
78
+ ## vertical input for radio buttons and check boxes
79
+ config.wrappers :vertical_collection, item_wrapper_class: 'form-check', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
80
+ b.use :html5
81
+ b.optional :readonly
82
+ b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
83
+ ba.use :label_text
84
+ end
85
+ b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
86
+ b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
87
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
88
+ end
89
+
90
+ ## bulma vertical file input
91
+ config.wrappers :vertical_file, tag: 'div', class: 'file' do |b|
92
+ b.use :html5
93
+ b.optional :readonly
94
+ b.use :input, class: 'file-input', wrap_with: { tag: 'label', class: 'file-label' }
95
+ b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
96
+ b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
97
+ end
98
+
99
+ ## bulma vertical multi select
100
+ config.wrappers :vertical_multi_select, tag: 'div', class: 'field' do |b|
101
+ b.use :html5
102
+ b.optional :readonly
103
+ b.use :label, class: 'label'
104
+ b.wrapper tag: 'div', class: 'control' do |ba|
105
+ ba.use :input, class: 'input', error_class: 'is-danger', valid_class: 'is-success'
106
+ end
107
+ b.use :full_error, wrap_with: { tag: 'div', class: 'is-danger' }
108
+ b.use :hint, wrap_with: { tag: 'small', class: 'help' }
109
+ end
110
+
111
+ # The default wrapper to be used by the FormBuilder.
112
+ config.default_wrapper = :vertical_form
113
+
114
+ # Custom wrappers for input types. This should be a hash containing an input
115
+ # type as key and the wrapper that will be used for all inputs with specified type.
116
+ config.wrapper_mappings = {
117
+ boolean: :vertical_boolean,
118
+ check_boxes: :vertical_collection,
119
+ date: :vertical_multi_select,
120
+ datetime: :vertical_multi_select,
121
+ file: :vertical_file,
122
+ radio_buttons: :vertical_collection,
123
+ range: :vertical_range,
124
+ time: :vertical_multi_select
125
+ }
126
+ end
@@ -0,0 +1,7 @@
1
+ module SimpleForm
2
+ module Bulma
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace SimpleForm::Bulma
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module SimpleForm
2
+ module Bulma
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require 'simple_form/bulma/version'
2
+ require 'simple_form/bulma/engine'
3
+
4
+ require 'simple_form'
5
+
6
+ module SimpleForm
7
+ module Bulma
8
+ # Your code goes here...
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :simple_form_bulma do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_form-bulma
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Juan Vasquez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-06-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.7
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.1.7.7
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 6.1.7
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.1.7.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: simple_form
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 5.3.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 5.3.0
47
+ description: This is going to help you to use Bulma CSS Framework with SimpleForm.
48
+ email:
49
+ - simple_form-bulma@juanvasquez.dev
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - app/assets/config/simple_form_bulma_manifest.js
58
+ - app/assets/stylesheets/simple_form/bulma/application.css
59
+ - app/controllers/simple_form/bulma/application_controller.rb
60
+ - app/controllers/simple_form/bulma/items_controller.rb
61
+ - app/helpers/simple_form/bulma/application_helper.rb
62
+ - app/jobs/simple_form/bulma/application_job.rb
63
+ - app/mailers/simple_form/bulma/application_mailer.rb
64
+ - app/models/simple_form/bulma/application_record.rb
65
+ - app/models/simple_form/bulma/item.rb
66
+ - app/views/layouts/simple_form/bulma/application.html.erb
67
+ - app/views/simple_form/bulma/items/_form.html.erb
68
+ - app/views/simple_form/bulma/items/index.html.erb
69
+ - app/views/simple_form/bulma/items/new.html.erb
70
+ - config/initializers/simple_form.rb
71
+ - config/initializers/simple_form_bulma.rb
72
+ - config/locales/simple_form.en.yml
73
+ - config/routes.rb
74
+ - lib/generators/simple_form/bulma/USAGE
75
+ - lib/generators/simple_form/bulma/install_generator.rb
76
+ - lib/generators/simple_form/bulma/templates/config/initializers/simple_form_bulma.rb
77
+ - lib/simple_form/bulma.rb
78
+ - lib/simple_form/bulma/engine.rb
79
+ - lib/simple_form/bulma/version.rb
80
+ - lib/tasks/simple_form/bulma_tasks.rake
81
+ homepage: https://github.com/juanvqz/simple_form-bulma
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ allowed_push_host: https://rubygems.org
86
+ homepage_uri: https://github.com/juanvqz/simple_form-bulma
87
+ source_code_uri: https://github.com/juanvqz/simple_form-bulma
88
+ changelog_uri: https://github.com/juanvqz/simple_form-bulma/blob/main/CHANGELOG.md
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: 2.6.0
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubygems_version: 3.2.3
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: SimpleForm Theme for Bulma CSS Framework
108
+ test_files: []