tailwind_form 0.0.1 → 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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +69 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +44 -1
- data/README.md +41 -13
- data/lib/tailwind_form.rb +11 -0
- data/lib/tailwind_form/components.rb +11 -0
- data/lib/tailwind_form/components/labels.rb +16 -0
- data/lib/tailwind_form/form_builder.rb +7 -23
- data/lib/tailwind_form/form_group.rb +14 -0
- data/lib/tailwind_form/inputs.rb +12 -0
- data/lib/tailwind_form/inputs/base.rb +19 -0
- data/lib/tailwind_form/inputs/email_field.rb +14 -0
- data/lib/tailwind_form/inputs/text_area.rb +14 -0
- data/lib/tailwind_form/inputs/text_field.rb +14 -0
- data/lib/tailwind_form/version.rb +1 -1
- data/tailwind_form.gemspec +14 -13
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8ea607b83292e5a3d3b3b440566f54cf638937fdd4bbf0d9beec0a82a804a0a
|
4
|
+
data.tar.gz: 5c0322940e9a55b583b23cf88e75d6b926cd4ab52947a611ffc6a3152b660a16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a90b7a935465cfbff945710b70649da41a9240aed3fd0328ca71f4cb1621bcddcdd394328b93d6cc1302dd6da2bbb6cf63688a32d02fbf1710c1c4dd481212af
|
7
|
+
data.tar.gz: efdb6e8397b5edf468353c4309eeccb5bf910fed14bb9a37d3dc9435f8b4b765f504c274d8f56f481e2017e556c5c1fe899d376c253d60606a4bdf6ef8349ce8
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rails
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
Exclude:
|
7
|
+
- "bin/**/*"
|
8
|
+
|
9
|
+
Layout/BlockAlignment:
|
10
|
+
EnforcedStyleAlignWith: start_of_block
|
11
|
+
Layout/DefEndAlignment:
|
12
|
+
EnforcedStyleAlignWith: def
|
13
|
+
AutoCorrect: true
|
14
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
15
|
+
Enabled: true
|
16
|
+
Layout/IndentationConsistency:
|
17
|
+
EnforcedStyle: indented_internal_methods
|
18
|
+
Layout/LineLength:
|
19
|
+
AutoCorrect: true
|
20
|
+
Max: 120
|
21
|
+
Layout/MultilineArrayLineBreaks:
|
22
|
+
Enabled: true
|
23
|
+
Layout/MultilineHashKeyLineBreaks:
|
24
|
+
Enabled: true
|
25
|
+
Layout/SpaceAroundMethodCallOperator:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
Style/Alias:
|
29
|
+
Enabled: true
|
30
|
+
EnforcedStyle: prefer_alias_method
|
31
|
+
Style/ExponentialNotation:
|
32
|
+
Enabled: true
|
33
|
+
Style/HashEachMethods:
|
34
|
+
Enabled: true
|
35
|
+
Style/HashTransformKeys:
|
36
|
+
Enabled: true
|
37
|
+
Style/HashTransformValues:
|
38
|
+
Enabled: true
|
39
|
+
Style/RegexpLiteral:
|
40
|
+
Enabled: true
|
41
|
+
AllowInnerSlashes: true
|
42
|
+
Style/SlicingWithRange:
|
43
|
+
Enabled: true
|
44
|
+
Style/SymbolArray:
|
45
|
+
Enabled: true
|
46
|
+
EnforcedStyle: brackets
|
47
|
+
Style/TrailingCommaInArrayLiteral:
|
48
|
+
EnforcedStyleForMultiline: consistent_comma
|
49
|
+
Style/TrailingCommaInHashLiteral:
|
50
|
+
EnforcedStyleForMultiline: consistent_comma
|
51
|
+
Style/WordArray:
|
52
|
+
Enabled: true
|
53
|
+
EnforcedStyle: brackets
|
54
|
+
|
55
|
+
Lint/RaiseException:
|
56
|
+
Enabled: true
|
57
|
+
Lint/StructNewOverride:
|
58
|
+
Enabled: true
|
59
|
+
|
60
|
+
#
|
61
|
+
### DISABLED COPS
|
62
|
+
#
|
63
|
+
|
64
|
+
Style/ClassAndModuleChildren:
|
65
|
+
Enabled: false
|
66
|
+
Style/Documentation:
|
67
|
+
Enabled: false
|
68
|
+
Style/FrozenStringLiteralComment:
|
69
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in tailwind_form.gemspec
|
4
4
|
gemspec path: __dir__
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'rubocop-performance', require: false
|
8
|
+
gem 'rubocop-rails', require: false
|
9
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,59 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tailwind_form (0.0.
|
4
|
+
tailwind_form (0.0.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
activesupport (6.0.3.2)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 0.7, < 2)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
tzinfo (~> 1.1)
|
14
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
15
|
+
ast (2.4.1)
|
16
|
+
concurrent-ruby (1.1.6)
|
17
|
+
i18n (1.8.3)
|
18
|
+
concurrent-ruby (~> 1.0)
|
19
|
+
minitest (5.14.1)
|
20
|
+
parallel (1.19.2)
|
21
|
+
parser (2.7.1.4)
|
22
|
+
ast (~> 2.4.1)
|
23
|
+
rack (2.2.3)
|
24
|
+
rainbow (3.0.0)
|
25
|
+
regexp_parser (1.7.1)
|
26
|
+
rexml (3.2.4)
|
27
|
+
rubocop (0.88.0)
|
28
|
+
parallel (~> 1.10)
|
29
|
+
parser (>= 2.7.1.1)
|
30
|
+
rainbow (>= 2.2.2, < 4.0)
|
31
|
+
regexp_parser (>= 1.7)
|
32
|
+
rexml
|
33
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
34
|
+
ruby-progressbar (~> 1.7)
|
35
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
36
|
+
rubocop-ast (0.1.0)
|
37
|
+
parser (>= 2.7.0.1)
|
38
|
+
rubocop-performance (1.7.1)
|
39
|
+
rubocop (>= 0.82.0)
|
40
|
+
rubocop-rails (2.6.0)
|
41
|
+
activesupport (>= 4.2.0)
|
42
|
+
rack (>= 1.1)
|
43
|
+
rubocop (>= 0.82.0)
|
44
|
+
ruby-progressbar (1.10.1)
|
45
|
+
thread_safe (0.3.6)
|
46
|
+
tzinfo (1.2.7)
|
47
|
+
thread_safe (~> 0.1)
|
48
|
+
unicode-display_width (1.7.0)
|
49
|
+
zeitwerk (2.4.0)
|
9
50
|
|
10
51
|
PLATFORMS
|
11
52
|
ruby
|
12
53
|
|
13
54
|
DEPENDENCIES
|
55
|
+
rubocop-performance
|
56
|
+
rubocop-rails
|
14
57
|
tailwind_form!
|
15
58
|
|
16
59
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -10,6 +10,8 @@ Benefits of `tailwind_form`
|
|
10
10
|
* Reduces errors
|
11
11
|
* Makes `.erb` forms much more readable
|
12
12
|
|
13
|
+
This gem is largely based on the [Bootstrap Form Gem](https://github.com/bootstrap-ruby/bootstrap_form), but implemented for TailwindCSS.
|
14
|
+
|
13
15
|
## Requirements
|
14
16
|
|
15
17
|
Currently, `tailwind_form` is only tested with
|
@@ -62,45 +64,71 @@ A sample implementation is as follows:
|
|
62
64
|
Here is an example of the form:
|
63
65
|
|
64
66
|
```erb
|
65
|
-
<%= tailwind_form_with
|
66
|
-
<%=
|
67
|
-
<%=
|
67
|
+
<%= tailwind_form_with(model: @person, local: true) do |form| %>
|
68
|
+
<%= form.form_group :first_name %>
|
69
|
+
<%= form.form_group :last_name %>
|
70
|
+
<%= form.form_group :email, :email_field %>
|
71
|
+
|
72
|
+
<div class="actions">
|
73
|
+
<%= form.submit %>
|
74
|
+
</div>
|
68
75
|
<% end %>
|
76
|
+
|
69
77
|
```
|
70
78
|
|
71
79
|
Which generates the following form:
|
72
80
|
|
73
81
|
```html
|
74
|
-
<form
|
75
|
-
<input type="hidden" name="authenticity_token" value="
|
82
|
+
<form action="/people" accept-charset="UTF-8" method="post">
|
83
|
+
<input type="hidden" name="authenticity_token" value="cfuds;" />
|
84
|
+
<div class="form__group">
|
85
|
+
<label class="form__label" for="person_first_name">First name</label>
|
86
|
+
<div class="form__inputGroup">
|
87
|
+
<input class="form__input" type="text" name="person[first_name]" id="person_first_name" />
|
88
|
+
</div>
|
89
|
+
</div>
|
76
90
|
<div class="form__group">
|
77
|
-
<label class="form__label" for="
|
91
|
+
<label class="form__label" for="person_last_name">Last name</label>
|
78
92
|
<div class="form__inputGroup">
|
79
|
-
<input class="form__input" type="text" name="
|
93
|
+
<input class="form__input" type="text" name="person[last_name]" id="person_last_name" />
|
80
94
|
</div>
|
81
95
|
</div>
|
82
96
|
<div class="form__group">
|
83
|
-
<label class="form__label" for="
|
97
|
+
<label class="form__label" for="person_email">Email</label>
|
84
98
|
<div class="form__inputGroup">
|
85
|
-
<input class="form__input" type="
|
99
|
+
<input class="form__input" type="email" name="person[email]" id="person_email" />
|
86
100
|
</div>
|
87
101
|
</div>
|
102
|
+
|
103
|
+
<div class="actions">
|
104
|
+
<input type="submit" name="commit" value="Create Person" data-disable-with="Create Person" />
|
105
|
+
</div>
|
88
106
|
</form>
|
89
107
|
```
|
90
108
|
|
91
109
|
## Development
|
92
110
|
|
93
|
-
|
111
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
112
|
+
|
113
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
114
|
+
|
115
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
94
116
|
|
95
|
-
|
117
|
+
## To do
|
96
118
|
|
97
|
-
|
119
|
+
So far, we have implemented the basic form but only have `text_field`, `text_area`, and `email_field`. Next steps are implementing all of the other input types.
|
120
|
+
|
121
|
+
Additionally, here are other items on the todo list:
|
122
|
+
* Add support for errors, both as an alert and as inline error helper
|
123
|
+
* Add different layout options
|
124
|
+
* Add different options for select and multiselect using AlpineJS
|
125
|
+
|
126
|
+
If anyone happens to be seeing/using this gem and can think of other features, please let me know!
|
98
127
|
|
99
128
|
## Contributing
|
100
129
|
|
101
130
|
Bug reports and pull requests are welcome on GitHub at https://github.com/maxmetcalf12/tailwind_form. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/maxmetcalf12/tailwind_form/blob/master/CODE_OF_CONDUCT.md).
|
102
131
|
|
103
|
-
|
104
132
|
## License
|
105
133
|
|
106
134
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/tailwind_form.rb
CHANGED
@@ -10,6 +10,17 @@ module TailwindForm
|
|
10
10
|
|
11
11
|
eager_autoload do
|
12
12
|
autoload :FormBuilder
|
13
|
+
autoload :FormGroup
|
14
|
+
autoload :Components
|
15
|
+
autoload :Inputs
|
16
|
+
end
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def eager_load!
|
20
|
+
super
|
21
|
+
TailwindForm::Components.eager_load!
|
22
|
+
TailwindForm::Inputs.eager_load!
|
23
|
+
end
|
13
24
|
end
|
14
25
|
end
|
15
26
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TailwindForm
|
4
|
+
module Components
|
5
|
+
module Labels
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def tailwind_label_field(name)
|
11
|
+
field_options = { class: 'form__label' }
|
12
|
+
label(name, field_options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -2,30 +2,14 @@
|
|
2
2
|
|
3
3
|
module TailwindForm
|
4
4
|
class FormBuilder < ActionView::Helpers::FormBuilder
|
5
|
-
|
6
|
-
|
7
|
-
label(name, field_options)
|
8
|
-
end
|
5
|
+
include TailwindForm::FormGroup
|
6
|
+
include TailwindForm::Components
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
8
|
+
include TailwindForm::Inputs::Base
|
9
|
+
include TailwindForm::Inputs::EmailField
|
10
|
+
include TailwindForm::Inputs::TextArea
|
11
|
+
include TailwindForm::Inputs::TextField
|
16
12
|
|
17
|
-
|
18
|
-
field_options = { class: 'form__input' }
|
19
|
-
@template.content_tag :div, class: 'form__inputGroup' do
|
20
|
-
text_area(name, field_options)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def form_group(name, classes = 'form__group', field_type = :text_field)
|
25
|
-
function_name = "tailwind_#{field_type}"
|
26
|
-
@template.content_tag :div, class: classes do
|
27
|
-
tailwind_label_field(name) + send(function_name, name)
|
28
|
-
end
|
29
|
-
end
|
13
|
+
delegate :concat, :tag, to: :@template
|
30
14
|
end
|
31
15
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TailwindForm
|
4
|
+
module FormGroup
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
def form_group(name, field_type = :text_field, classes = 'form__group')
|
8
|
+
function_name = "#{field_type}_with_tailwind"
|
9
|
+
tag.div(class: classes) do
|
10
|
+
tailwind_label_field(name) + send(function_name, name, { class: 'form__input' })
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TailwindForm
|
4
|
+
module Inputs
|
5
|
+
module Base
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
class_methods do
|
9
|
+
def tailwind_field(field_name)
|
10
|
+
define_method "#{field_name}_with_tailwind" do |name, options = {}|
|
11
|
+
@template.content_tag :div, class: 'form__inputGroup' do
|
12
|
+
send(field_name, name, options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/tailwind_form.gemspec
CHANGED
@@ -3,23 +3,24 @@
|
|
3
3
|
require_relative 'lib/tailwind_form/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = 'tailwind_form'
|
7
|
+
spec.version = TailwindForm::VERSION
|
8
|
+
spec.authors = ['maxmetcalf12']
|
9
|
+
spec.email = ['maxmetcalf12@gmail.com']
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
11
|
+
spec.summary = 'Tailwind form builder makes it easy to style forms consistently using TailwindCSS'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'https://github.com/maxmetcalf12/tailwind_form'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
18
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files =
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
spec.
|
19
|
+
spec.files =
|
20
|
+
Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
|
24
25
|
spec.require_paths = ['lib']
|
25
26
|
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailwind_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- maxmetcalf12
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: Tailwind form builder makes it easy to style forms consistently using
|
14
|
+
TailwindCSS
|
14
15
|
email:
|
15
16
|
- maxmetcalf12@gmail.com
|
16
17
|
executables: []
|
@@ -19,6 +20,7 @@ extra_rdoc_files: []
|
|
19
20
|
files:
|
20
21
|
- ".gitignore"
|
21
22
|
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
22
24
|
- ".travis.yml"
|
23
25
|
- CODE_OF_CONDUCT.md
|
24
26
|
- Gemfile
|
@@ -30,8 +32,16 @@ files:
|
|
30
32
|
- bin/setup
|
31
33
|
- lib/tailwind_form.rb
|
32
34
|
- lib/tailwind_form/action_view_extensions/form_helper.rb
|
35
|
+
- lib/tailwind_form/components.rb
|
36
|
+
- lib/tailwind_form/components/labels.rb
|
33
37
|
- lib/tailwind_form/engine.rb
|
34
38
|
- lib/tailwind_form/form_builder.rb
|
39
|
+
- lib/tailwind_form/form_group.rb
|
40
|
+
- lib/tailwind_form/inputs.rb
|
41
|
+
- lib/tailwind_form/inputs/base.rb
|
42
|
+
- lib/tailwind_form/inputs/email_field.rb
|
43
|
+
- lib/tailwind_form/inputs/text_area.rb
|
44
|
+
- lib/tailwind_form/inputs/text_field.rb
|
35
45
|
- lib/tailwind_form/version.rb
|
36
46
|
- tailwind_form.gemspec
|
37
47
|
homepage: https://github.com/maxmetcalf12/tailwind_form
|