simple_form-tailwind 0.1.2 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2399719b0970ee061cc46ab22c6a53dda1e54906d865f36f39ede5c2573d1c96
4
- data.tar.gz: 2590b3c970d827319de99f6e9b27343ca3517902e22249d99c8e36ef02a89907
3
+ metadata.gz: c22ded5d6274d290520ed422df31a3f876ecc55efd2ad244c5fc79331f1f2d38
4
+ data.tar.gz: b903d2af76a8070ac79a574883564da189725c5621bc7e0ea97665d52756f022
5
5
  SHA512:
6
- metadata.gz: 61101424ceea3305056a6c54f30ed5801a7b850e25fd2b2fb11e19435ef4a67203e787b92896283546bde6255d2321fa3aac2656fd42e2d4e641fdf083e0b7be
7
- data.tar.gz: 17f267933c59f1d8540a5d3943ffedb1103c269d0007cf9891868f5489bc7896c3b5d5005655f45078ddae0ffb97b1166b8c69402e9be685fa25da79572aa79b
6
+ metadata.gz: 7ca518f967a62b4c6e2692e44ab169d409b1eff70ffa2f6ec6ebb9785783c085c79ae7bb890afd45e8fdcb8dcd8e05dabeb6cb2fc7707fe703085f4d0d26ce61
7
+ data.tar.gz: 358522dbdd2ff3f2e7ac78a773fb55b477b7c6d510b42cfdce63ddcd71274959a7835c57bded9f9395531d54ef04d566820b53827d0c2976622c20bddeeb26ee
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.0] - 2024-04-09
9
+
10
+ * Compatibility with Rails 8 and Tailwind CSS 4
11
+ * Updated installer for the new Tailwind CSS installation method
12
+ * Removed dependency on tailwind.config.js file
13
+ * Added new wrappers for date, time, datetime fields, etc.
14
+ * Fixed color classes (grey -> gray)
15
+ * Improved documentation
8
16
 
9
17
  ## [0.1.1] - 2020-12-30
10
18
 
@@ -12,4 +20,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
20
 
13
21
  ## [0.0.1] - 2020-11-29
14
22
 
15
- * Initia Commit
23
+ * Initial Commit
data/README.md CHANGED
@@ -1,8 +1,18 @@
1
1
  # SimpleForm::Tailwind
2
2
 
3
- Used to add a base [simple_form](https://github.com/heartcombo/simple_form) config with basic tailwind classes added to the form attributes.
3
+ Used to add a base [simple_form](https://github.com/heartcombo/simple_form) configuration with Tailwind CSS classes for form attributes.
4
4
 
5
- **NOTE:** This simple_form config is best used with tailwindCSS `v2.0`
5
+ **NOTE:** This simple_form configuration is optimized for Rails 7> and Tailwind CSS 4.
6
+
7
+ ## Prerequisites
8
+
9
+ Before installing this gem, make sure you have installed Tailwind CSS in your Rails application:
10
+
11
+ ```bash
12
+ ./bin/bundle add tailwindcss-ruby
13
+ ./bin/bundle add tailwindcss-rails
14
+ ./bin/rails tailwindcss:install
15
+ ```
6
16
 
7
17
  ## Installation
8
18
 
@@ -12,7 +22,7 @@ Add this line to your application's Gemfile:
12
22
  gem 'simple_form-tailwind'
13
23
  ```
14
24
 
15
- And then execute:
25
+ Then execute:
16
26
 
17
27
  $ bundle install
18
28
 
@@ -22,8 +32,8 @@ Or install it yourself as:
22
32
 
23
33
  ## Usage
24
34
 
25
- To use this simple_form config you need to ensure your application is using simple_form to generate it's forms.
26
- Run the generator to add the following file to your application `config/initializers/simple_form_tailwind.rb`
35
+ To use this simple_form configuration, you need to ensure that your application uses simple_form to generate its forms.
36
+ Run the generator to add the following file to your application `config/initializers/simple_form_tailwind.rb`:
27
37
 
28
38
  $ rails g simple_form:tailwind:install
29
39
 
@@ -31,7 +41,6 @@ Run the generator to add the following file to your application `config/initiali
31
41
 
32
42
  Bug reports and pull requests are welcome on GitHub at https://github.com/tarellel/simple_form-tailwind.
33
43
 
34
-
35
44
  ## License
36
45
 
37
46
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -8,26 +8,18 @@ module SimpleForm
8
8
  desc 'Generate a SimpleForm config for tailwind based forms'
9
9
  source_root File.expand_path('templates', __dir__)
10
10
 
11
- def update_tailwind_config
12
- # Open the tailwind.config.js file
13
- config_path = Rails.root.join('config/tailwind.config.js')
14
- if File.exist?(config_path)
15
- # Read the existing file
16
- config = File.read(config_path)
17
- # Add the line in the content section if it's not already there
18
- if config.include?('./config/initializers')
19
- say 'tailwind.config.js already includes the necessary configuration.', :green
20
- else
21
- config.sub!('content: [', "content: [\n \"./config/initializers/*.rb\",")
22
- # save modifications
23
- File.write(config_path, config)
24
- say 'tailwind.config.js has been updated with the necessary configuration.', :green
25
- end
26
- else
27
- say 'tailwind.config.js not found.', :red
28
- say 'Please ensure Tailwind is properly installed and try again.', :yellow
11
+ def check_tailwind_installation
12
+ # Check if tailwindcss-rails is installed
13
+ unless File.exist?(Rails.root.join('app/assets/stylesheets/application.css'))
14
+ say 'Tailwind CSS is not properly installed.', :red
15
+ say 'Please install Tailwind CSS with the following commands:', :yellow
16
+ say ' ./bin/bundle add tailwindcss-ruby', :yellow
17
+ say ' ./bin/bundle add tailwindcss-rails', :yellow
18
+ say ' ./bin/rails tailwindcss:install', :yellow
29
19
  exit # Cancel installation
30
20
  end
21
+
22
+ say 'Tailwind CSS is properly installed.', :green
31
23
  end
32
24
 
33
25
  def copy_initialzier
@@ -49,7 +49,7 @@ SimpleForm.setup do |config|
49
49
  b.use :input,
50
50
  class: 'shadow appearance-none border border-gray-300 rounded w-full py-2 px-3 bg-white focus:outline-none focus:ring-0 focus:border-blue-500 text-gray-400 leading-6 transition-colors duration-200 ease-in-out', error_class: 'border-red-500', valid_class: 'border-green-400'
51
51
  b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
52
- b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-grey-700 text-xs italic' }
52
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
53
53
  end
54
54
 
55
55
  # vertical input for boolean (aka checkboxes)
@@ -62,7 +62,7 @@ SimpleForm.setup do |config|
62
62
  end
63
63
  b.wrapper tag: 'div', class: 'ml-3 text-sm' do |bb|
64
64
  bb.use :label, class: 'block', error_class: 'text-red-500'
65
- bb.use :hint, wrap_with: { tag: 'p', class: 'block text-grey-700 text-xs italic' }
65
+ bb.use :hint, wrap_with: { tag: 'p', class: 'block text-gray-700 text-xs italic' }
66
66
  bb.use :full_error, wrap_with: { tag: 'p', class: 'block text-red-500 text-xs italic' }
67
67
  end
68
68
  end
@@ -79,7 +79,7 @@ SimpleForm.setup do |config|
79
79
  b.use :input,
80
80
  class: 'focus:ring-2 focus:ring-indigo-500 ring-offset-2 h-4 w-4 text-indigo-600 border-gray-300 rounded', error_class: 'text-red-500', valid_class: 'text-green-400'
81
81
  b.use :full_error, wrap_with: { tag: 'p', class: 'block mt-2 text-red-500 text-xs italic' }
82
- b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-grey-700 text-xs italic' }
82
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
83
83
  end
84
84
 
85
85
  # vertical file input
@@ -93,55 +93,98 @@ SimpleForm.setup do |config|
93
93
  b.use :input, class: 'w-full text-gray-500 px-3 py-2 border rounded', error_class: 'text-red-500 border-red-500',
94
94
  valid_class: 'text-green-400'
95
95
  b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
96
- b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-grey-700 text-xs italic' }
96
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
97
97
  end
98
98
 
99
99
  # vertical multi select
100
100
  config.wrappers :vertical_multi_select, tag: 'div', class: 'my-4', error_class: 'f', valid_class: '' do |b|
101
101
  b.use :html5
102
102
  b.optional :readonly
103
- b.wrapper :legend_tag, tag: 'legend', class: 'text-sm font-medium text-gray-600',
104
- error_class: 'text-red-500' do |ba|
105
- ba.use :label_text
106
- end
103
+ b.use :label, class: 'text-sm font-medium text-gray-600 block', error_class: 'text-red-500'
107
104
  b.wrapper tag: 'div', class: 'inline-flex space-x-1' do |ba|
108
- # ba.use :input, class: 'flex w-auto w-auto text-gray-500 text-sm border-gray-300 rounded p-2', error_class: 'text-red-500', valid_class: 'text-green-400'
109
- ba.use :input,
110
- class: 'flex w-auto w-auto shadow appearance-none border border-gray-300 rounded w-full p-2 bg-white focus:outline-none focus:border-blue-500 text-gray-400 leading-4 transition-colors duration-200 ease-in-out'
105
+ ba.use :input, class: 'flex-grow', error_class: 'text-red-500', valid_class: 'text-green-400'
111
106
  end
112
107
  b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
113
- b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-grey-700 text-xs italic' }
108
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
114
109
  end
115
110
 
116
- # vertical range input
117
- config.wrappers :vertical_range, tag: 'div', class: 'my-4', error_class: 'text-red-500',
118
- valid_class: 'text-green-400' do |b|
111
+ # vertical date input
112
+ config.wrappers :vertical_date, tag: 'div', class: 'my-4', error_class: 'f', valid_class: '' do |b|
113
+ b.use :html5
114
+ b.optional :readonly
115
+ b.use :label, class: 'text-sm font-medium text-gray-600 block', error_class: 'text-red-500'
116
+ b.use :input, class: 'mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm', error_class: 'text-red-500', valid_class: 'text-green-400'
117
+ b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
118
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
119
+ end
120
+
121
+ # vertical time input
122
+ config.wrappers :vertical_time, tag: 'div', class: 'my-4', error_class: 'f', valid_class: '' do |b|
123
+ b.use :html5
124
+ b.optional :readonly
125
+ b.use :label, class: 'text-sm font-medium text-gray-600 block', error_class: 'text-red-500'
126
+ b.use :input, class: 'mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm', error_class: 'text-red-500', valid_class: 'text-green-400'
127
+ b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
128
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
129
+ end
130
+
131
+ # vertical date time
132
+ config.wrappers :vertical_datetime, tag: 'div', class: 'my-4', error_class: 'f', valid_class: '' do |b|
133
+ b.use :html5
134
+ b.optional :readonly
135
+ b.use :label, class: 'text-sm font-medium text-gray-600 block', error_class: 'text-red-500'
136
+ b.use :input, class: 'mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm', error_class: 'text-red-500', valid_class: 'text-green-400'
137
+ b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
138
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
139
+ end
140
+
141
+ # vertical date time zone
142
+ config.wrappers :vertical_datetime_local, tag: 'div', class: 'my-4', error_class: 'f', valid_class: '' do |b|
143
+ b.use :html5
144
+ b.optional :readonly
145
+ b.use :label, class: 'text-sm font-medium text-gray-600 block', error_class: 'text-red-500'
146
+ b.use :input, class: 'mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm', error_class: 'text-red-500', valid_class: 'text-green-400'
147
+ b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
148
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
149
+ end
150
+
151
+ # vertical select
152
+ config.wrappers :vertical_select, tag: 'div', class: 'my-4', error_class: 'f', valid_class: '' do |b|
153
+ b.use :html5
154
+ b.optional :readonly
155
+ b.use :label, class: 'text-sm font-medium text-gray-600 block', error_class: 'text-red-500'
156
+ b.use :input, class: 'mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm', error_class: 'text-red-500', valid_class: 'text-green-400'
157
+ b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
158
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
159
+ end
160
+
161
+ # vertical range
162
+ config.wrappers :vertical_range, tag: 'div', class: 'my-4', error_class: 'f', valid_class: '' do |b|
119
163
  b.use :html5
120
- b.use :placeholder
121
164
  b.optional :readonly
122
165
  b.optional :step
123
166
  b.use :label, class: 'text-sm font-medium text-gray-600 block', error_class: 'text-red-500'
124
- b.wrapper tag: 'div', class: 'flex items-center h-5' do |ba|
125
- ba.use :input, class: 'rounded-lg overflow-hidden appearance-none bg-gray-400 h-3 w-full text-gray-300',
126
- error_class: 'text-red-500', valid_class: 'text-green-400'
127
- end
167
+ b.use :input, class: 'mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm', error_class: 'text-red-500', valid_class: 'text-green-400'
128
168
  b.use :full_error, wrap_with: { tag: 'p', class: 'mt-2 text-red-500 text-xs italic' }
129
- b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-grey-700 text-xs italic' }
169
+ b.use :hint, wrap_with: { tag: 'p', class: 'mt-2 text-gray-700 text-xs italic' }
130
170
  end
131
171
 
132
172
  # The default wrapper to be used by the FormBuilder.
133
173
  config.default_wrapper = :vertical_form
134
174
 
135
175
  # Custom wrappers for input types. This should be a hash containing an input
136
- # type as key and the wrapper that will be used for all inputs with specified type.
176
+ # type as key and the wrapper used for the input.
137
177
  config.wrapper_mappings = {
138
178
  boolean: :vertical_boolean,
139
179
  check_boxes: :vertical_collection,
140
- date: :vertical_multi_select,
141
- datetime: :vertical_multi_select,
180
+ collection: :vertical_collection,
181
+ date: :vertical_date,
182
+ datetime: :vertical_datetime,
142
183
  file: :vertical_file,
143
184
  radio_buttons: :vertical_collection,
144
185
  range: :vertical_range,
145
- time: :vertical_multi_select
186
+ select: :vertical_select,
187
+ time: :vertical_time,
188
+ datetime_local: :vertical_datetime_local
146
189
  }
147
190
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module SimpleForm
4
4
  module Tailwind
5
- MIN_RAILS_VERSION = '4.0'
5
+ MIN_RAILS_VERSION = '7.0'
6
6
  MIN_SIMPLEFORM_VERSION = '5.0'
7
- VERSION = '0.1.2'
7
+ VERSION = '0.2.0'
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form-tailwind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Hicks
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-30 00:00:00.000000000 Z
10
+ date: 2025-05-09 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '4.0'
18
+ version: '7.0'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '4.0'
25
+ version: '7.0'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: simple_form
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -102,7 +101,6 @@ metadata:
102
101
  bug_tracker_uri: https://github.com/tarellel/simple_form-tailwind/issues
103
102
  changelog_uri: https://github.com/tarellel/simple_form-tailwind/blob/master/CHANGELOG.md
104
103
  source_code_uri: https://github.com/tarellel/simple_form-tailwind
105
- post_install_message:
106
104
  rdoc_options: []
107
105
  require_paths:
108
106
  - lib
@@ -117,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
115
  - !ruby/object:Gem::Version
118
116
  version: '0'
119
117
  requirements: []
120
- rubygems_version: 3.5.17
121
- signing_key:
118
+ rubygems_version: 3.6.3
122
119
  specification_version: 4
123
120
  summary: A basic rails generator for adding a simpleform config setup for tailwindCSS
124
121
  based forms