simple_form-theme 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -2
- data/config/initializers/simple_form.rb +176 -0
- data/lib/generators/simple_form/theme/tailwind/USAGE +2 -4
- data/lib/generators/simple_form/theme/tailwind/tailwind_generator.rb +21 -2
- data/lib/generators/simple_form/theme/tailwind/templates/config/locales/simple_form_tailwind.en.yml +6 -0
- data/lib/simple_form/theme/version.rb +1 -1
- data/lib/simple_form/theme.rb +7 -2
- metadata +15 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e9ef112e8336bcefad7f46954411a7aa154bca3b05886aed6420e322818ead4
|
4
|
+
data.tar.gz: 0e7bf9b15e1ec7674bdd266bc1b0bde0d10f10338111cf48344981d8423ffccc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a5b0bf8a3e6db84204c357e383a19375251b001055797aaf2196a20e14d43a557e016cf2161f69355a65b59efdf3785ac2a7a2e0aff011b9d9d24f50bebdec9
|
7
|
+
data.tar.gz: 1e0cfb0ce5820477683b9aa4915949e8c0ca992e610a1339b10dbbaa6162c3add99c68c65e71ed9ecefad1a7c6472e33bf049af4a3efeed1568141eaf0a2816f
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/simple_form-theme.svg)](https://badge.fury.io/rb/simple_form-theme)
|
2
|
+
|
1
3
|
# SimpleForm::Theme
|
2
4
|
Short description and motivation.
|
3
5
|
|
@@ -34,13 +36,31 @@ However, if you install the gem, you will get the latest updates and improvement
|
|
34
36
|
|
35
37
|
## Usage
|
36
38
|
|
37
|
-
### Install Tailwind CSS
|
39
|
+
### Install Tailwind CSS files
|
38
40
|
|
39
41
|
```bash
|
40
42
|
bin/rails generate simple_form:theme:tailwind install
|
41
43
|
```
|
42
44
|
|
43
|
-
|
45
|
+
After running this generator, you will see the `config/initializers/simple_form_tailwindcss.rb` file.
|
46
|
+
This file adds the Tailwind CSS styles to your application.
|
47
|
+
Additionally, the `config/locales/simple_form_tailwind.en.yml` file will add the "required" mark to the required fields.
|
48
|
+
However, you need to communicate Tailwind to "watch" those files by adding the following configuration:
|
49
|
+
|
50
|
+
```js
|
51
|
+
# tailwind.config.js
|
52
|
+
|
53
|
+
module.exports = {
|
54
|
+
...
|
55
|
+
content: [
|
56
|
+
'./config/initializers/simple_form_tailwindcss.rb',
|
57
|
+
'./config/locales/simple_form*.yml',
|
58
|
+
...
|
59
|
+
],
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
63
|
+
### Install Bulma CSS files
|
44
64
|
|
45
65
|
```bash
|
46
66
|
bin/rails generate simple_form:theme:bulma install
|
@@ -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
|
@@ -3,8 +3,27 @@
|
|
3
3
|
class SimpleForm::Theme::TailwindGenerator < Rails::Generators::NamedBase
|
4
4
|
source_root File.expand_path('templates', __dir__)
|
5
5
|
|
6
|
-
desc 'Copy the tailwindcss
|
7
|
-
def
|
6
|
+
desc 'Copy the tailwindcss files for simple_form'
|
7
|
+
def generate
|
8
|
+
install if install?
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def install
|
14
|
+
copy_initializers
|
15
|
+
copy_locales
|
16
|
+
end
|
17
|
+
|
18
|
+
def install?
|
19
|
+
name == 'install'
|
20
|
+
end
|
21
|
+
|
22
|
+
def copy_initializers
|
8
23
|
template 'config/initializers/simple_form_tailwindcss.rb', 'config/initializers/simple_form_tailwindcss.rb'
|
9
24
|
end
|
25
|
+
|
26
|
+
def copy_locales
|
27
|
+
directory 'config/locales'
|
28
|
+
end
|
10
29
|
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,35 +1,35 @@
|
|
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.3
|
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-
|
11
|
+
date: 2024-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 6.1.7
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 6.
|
19
|
+
version: '6.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 6.1.7
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: 6.
|
29
|
+
version: '6.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: simple_form
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,6 +62,7 @@ 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
|
66
67
|
- lib/generators/simple_form/theme/bulma/USAGE
|
67
68
|
- lib/generators/simple_form/theme/bulma/bulma_generator.rb
|
@@ -69,6 +70,7 @@ files:
|
|
69
70
|
- lib/generators/simple_form/theme/tailwind/USAGE
|
70
71
|
- lib/generators/simple_form/theme/tailwind/tailwind_generator.rb
|
71
72
|
- lib/generators/simple_form/theme/tailwind/templates/config/initializers/simple_form_tailwindcss.rb
|
73
|
+
- lib/generators/simple_form/theme/tailwind/templates/config/locales/simple_form_tailwind.en.yml
|
72
74
|
- lib/simple_form/theme.rb
|
73
75
|
- lib/simple_form/theme/engine.rb
|
74
76
|
- lib/simple_form/theme/version.rb
|
@@ -89,6 +91,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
91
|
- - ">="
|
90
92
|
- !ruby/object:Gem::Version
|
91
93
|
version: 2.6.0
|
94
|
+
- - "<"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.1'
|
92
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
98
|
requirements:
|
94
99
|
- - ">="
|