simple_form-theme 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -6
- data/config/initializers/simple_form.rb +176 -0
- data/lib/generators/simple_form/theme/bulma/USAGE +8 -0
- data/lib/generators/simple_form/theme/bulma/bulma_generator.rb +10 -0
- data/lib/generators/simple_form/theme/bulma/templates/config/initializers/simple_form_bulma.rb +126 -0
- data/lib/generators/simple_form/theme/tailwind/USAGE +8 -0
- data/lib/generators/simple_form/theme/tailwind/tailwind_generator.rb +10 -0
- data/lib/generators/simple_form/theme/tailwind/templates/config/initializers/simple_form_tailwindcss.rb +161 -0
- data/lib/simple_form/theme/version.rb +1 -1
- data/lib/simple_form/theme.rb +7 -2
- metadata +10 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d934b32592b1a73bb0bc657301447d61a96ec793002ee096e700b176000120d
|
|
4
|
+
data.tar.gz: 3a7dcde3dea07205f7f4542d68061fca65f696ebe41c17eab3c059fb1029b8e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4cfd8957eb26b23fa26fd3d981c28d08f21c3c9b7955feac799380f1a2f9421d8b9723c160e124544fa88f5902eb52eb237ffa91a8a0e98a476530a825c76d4c
|
|
7
|
+
data.tar.gz: b49bffcde5d65de881e966d0c36da9fc953ac0c09b451d517151a05fe40d7f9a23b48b7b0bc7488382395f8ec4b0899bab5742ac54ba393c123d15bef256d8b8
|
data/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
[](https://badge.fury.io/rb/simple_form-theme)
|
|
2
|
+
|
|
1
3
|
# SimpleForm::Theme
|
|
2
4
|
Short description and motivation.
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
### Supported CSS Frameworks
|
|
7
|
+
* [Tailwind CSS](https://tailwindcss.com/docs/installation)
|
|
8
|
+
* [Bulma](https://bulma.io/documentation/start/installation)
|
|
6
9
|
|
|
7
10
|
## Installation
|
|
8
11
|
Add this line to your application's Gemfile:
|
|
@@ -13,16 +16,40 @@ gem 'simple_form-theme'
|
|
|
13
16
|
|
|
14
17
|
And then execute:
|
|
15
18
|
```bash
|
|
16
|
-
|
|
19
|
+
bundle
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
As an alternative instead of adding an additional dependency to your project,
|
|
23
|
+
you can copy the initializer file to your project from the GitHub repository.
|
|
24
|
+
|
|
25
|
+
Example:
|
|
26
|
+
```bash
|
|
27
|
+
cp lib/generators/simple_form/theme/templates/config/initializers/simple_form_tailwindcss.rb yourapp/config/initializers/simple_form_tailwindcss.rb
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
However, if you install the gem, you will get the latest updates and improvements.
|
|
31
|
+
|
|
32
|
+
## Requirements
|
|
33
|
+
|
|
34
|
+
* Make sure you have installed [simple_form](https://github.com/heartcombo/simple_form) gem.
|
|
35
|
+
* Make sure you have installed the decired css framework.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Install Tailwind CSS initializer
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bin/rails generate simple_form:theme:tailwind install
|
|
17
43
|
```
|
|
18
44
|
|
|
19
|
-
|
|
45
|
+
### Install Bulma CSS initializer
|
|
46
|
+
|
|
20
47
|
```bash
|
|
21
|
-
|
|
48
|
+
bin/rails generate simple_form:theme:bulma install
|
|
22
49
|
```
|
|
23
50
|
|
|
24
51
|
## Contributing
|
|
25
|
-
|
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/JuanVqz/simple_form-theme
|
|
26
53
|
|
|
27
54
|
## License
|
|
28
55
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -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,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class SimpleForm::Theme::BulmaGenerator < Rails::Generators::NamedBase
|
|
4
|
+
source_root File.expand_path('templates', __dir__)
|
|
5
|
+
|
|
6
|
+
desc 'Copy the bulma initializer file for simple_form'
|
|
7
|
+
def copy_initializer_file
|
|
8
|
+
template 'config/initializers/simple_form_bulma.rb', 'config/initializers/simple_form_bulma.rb'
|
|
9
|
+
end
|
|
10
|
+
end
|
data/lib/generators/simple_form/theme/bulma/templates/config/initializers/simple_form_bulma.rb
ADDED
|
@@ -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 = ->(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,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class SimpleForm::Theme::TailwindGenerator < Rails::Generators::NamedBase
|
|
4
|
+
source_root File.expand_path('templates', __dir__)
|
|
5
|
+
|
|
6
|
+
desc 'Copy the tailwindcss initializer file for simple_form'
|
|
7
|
+
def copy_initializer_file
|
|
8
|
+
template 'config/initializers/simple_form_tailwindcss.rb', 'config/initializers/simple_form_tailwindcss.rb'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Use this setup block to configure all options available in SimpleForm.
|
|
4
|
+
SimpleForm.setup do |config|
|
|
5
|
+
config.wrappers :vertical_form, tag: :div, class: 'mb-4' do |b|
|
|
6
|
+
b.use :html5
|
|
7
|
+
b.use :placeholder
|
|
8
|
+
b.optional :maxlength
|
|
9
|
+
b.optional :minlength
|
|
10
|
+
b.optional :pattern
|
|
11
|
+
b.optional :min_max
|
|
12
|
+
b.optional :readonly
|
|
13
|
+
b.use :label, class: 'block mb-2 text-sm font-medium text-gray-900 dark:text-white'
|
|
14
|
+
b.use :input,
|
|
15
|
+
class: 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500',
|
|
16
|
+
error_class: 'bg-red-50 border-red-500 text-red-900 placeholder-red-700 focus:ring-red-500 dark:bg-gray-700 focus:border-red-500 dark:text-red-500 dark:placeholder-red-500 dark:border-red-500',
|
|
17
|
+
valid_class: 'bg-green-50 border-green-500 text-green-900 dark:text-green-400 placeholder-green-700 dark:placeholder-green-500 focus:ring-green-500 focus:border-green-500 dark:bg-gray-700 dark:border-green-500'
|
|
18
|
+
b.use :full_error, wrap_with: { tag: :p, class: 'mt-2 text-sm text-red-600 dark:text-red-600' }
|
|
19
|
+
b.use :hint, wrap_with: { tag: :small, class: 'text-sm text-gray-400 dark:text-gray-400' }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# vertical input for radio buttons and check boxes
|
|
23
|
+
config.wrappers :vertical_collection, item_wrapper_class: 'form-check',
|
|
24
|
+
item_label_class: 'form-check-label',
|
|
25
|
+
tag: :fieldset,
|
|
26
|
+
class: 'form-group mb-3',
|
|
27
|
+
error_class: 'form-group-invalid',
|
|
28
|
+
valid_class: 'form-group-valid' do |b|
|
|
29
|
+
b.use :html5
|
|
30
|
+
b.optional :readonly
|
|
31
|
+
b.wrapper :legend_tag, tag: :legend, class: 'col-form-label pt-0' do |ba|
|
|
32
|
+
ba.use :label_text, class: 'ml-3 block text-sm font-medium text-gray-700'
|
|
33
|
+
end
|
|
34
|
+
b.use :input, class: 'focus:ring-indigo-500 h-4 w-4 text-sky-600 border-gray-300 mr-2',
|
|
35
|
+
error_class: 'is-invalid border-red-400',
|
|
36
|
+
valid_class: 'is-valid'
|
|
37
|
+
b.use :full_error, wrap_with: { tag: :p, class: 'mt-2 text-sm text-red-600 dark:text-red-600' }
|
|
38
|
+
b.use :hint, wrap_with: { tag: :small, class: 'text-gray-400' }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# vertical input for radio buttons and check boxes
|
|
42
|
+
# config.wrappers :vertical_check_boxes_collection, item_wrapper_class: 'form-check',
|
|
43
|
+
# item_label_class: 'form-check-label',
|
|
44
|
+
# tag: 'fieldset', class: 'form-group mb-3',
|
|
45
|
+
# error_class: 'form-group-invalid',
|
|
46
|
+
# valid_class: 'form-group-valid' do |b|
|
|
47
|
+
# b.use :html5
|
|
48
|
+
# b.optional :readonly
|
|
49
|
+
# b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
|
|
50
|
+
# ba.use :label_text, class: 'ml-3 block text-sm font-medium text-gray-700'
|
|
51
|
+
# end
|
|
52
|
+
# b.use :input, class: 'focus:ring-indigo-500 h-4 w-4 text-sky-600 border-gray-300 rounded mr-2',
|
|
53
|
+
# error_class: 'is-invalid border-red-400',
|
|
54
|
+
# valid_class: 'is-valid'
|
|
55
|
+
# b.use :full_error, wrap_with: {tag: :p, class: "mt-2 text-sm text-red-600 dark:text-red-600"}
|
|
56
|
+
# b.use :hint, wrap_with: { tag: :small, class: 'text-gray-400' }
|
|
57
|
+
# end
|
|
58
|
+
|
|
59
|
+
# horizontal input for inline radio buttons and check boxes
|
|
60
|
+
config.wrappers :horizontal_collection_inline, item_wrapper_class: 'form-check form-check-inline',
|
|
61
|
+
item_label_class: 'form-check-label',
|
|
62
|
+
tag: :div,
|
|
63
|
+
class: 'form-group flex flex-row-reverse w-fit mb-3',
|
|
64
|
+
error_class: 'form-group-invalid',
|
|
65
|
+
valid_class: 'form-group-valid' do |b|
|
|
66
|
+
b.use :html5
|
|
67
|
+
b.optional :readonly
|
|
68
|
+
b.use :label, class: 'pt-0 mb-2'
|
|
69
|
+
b.wrapper :grid_wrapper, tag: :div do |ba|
|
|
70
|
+
ba.use :input, class: 'focus:ring-indigo-500 h-4 w-4 text-sky-600 border-gray-300 rounded mr-2',
|
|
71
|
+
error_class: 'is-invalid', valid_class: 'is-valid'
|
|
72
|
+
ba.use :full_error, wrap_with: { tag: :p, class: 'mt-2 text-sm text-red-600 dark:text-red-600' }
|
|
73
|
+
ba.use :hint, wrap_with: { tag: :small, class: 'text-gray-400' }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# vertical multi select
|
|
78
|
+
config.wrappers :vertical_multi_select, tag: :div, class: 'mb-4' do |b|
|
|
79
|
+
b.use :html5
|
|
80
|
+
b.optional :readonly
|
|
81
|
+
b.use :label, class: 'block mb-2 text-sm font-medium text-gray-900 dark:text-white'
|
|
82
|
+
b.wrapper tag: :div, class: 'flex flex-col md:flex-row gap-1 justify-between items-center' do |ba|
|
|
83
|
+
ba.use :input,
|
|
84
|
+
class: 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500',
|
|
85
|
+
error_class: 'bg-red-50 border-red-500 text-red-900 placeholder-red-700 focus:ring-red-500 dark:bg-gray-700 focus:border-red-500 dark:text-red-500 dark:placeholder-red-500 dark:border-red-500',
|
|
86
|
+
valid_class: 'bg-green-50 border-green-500 text-green-900 dark:text-green-400 placeholder-green-700 dark:placeholder-green-500 focus:ring-green-500 focus:border-green-500 dark:bg-gray-700 dark:border-green-500'
|
|
87
|
+
end
|
|
88
|
+
b.use :full_error, wrap_with: { tag: :p, class: 'mt-2 text-sm text-red-600 dark:text-red-600' }
|
|
89
|
+
b.use :hint, wrap_with: { tag: :small, class: 'text-gray-400' }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# vertical input for boolean
|
|
93
|
+
config.wrappers :vertical_boolean, tag: :fieldset, class: 'mb-3',
|
|
94
|
+
error_class: 'form-group-invalid',
|
|
95
|
+
valid_class: 'form-group-valid' do |b|
|
|
96
|
+
b.use :html5
|
|
97
|
+
b.optional :readonly
|
|
98
|
+
b.wrapper :form_check_wrapper, tag: 'div' do |bb|
|
|
99
|
+
bb.use :input, class: 'focus:ring-indigo-500 h-4 w-4 text-sky-600 border-gray-300 rounded mr-2',
|
|
100
|
+
error_class: '!border-red-500',
|
|
101
|
+
valid_class: 'is-valid'
|
|
102
|
+
bb.use :label, class: 'mb-2'
|
|
103
|
+
end
|
|
104
|
+
b.use :full_error, wrap_with: { tag: :p, class: 'mt-2 text-sm text-red-600 dark:text-red-600' }
|
|
105
|
+
b.use :hint, wrap_with: { tag: :small, class: 'text-gray-400' }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# vertical file input
|
|
109
|
+
config.wrappers :vertical_file, tag: :div, class: 'mb-4' do |b|
|
|
110
|
+
b.use :html5
|
|
111
|
+
b.use :placeholder
|
|
112
|
+
b.optional :maxlength
|
|
113
|
+
b.optional :minlength
|
|
114
|
+
b.optional :readonly
|
|
115
|
+
b.use :label, class: 'block mb-2 text-sm font-medium text-gray-900 dark:text-white'
|
|
116
|
+
b.use :input,
|
|
117
|
+
class: 'block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400',
|
|
118
|
+
error_class: 'bg-red-50 border-red-500 text-red-900 placeholder-red-700 focus:ring-red-500 dark:bg-gray-700 focus:border-red-500 dark:text-red-500 dark:placeholder-red-500 dark:border-red-500',
|
|
119
|
+
valid_class: 'bg-green-50 border-green-500 text-green-900 dark:text-green-400 placeholder-green-700 dark:placeholder-green-500 focus:ring-green-500 focus:border-green-500 dark:bg-gray-700 dark:border-green-500'
|
|
120
|
+
b.use :full_error, wrap_with: { tag: :p, class: 'mt-2 text-sm text-red-600 dark:text-red-600' }
|
|
121
|
+
b.use :hint, wrap_with: { tag: :small, class: 'text-sm text-gray-400 dark:text-gray-400' }
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
|
125
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
|
126
|
+
config.wrapper_mappings = {
|
|
127
|
+
boolean: :vertical_boolean,
|
|
128
|
+
check_boxes: :vertical_collection,
|
|
129
|
+
date: :vertical_multi_select,
|
|
130
|
+
file: :vertical_file,
|
|
131
|
+
datetime: :vertical_multi_select,
|
|
132
|
+
radio_buttons: :vertical_collection,
|
|
133
|
+
time: :vertical_multi_select
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# How the label text should be generated altogether with the required text.
|
|
137
|
+
config.label_text = ->(label, required, _explicit_label) { "#{label} #{required}" }
|
|
138
|
+
|
|
139
|
+
# CSS class for buttons
|
|
140
|
+
config.button_class = 'text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800'
|
|
141
|
+
|
|
142
|
+
# Set this to div to make the checkbox and radio properly work
|
|
143
|
+
# otherwise simple_form adds a label tag instead of a div around
|
|
144
|
+
# the nested label
|
|
145
|
+
config.item_wrapper_tag = :div
|
|
146
|
+
|
|
147
|
+
# CSS class to add for error notification helper.
|
|
148
|
+
config.error_notification_class = 'bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded'
|
|
149
|
+
|
|
150
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
|
151
|
+
# :first lists the first message for each field.
|
|
152
|
+
# :to_sentence to list all errors for each field.
|
|
153
|
+
config.error_method = :to_sentence
|
|
154
|
+
|
|
155
|
+
# The default wrapper to be used by the FormBuilder.
|
|
156
|
+
config.default_wrapper = :vertical_form
|
|
157
|
+
|
|
158
|
+
# add validation classes to `input_field`
|
|
159
|
+
config.input_field_error_class = 'bg-red-50'
|
|
160
|
+
config.input_field_valid_class = 'bg-green-50'
|
|
161
|
+
end
|
data/lib/simple_form/theme.rb
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'simple_form/theme/version'
|
|
4
|
+
require 'simple_form/theme/engine'
|
|
5
|
+
|
|
6
|
+
require 'simple_form'
|
|
3
7
|
|
|
4
8
|
module SimpleForm
|
|
9
|
+
# SimpleFormTheme
|
|
5
10
|
module Theme
|
|
6
11
|
# Your code goes here...
|
|
7
12
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_form-theme
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Vasquez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-06
|
|
11
|
+
date: 2024-07-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -62,7 +62,14 @@ files:
|
|
|
62
62
|
- app/mailers/simple_form/theme/application_mailer.rb
|
|
63
63
|
- app/models/simple_form/theme/application_record.rb
|
|
64
64
|
- app/views/layouts/simple_form/theme/application.html.erb
|
|
65
|
+
- config/initializers/simple_form.rb
|
|
65
66
|
- config/routes.rb
|
|
67
|
+
- lib/generators/simple_form/theme/bulma/USAGE
|
|
68
|
+
- lib/generators/simple_form/theme/bulma/bulma_generator.rb
|
|
69
|
+
- lib/generators/simple_form/theme/bulma/templates/config/initializers/simple_form_bulma.rb
|
|
70
|
+
- lib/generators/simple_form/theme/tailwind/USAGE
|
|
71
|
+
- lib/generators/simple_form/theme/tailwind/tailwind_generator.rb
|
|
72
|
+
- lib/generators/simple_form/theme/tailwind/templates/config/initializers/simple_form_tailwindcss.rb
|
|
66
73
|
- lib/simple_form/theme.rb
|
|
67
74
|
- lib/simple_form/theme/engine.rb
|
|
68
75
|
- lib/simple_form/theme/version.rb
|
|
@@ -89,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
89
96
|
- !ruby/object:Gem::Version
|
|
90
97
|
version: '0'
|
|
91
98
|
requirements: []
|
|
92
|
-
rubygems_version: 3.
|
|
99
|
+
rubygems_version: 3.1.6
|
|
93
100
|
signing_key:
|
|
94
101
|
specification_version: 4
|
|
95
102
|
summary: The most modern themes for SimpleForm gem.
|