Skip to content

Commit

Permalink
Minor v5 cleanup (#334)
Browse files Browse the repository at this point in the history
* remove static id attributes

* simplify application.scss

via: https://github.com/twbs/bootstrap-rubygem

* import bootstrap library
  * reduce maintenance

* fix issues with border-radius on input_groups

* fix input_group tests
  • Loading branch information
m5o committed May 21, 2021
1 parent 8038169 commit 1468d46
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 55 deletions.
54 changes: 7 additions & 47 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -1,56 +1,16 @@
/*
* Keep in sync with `assets/stylesheets/_bootstrap.scss` from
* `bootstrap-rubygem`.
*/

// 1. Include functions & variables first
@import "bootstrap/functions";

$custom-colors: ( "bootstrap": #563d7c, "simpleform": #00617f );

@import "bootstrap/variables";
@import "bootstrap/mixins";

$custom-colors: (
"bootstrap": #563d7c,
"simpleform": #00617f
);
$theme-colors: map-merge($theme-colors, $custom-colors);

@import "bootstrap/utilities";

// Layout & components
@import "bootstrap/root";
@import "bootstrap/reboot";
@import "bootstrap/type";
@import "bootstrap/images";
@import "bootstrap/containers";
@import "bootstrap/grid";
@import "bootstrap/tables";
@import "bootstrap/forms";
@import "bootstrap/buttons";
@import "bootstrap/transitions";
@import "bootstrap/dropdown";
@import "bootstrap/button-group";
@import "bootstrap/nav";
@import "bootstrap/navbar";
@import "bootstrap/card";
@import "bootstrap/accordion";
@import "bootstrap/breadcrumb";
@import "bootstrap/pagination";
@import "bootstrap/badge";
@import "bootstrap/alert";
@import "bootstrap/progress";
@import "bootstrap/list-group";
@import "bootstrap/close";
@import "bootstrap/toasts";
@import "bootstrap/modal";
@import "bootstrap/tooltip";
@import "bootstrap/popover";
@import "bootstrap/carousel";
@import "bootstrap/spinners";
@import "bootstrap/offcanvas";

// Helpers
@import "bootstrap/helpers";
// Custom bootstrap variables must be set or imported *before* bootstrap.
@import "bootstrap";

// Utilities
@import "bootstrap/utilities/api";

// App sections
@import "application/breadcrumb";
Expand Down
8 changes: 4 additions & 4 deletions app/views/examples/input_groups/_bootstrap.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="mb-3">
<label for="exampleInputName" class="form-label">Name</label>
<div class="input-group has-validation">
<span class="input-group-text" id="basic-addon1">@</span>
<span class="input-group-text">@</span>
<input type="text" class="form-control" id="exampleInputName" placeholder="Your name" required>
<div class="invalid-feedback">Name can't be blank</div>
<div class="valid-feedback">Looks good!</div>
Expand All @@ -15,9 +15,9 @@
<div class="mb-3">
<label for="exampleInputEmail" class="form-label">Email</label>
<div class="input-group has-validation">
<span class="input-group-text" id="basic-addon1">example-</span>
<span class="input-group-text">example-</span>
<input type="email" class="form-control" id="exampleInputEmail" placeholder="Enter email" autocomplete="email" required>
<span class="input-group-text" id="basic-addon1">@gmail.com</span>
<span class="input-group-text">@gmail.com</span>
<div class="invalid-feedback">Email can't be blank</div>
<div class="valid-feedback">Looks good!</div>
</div>
Expand All @@ -28,7 +28,7 @@
<label for="exampleInputPassword" class="form-label">Password</label>
<div class="input-group has-validation">
<input type="password" class="form-control" id="exampleInputPassword" placeholder="Password" autocomplete="current-password" required>
<span class="input-group-text" id="basic-addon1">🙊</span>
<span class="input-group-text">🙊</span>
<div class="invalid-feedback">Please provide a valid value.</div>
<div class="valid-feedback">Looks good!</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/simple_form_bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
b.optional :min_max
b.optional :readonly
b.use :label, class: 'form-label'
b.wrapper :input_group_tag, class: 'input-group has-validation' do |ba|
b.wrapper :input_group_tag, class: 'input-group' do |ba|
ba.optional :prepend
ba.use :input, class: 'form-control', error_class: 'is-invalid', valid_class: 'is-valid'
ba.optional :append
Expand Down
6 changes: 3 additions & 3 deletions test/simple_form-bootstrap/input_group_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_input_group_prepend
expected = <<-HTML
<div class="mb-3 string required user_name">
<label class="form-label string required" for="user_name">Name <abbr title="required">*</abbr></label>
<div class="input-group has-validation">
<div class="input-group">
<span class="input-group-text">$</span>
<input class="form-control string required" id="user_name" name="user[name]" placeholder="Your name" type="text"/>
</div>
Expand All @@ -26,7 +26,7 @@ def test_input_group_append
expected = <<-HTML
<div class="mb-3 string required user_name">
<label class="form-label string required" for="user_name">Name <abbr title="required">*</abbr></label>
<div class="input-group has-validation">
<div class="input-group">
<input class="form-control string required" id="user_name" name="user[name]" placeholder="Your name" type="text"/>
<span class="input-group-text">.00</span>
</div>
Expand All @@ -41,7 +41,7 @@ def test_input_group_prepend_and_append
expected = <<-HTML
<div class="mb-3 string required user_name">
<label class="form-label string required" for="user_name">Name <abbr title="required">*</abbr></label>
<div class="input-group has-validation">
<div class="input-group">
<span class="input-group-text">$</span>
<input class="form-control string required" id="user_name" name="user[name]" placeholder="Your name" type="text"/>
<span class="input-group-text">.00</span>
Expand Down

0 comments on commit 1468d46

Please sign in to comment.