-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preliminary support for Bootstrap 5 #567
Conversation
Here's an example of a CHANGELOG.md entry (place it immediately under the * [#567](https://github.com/bootstrap-ruby/bootstrap_form/pull/567): Preliminary support for Bootstrap 5 - [@taylorthurlow](https://github.com/taylorthurlow). Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, thanks for the PR! I especially like that you took the time to write up some of your thinking and your findings.
Some history: The upgrade of Bootstrap from 3 to 4 took some time, and there were a few alphas, if I recall correctly. Based on the list of changes for Bootstrap 5, I'm hoping this upgrade will go faster, but I still think it's worthwhile to create a branch for Bootstrap 5 development for now. I'll try to create that branch shortly, and then could you please point this PR at that branch rather than at master? Thanks in advance.
The question of form group is interesting. In both Bootstrap 3 and 4 there was a form group, but it changed a bit, and it turned out to have interesting consequences for our gem. But we discovered them by people using the gem, so your PR is on the right track.
With respect to testing: I'm a big believer in quality testing. It wouldn't surprise me if a bunch of tests should disappear, but I'd expect that we'd find they should be replaced by new tests. I'll try to pull your PR in the next day or two and take a look in more detail.
So thanks again. I'll drop a comment on your PR when I've created the bootstrap-5
branch and you can point your PR at the branch.
I've created a Thanks again for your PR! |
Switched the base branch. Glad I could be of some help! |
I noticed that the EDIT: Some rubocop warnings were fixed in those aforementioned ~8 commits so the rebased version is failing CI. |
Thank you so much for picking up support for Bootstrap 5! I'm already using this in an application I'm working on. One thing I noticed is that checkbox labels both get the |
Another issue: dropdowns (select) should get the class |
Terribly sorry about that. My bad. I have updated the @thimo Thanks for the feedback. We're happy to consider pull requests on the The reason for separate issues is the following: The upgrade from Bootstrap 3 to 4 was a long process, and some of the individual changes turned out to require significant work. It's easier to track the work for each issue separately, rather than try to do one big PR. Thanks in advance. |
In 5.0 they are consolidated into the .form-check class, and no longer need to be treated as separate cases. Relevant tests will be fixed or removed in the next commit.
Bootstrap 5 is now recommending using bottom margin utilities to control group spacing, and has removed ".form-group" entirely.
Some methods in FormGroup were refactored to meet a RuboCop lint complexity requirement. I don't personally think the refactor is necessary but it won't pass CI without it.
Bootstrap 5 removes ".form-inline" in favor of the usage of ".col-auto" and the new gutter utilities.
Bootstrap 5 removes ".input-group-prepend" and ".input-group-append", they are no longer necessary. You can now add buttons and ".input-group-text" as direct children of the input groups.
My heavy-handedness with the previous commits removed the ability to use switch style checkboxes when I removed the custom check box classes.
No problem at all, it took less than 5 minutes. I kept the old branch alive so I just re-pushed the old branch without the small changes. I'm not sure what the best approach for getting @thimo's proposed fixes merged here. Would it make sense to merge this PR with its flaws intact, and just continue submitting PRs to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome work. Thank you. Please take a look at my questions. Other work we can do under other PRs. Thanks again for jumping on this so quickly.
@taylorthurlow Apologies for the disorganized nature of my feedback. My paid job doesn't use the gem, so I have to squeeze in time around family and work. Anyway, now that I have my head around @thimo 's comments, I'll leave it up to you if you want to add them to this PR. They seem pretty straightforward, so if you don't mind fixing them in this PR, it would move things along faster. |
The Rails view helpers that accept a `class` option accept both single strings and arrays of strings, so this change makes the CSS class array builder agnostic to the input type. I'm now also noticing that the result already had `#flatten` called on it, so this probably wasn't an issue, but this is nicer!
Thanks to @thimo for catching this one.
This required some extra effort because all the select forms inherited their control class from the base input class.
I've fixed the issues @thimo brought up. The I feel like the way I fixed it is a little sloppy. The control class is And I applied that to all necessary select fields, but for Let me know if you have any suggestions on how to make this a little better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this PR. You've really given us a great step for Bootstrap 5 support.
@@ -66,7 +66,7 @@ def group_layout_horizontal?(layout) | |||
end | |||
|
|||
def classes_include_gutters?(classes) | |||
classes.any? { |c| c =~ /g-\d+/ } | |||
classes.any? { |c| c =~ /^g-\d+$/ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works as long as we're sure the classes
always has just one class per item in the iterator.
👍
Awesome work, thanks a lot! I've switched to using the new |
* Start README for Bootstrap 5 * Preliminary support for Bootstrap 5 (#567) * Switch demo bootstrap JS include URL * Remove "custom-control" support from radios and check boxes In 5.0 they are consolidated into the .form-check class, and no longer need to be treated as separate cases. Relevant tests will be fixed or removed in the next commit. * Remove "custom-control" tests for radios and check boxes * Rename ".custom-file" to ".form-file" * Change all ".form-group" uses to ".mb-3" Bootstrap 5 is now recommending using bottom margin utilities to control group spacing, and has removed ".form-group" entirely. * Replace ".form-row" with gutter utils (".g-3") Some methods in FormGroup were refactored to meet a RuboCop lint complexity requirement. I don't personally think the refactor is necessary but it won't pass CI without it. * Replace ".form-inline" where necessary Bootstrap 5 removes ".form-inline" in favor of the usage of ".col-auto" and the new gutter utilities. * Remove wrapper divs for elements prepended/appended to input groups Bootstrap 5 removes ".input-group-prepend" and ".input-group-append", they are no longer necessary. You can now add buttons and ".input-group-text" as direct children of the input groups. * Add ".form-label" to all generated label tags * Fix broken tests after label class change * Fix switch style check boxes My heavy-handedness with the previous commits removed the ability to use switch style checkboxes when I removed the custom check box classes. * Update switch checkbox syntax in README.md * Add anchors for stricter #classes_include_gutters? * Handle string or array of classes for check boxes and radio buttons The Rails view helpers that accept a `class` option accept both single strings and arrays of strings, so this change makes the CSS class array builder agnostic to the input type. I'm now also noticing that the result already had `#flatten` called on it, so this probably wasn't an issue, but this is nicer! * Use only form-check-label class for check box and radio button labels Thanks to @thimo for catching this one. * Change select box class from "form-control" to "form-select" This required some extra effort because all the select forms inherited their control class from the base input class. * Add upgrade doc and update gemspec * Remove role="form" (#571) * Fix tests in bootstrap-5 branch. Fixes #582 (#583) * Fix tests for Rails updates * Fix Rubocop offenses Dangerfile:48:3: C: [Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer if conditions. if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3 ^^ Dangerfile:48:42: C: [Correctable] Style/RedundantRegexpEscape: Redundant escape inside regexp literal if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3 ^^ bootstrap_form.gemspec:27:3: W: Lint/ConstantDefinitionInBlock: Do not define constants this way within a block. (https://rubystyle.guide#no-constant-definition-in-block) REQUIRED_RAILS_VERSION = ">= 5.2".freeze ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ demo/config/puma.rb:7:21: C: [Correctable] Style/RedundantFetchBlock: Use fetch("RAILS_MAX_THREADS", 5) instead of fetch("RAILS_MAX_THREADS") { 5 }. (https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code) threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ demo/config/puma.rb:12:17: C: [Correctable] Style/RedundantFetchBlock: Use fetch("PORT", 3000) instead of fetch("PORT") { 3000 }. (https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code) port ENV.fetch("PORT") { 3000 } ^^^^^^^^^^^^^^^^^^^^^^ lib/bootstrap_form.rb:5:11: C: [Correctable] Style/StringConcatenation: Prefer string interpolation to string concatenation. (https://rubystyle.guide#string-interpolation) require Gem::Specification.find_by_name("actiontext").gem_dir + ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/components/validation.rb:17:22: C: [Correctable] Style/ClassEqualityComparison: Use instance_of?(Class) instead of comparing classes. (https://rubystyle.guide#instance-of-vs-class-comparison) target = obj.class == Class ? obj : obj.class ^^^^^^^^^^^^^^ lib/bootstrap_form/form_builder.rb:48:5: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/AbcSize. # rubocop:disable Metrics/AbcSize ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/form_group_builder.rb:24:9: C: [Correctable] Style/ExplicitBlockArgument: Consider using explicit block argument in the surrounding method's signature over yield. (https://rubystyle.guide#block-argument) form_group(method, form_group_options) { yield } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/form_group_builder.rb:32:59: C: [Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer unless conditions. options[:required] = form_group_required(options) if options.key?(:skip_required) ^^ lib/bootstrap_form/form_group_builder.rb:60:7: C: [Correctable] Style/RedundantAssignment: Redundant assignment before returning detected. hash = { ... ^^^^^^^^ lib/bootstrap_form/helpers/bootstrap.rb:25:44: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/AbcSize. def alert_message(title, options={}) # rubocop:disable Metrics/AbcSize ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/test_helper.rb:7:18: C: [Correctable] Style/RedundantFileExtensionInRequire: Redundant .rb file extension detected. (https://rubystyle.guide#no-explicit-rb-to-require) require_relative "../demo/config/environment.rb" * Update CHANGELOG * Add gemfile for Rails 6.1 * Run Travis against latest Ruby versions * Update tests to both handle Rails 5.2/6 and Rails 6.1 * Step down 1 minor version for Ruby as Travis is not yet ready * Update changelog * Support Bootstrap 5 floating labels. Fixes #573 (#584) * Support floating labels * Add tests for floating labels * Update demo app with floating labels section * Add floating labels to CHANGELOG * Describe floating labels in README * Fix rubop offense for block length lib/bootstrap_form/inputs/base.rb:8:7: C: Metrics/BlockLength: Block has too many lines. [26/25] class_methods do ... ^^^^^^^^^^^^^^^^ * Fix capitalization * Use <<~ instead of strip_heredoc * Simplify rendering of file_field for Bootstrap 5. Fixes #572 (#581) * Use Bootstrap 5 beta 3 CDN libraries in demo app Links to both CSS and JS libraries taken from https://getbootstrap.com/docs/5.0/getting-started/introduction/ * Remove linking ../images Folder doesn’t exist and causes the error "ActionView::Template::Error (link_tree argument must be a directory)" * Cleanup generated HTML for file upload as per Bootstrap 5 See #572 * Update tests for new file upload rendering * Add changelog entry * Fix Rubocop offense on whitespace lib/bootstrap_form/inputs/file_field.rb:10:52: C: [Correctable] Layout/SpaceAroundEqualsInParameterDefault: Surrounding space detected in default value assignment. (https://rubystyle.guide#spaces-around-equals) def file_field_with_bootstrap(name, options = {}) ^^^ Co-authored-by: Larry Reid <lcreid@jadesystems.ca> * Get rid of `heredoc` on `bootstrap-5` branch (#591) * Ignore RubyMine config directory * Initial setup of GitHb Actions * Run tests for rails 5 and rails 6 * Run tests for rails 5 and rails 6 + run lint job * GH Actions: Correct gemfile names * GH Actions: Only run the test task in the matrix. rubocop is run in the separate Lint job. * GH Actions: Separate the Danger run for better output * GH Actions: Run rubocop directly instead of as a Rake task. Allow autocorrectable offences. * GH Actions: Only run Danger for pull requests * GH Actions: Try to calm RuboCop * Use the default Gemfile to pick up rubocop.yml * GH Actions: Ignore the vendor directory for rubocop * Forward the options as keyword arguments * Test Rails 6.1 and skip Rails 5.2 + Ruby 3.0 * Fix Rails 6.1 tests on master (#586) * Fix tests for Rails 6.1 * Fix Rubocop offenses bootstrap_form.gemspec:27:29: C: Gemspec/RequiredRubyVersion: required_ruby_version (2.5, declared in bootstrap_form.gemspec) and TargetRubyVersion (2.7, which may be specified in .rubocop.yml) should be equal. s.required_ruby_version = ">= 2.5" ^^^^^^^^ lib/bootstrap_form/form_group.rb:14:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent) :input_group_class, :label_col, :control_col, ^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/form_group.rb:15:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent) :add_control_col_class, :layout, :prepend)) do ^^^^^^^^^^^^^^^^^^^^^^ test/bootstrap_form_test.rb:123:103: C: [Correctable] Style/IfUnlessModifier: Modifier form of if makes the line too long. (https://rubystyle.guide#if-as-a-modifier) <form accept-charset="UTF-8" action="/users" method="post" role="form" #{'data-remote="true"' if ::Rails::VERSION::STRING < "6.1"}> ^^ test/bootstrap_form_test.rb:123:133: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. <form accept-charset="UTF-8" action="/users" method="post" role="form" #{'data-remote="true"' if ::Rails::VERSION::STRING < "6.1"}> ^^^^^ test/bootstrap_rich_text_area_test.rb:23:54: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename" ^^^^^^^^^^^ test/bootstrap_rich_text_area_test.rb:23:97: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename" ^^^^^ * Include Rails 6.1 in Travis tests + update Ruby versions * Update CHANGELOG * Rails Edge requires Ruby 2.7+ * Remove rubocop_todo and fix Rubocop offenses * Replace strip_heredoc with <<~ (#587) * Replace strip_heredoc with <<~ Also fix newly detected Rubocop offenses on indentation * Update CHANGELOG * Simplify Dockerfile and add documentation (#588) * Simplify Dockerfile and add documentation * A few more additions to .gitignore * Ignore gems placed when using Dockerfile (#590) * Fix formatting and heredoc * Fix bad merge Co-authored-by: Uwe Kubosch <uwe@kubosch.no> Co-authored-by: Uwe Kubosch <donv@users.noreply.github.com> Co-authored-by: Thimo Jansen <thimo@defrog.nl> * Cherry pick some commits from `main` (#594) * Change default branch to `main` (#592) * Change default branch to `main` * Add GitHub token for Danger * Change default branch to `main` (#592) * Change default branch to `main` * Add GitHub token for Danger * Fix deprecation that I broke again * Errors on invalid feedback (#580) * Use "invalid-feedback" class name for errors_on * Add custom class option for errors_on helper * Improve tests, docs and changelog Co-authored-by: Larry Reid <lcreid@jadesystems.ca> * README: Use GH Actions badge, drop Travis badge, configuration file (#600) * README: Use GH Actions badge, drop Travis badge * Delete unused TravisCI configuration file * Update README for release of 5.0 Co-authored-by: Taylor Thurlow <taylorthurlow@me.com> Co-authored-by: Thimo Jansen <thimo@defrog.nl> Co-authored-by: Uwe Kubosch <uwe@kubosch.no> Co-authored-by: Uwe Kubosch <donv@users.noreply.github.com> Co-authored-by: Chrıs Seelus <cseelus@gmail.com> Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
* Start README for Bootstrap 5 * Preliminary support for Bootstrap 5 (#567) * Switch demo bootstrap JS include URL * Remove "custom-control" support from radios and check boxes In 5.0 they are consolidated into the .form-check class, and no longer need to be treated as separate cases. Relevant tests will be fixed or removed in the next commit. * Remove "custom-control" tests for radios and check boxes * Rename ".custom-file" to ".form-file" * Change all ".form-group" uses to ".mb-3" Bootstrap 5 is now recommending using bottom margin utilities to control group spacing, and has removed ".form-group" entirely. * Replace ".form-row" with gutter utils (".g-3") Some methods in FormGroup were refactored to meet a RuboCop lint complexity requirement. I don't personally think the refactor is necessary but it won't pass CI without it. * Replace ".form-inline" where necessary Bootstrap 5 removes ".form-inline" in favor of the usage of ".col-auto" and the new gutter utilities. * Remove wrapper divs for elements prepended/appended to input groups Bootstrap 5 removes ".input-group-prepend" and ".input-group-append", they are no longer necessary. You can now add buttons and ".input-group-text" as direct children of the input groups. * Add ".form-label" to all generated label tags * Fix broken tests after label class change * Fix switch style check boxes My heavy-handedness with the previous commits removed the ability to use switch style checkboxes when I removed the custom check box classes. * Update switch checkbox syntax in README.md * Add anchors for stricter #classes_include_gutters? * Handle string or array of classes for check boxes and radio buttons The Rails view helpers that accept a `class` option accept both single strings and arrays of strings, so this change makes the CSS class array builder agnostic to the input type. I'm now also noticing that the result already had `#flatten` called on it, so this probably wasn't an issue, but this is nicer! * Use only form-check-label class for check box and radio button labels Thanks to @thimo for catching this one. * Change select box class from "form-control" to "form-select" This required some extra effort because all the select forms inherited their control class from the base input class. * Add upgrade doc and update gemspec * Remove role="form" (#571) * Fix tests in bootstrap-5 branch. Fixes #582 (#583) * Fix tests for Rails updates * Fix Rubocop offenses Dangerfile:48:3: C: [Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer if conditions. if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3 ^^ Dangerfile:48:42: C: [Correctable] Style/RedundantRegexpEscape: Redundant escape inside regexp literal if IO.read("CHANGELOG.md").scan(/^\s*[-\*] Your contribution here/i).count < 3 ^^ bootstrap_form.gemspec:27:3: W: Lint/ConstantDefinitionInBlock: Do not define constants this way within a block. (https://rubystyle.guide#no-constant-definition-in-block) REQUIRED_RAILS_VERSION = ">= 5.2".freeze ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ demo/config/puma.rb:7:21: C: [Correctable] Style/RedundantFetchBlock: Use fetch("RAILS_MAX_THREADS", 5) instead of fetch("RAILS_MAX_THREADS") { 5 }. (https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code) threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ demo/config/puma.rb:12:17: C: [Correctable] Style/RedundantFetchBlock: Use fetch("PORT", 3000) instead of fetch("PORT") { 3000 }. (https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code) port ENV.fetch("PORT") { 3000 } ^^^^^^^^^^^^^^^^^^^^^^ lib/bootstrap_form.rb:5:11: C: [Correctable] Style/StringConcatenation: Prefer string interpolation to string concatenation. (https://rubystyle.guide#string-interpolation) require Gem::Specification.find_by_name("actiontext").gem_dir + ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/components/validation.rb:17:22: C: [Correctable] Style/ClassEqualityComparison: Use instance_of?(Class) instead of comparing classes. (https://rubystyle.guide#instance-of-vs-class-comparison) target = obj.class == Class ? obj : obj.class ^^^^^^^^^^^^^^ lib/bootstrap_form/form_builder.rb:48:5: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/AbcSize. # rubocop:disable Metrics/AbcSize ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/form_group_builder.rb:24:9: C: [Correctable] Style/ExplicitBlockArgument: Consider using explicit block argument in the surrounding method's signature over yield. (https://rubystyle.guide#block-argument) form_group(method, form_group_options) { yield } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/form_group_builder.rb:32:59: C: [Correctable] Style/SoleNestedConditional: Consider merging nested conditions into outer unless conditions. options[:required] = form_group_required(options) if options.key?(:skip_required) ^^ lib/bootstrap_form/form_group_builder.rb:60:7: C: [Correctable] Style/RedundantAssignment: Redundant assignment before returning detected. hash = { ... ^^^^^^^^ lib/bootstrap_form/helpers/bootstrap.rb:25:44: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Metrics/AbcSize. def alert_message(title, options={}) # rubocop:disable Metrics/AbcSize ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test/test_helper.rb:7:18: C: [Correctable] Style/RedundantFileExtensionInRequire: Redundant .rb file extension detected. (https://rubystyle.guide#no-explicit-rb-to-require) require_relative "../demo/config/environment.rb" * Update CHANGELOG * Add gemfile for Rails 6.1 * Run Travis against latest Ruby versions * Update tests to both handle Rails 5.2/6 and Rails 6.1 * Step down 1 minor version for Ruby as Travis is not yet ready * Update changelog * Support Bootstrap 5 floating labels. Fixes #573 (#584) * Support floating labels * Add tests for floating labels * Update demo app with floating labels section * Add floating labels to CHANGELOG * Describe floating labels in README * Fix rubop offense for block length lib/bootstrap_form/inputs/base.rb:8:7: C: Metrics/BlockLength: Block has too many lines. [26/25] class_methods do ... ^^^^^^^^^^^^^^^^ * Fix capitalization * Use <<~ instead of strip_heredoc * Simplify rendering of file_field for Bootstrap 5. Fixes #572 (#581) * Use Bootstrap 5 beta 3 CDN libraries in demo app Links to both CSS and JS libraries taken from https://getbootstrap.com/docs/5.0/getting-started/introduction/ * Remove linking ../images Folder doesn’t exist and causes the error "ActionView::Template::Error (link_tree argument must be a directory)" * Cleanup generated HTML for file upload as per Bootstrap 5 See #572 * Update tests for new file upload rendering * Add changelog entry * Fix Rubocop offense on whitespace lib/bootstrap_form/inputs/file_field.rb:10:52: C: [Correctable] Layout/SpaceAroundEqualsInParameterDefault: Surrounding space detected in default value assignment. (https://rubystyle.guide#spaces-around-equals) def file_field_with_bootstrap(name, options = {}) ^^^ Co-authored-by: Larry Reid <lcreid@jadesystems.ca> * Get rid of `heredoc` on `bootstrap-5` branch (#591) * Ignore RubyMine config directory * Initial setup of GitHb Actions * Run tests for rails 5 and rails 6 * Run tests for rails 5 and rails 6 + run lint job * GH Actions: Correct gemfile names * GH Actions: Only run the test task in the matrix. rubocop is run in the separate Lint job. * GH Actions: Separate the Danger run for better output * GH Actions: Run rubocop directly instead of as a Rake task. Allow autocorrectable offences. * GH Actions: Only run Danger for pull requests * GH Actions: Try to calm RuboCop * Use the default Gemfile to pick up rubocop.yml * GH Actions: Ignore the vendor directory for rubocop * Forward the options as keyword arguments * Test Rails 6.1 and skip Rails 5.2 + Ruby 3.0 * Fix Rails 6.1 tests on master (#586) * Fix tests for Rails 6.1 * Fix Rubocop offenses bootstrap_form.gemspec:27:29: C: Gemspec/RequiredRubyVersion: required_ruby_version (2.5, declared in bootstrap_form.gemspec) and TargetRubyVersion (2.7, which may be specified in .rubocop.yml) should be equal. s.required_ruby_version = ">= 2.5" ^^^^^^^^ lib/bootstrap_form/form_group.rb:14:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent) :input_group_class, :label_col, :control_col, ^^^^^^^^^^^^^^^^^^ lib/bootstrap_form/form_group.rb:15:30: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent) :add_control_col_class, :layout, :prepend)) do ^^^^^^^^^^^^^^^^^^^^^^ test/bootstrap_form_test.rb:123:103: C: [Correctable] Style/IfUnlessModifier: Modifier form of if makes the line too long. (https://rubystyle.guide#if-as-a-modifier) <form accept-charset="UTF-8" action="/users" method="post" role="form" #{'data-remote="true"' if ::Rails::VERSION::STRING < "6.1"}> ^^ test/bootstrap_form_test.rb:123:133: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. <form accept-charset="UTF-8" action="/users" method="post" role="form" #{'data-remote="true"' if ::Rails::VERSION::STRING < "6.1"}> ^^^^^ test/bootstrap_rich_text_area_test.rb:23:54: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename" ^^^^^^^^^^^ test/bootstrap_rich_text_area_test.rb:23:97: C: [Correctable] Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations. "http://test.host/rails/active_storage/blobs/#{"redirect/" if ::Rails::VERSION::STRING >= "6.1"}:signed_id/:filename" ^^^^^ * Include Rails 6.1 in Travis tests + update Ruby versions * Update CHANGELOG * Rails Edge requires Ruby 2.7+ * Remove rubocop_todo and fix Rubocop offenses * Replace strip_heredoc with <<~ (#587) * Replace strip_heredoc with <<~ Also fix newly detected Rubocop offenses on indentation * Update CHANGELOG * Simplify Dockerfile and add documentation (#588) * Simplify Dockerfile and add documentation * A few more additions to .gitignore * Ignore gems placed when using Dockerfile (#590) * Fix formatting and heredoc * Fix bad merge Co-authored-by: Uwe Kubosch <uwe@kubosch.no> Co-authored-by: Uwe Kubosch <donv@users.noreply.github.com> Co-authored-by: Thimo Jansen <thimo@defrog.nl> * Cherry pick some commits from `main` (#594) * Change default branch to `main` (#592) * Change default branch to `main` * Add GitHub token for Danger * Change default branch to `main` (#592) * Change default branch to `main` * Add GitHub token for Danger * Fix deprecation that I broke again * Errors on invalid feedback (#580) * Use "invalid-feedback" class name for errors_on * Add custom class option for errors_on helper * Improve tests, docs and changelog Co-authored-by: Larry Reid <lcreid@jadesystems.ca> * README: Use GH Actions badge, drop Travis badge, configuration file (#600) * README: Use GH Actions badge, drop Travis badge * Delete unused TravisCI configuration file * Update README for release of 5.0 * Preparing v5.0.0 Co-authored-by: Taylor Thurlow <taylorthurlow@me.com> Co-authored-by: Thimo Jansen <thimo@defrog.nl> Co-authored-by: Uwe Kubosch <uwe@kubosch.no> Co-authored-by: Uwe Kubosch <donv@users.noreply.github.com> Co-authored-by: Chrıs Seelus <cseelus@gmail.com> Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
* Switch demo bootstrap JS include URL * Remove "custom-control" support from radios and check boxes In 5.0 they are consolidated into the .form-check class, and no longer need to be treated as separate cases. Relevant tests will be fixed or removed in the next commit. * Remove "custom-control" tests for radios and check boxes * Rename ".custom-file" to ".form-file" * Change all ".form-group" uses to ".mb-3" Bootstrap 5 is now recommending using bottom margin utilities to control group spacing, and has removed ".form-group" entirely. * Replace ".form-row" with gutter utils (".g-3") Some methods in FormGroup were refactored to meet a RuboCop lint complexity requirement. I don't personally think the refactor is necessary but it won't pass CI without it. * Replace ".form-inline" where necessary Bootstrap 5 removes ".form-inline" in favor of the usage of ".col-auto" and the new gutter utilities. * Remove wrapper divs for elements prepended/appended to input groups Bootstrap 5 removes ".input-group-prepend" and ".input-group-append", they are no longer necessary. You can now add buttons and ".input-group-text" as direct children of the input groups. * Add ".form-label" to all generated label tags * Fix broken tests after label class change * Fix switch style check boxes My heavy-handedness with the previous commits removed the ability to use switch style checkboxes when I removed the custom check box classes. * Update switch checkbox syntax in README.md * Add anchors for stricter #classes_include_gutters? * Handle string or array of classes for check boxes and radio buttons The Rails view helpers that accept a `class` option accept both single strings and arrays of strings, so this change makes the CSS class array builder agnostic to the input type. I'm now also noticing that the result already had `#flatten` called on it, so this probably wasn't an issue, but this is nicer! * Use only form-check-label class for check box and radio button labels Thanks to @thimo for catching this one. * Change select box class from "form-control" to "form-select" This required some extra effort because all the select forms inherited their control class from the base input class.
With the Bootstrap 5 alpha out today, I thought I'd see how hard it would be to update the gem to support the latest alpha release.
This is a work-in-progress PR, but it does seem to be working, at least with the demo application forms. More work needs to be put into updating parts of the README.
I've also questionably removed some tests that I should probably look into figuring out if they're actually tests that should be removed, or slightly reworked.
One thing that might be worth discussing is Bootstrap 5's removal of the
.form-group
class. The concept is pretty hard-wired into the gem. Even though the class is gone, the "concept" of the form group wrapper is still there, just replaced with the.mb-3
class to maintain the margin on the div. I don't think it would necessarily be a bad thing to keep using the form group terminology within the code base.I haven't contributed here before, but any existing maintainers should feel free to push to this branch with changes you feel are necessary. If you'd like to go for a more methodical, less "shotgun search and replace" methodology, I wouldn't be offended if my efforts here were scrapped.