Skip to content

Commit

Permalink
imp: Improve look and behaviour of disabled checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
marien-probesys committed Jan 30, 2024
1 parent 272eec1 commit 8862664
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions assets/javascripts/controllers/checkboxes_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class extends Controller {
}

checkAll (event) {
const checkboxes = this.element.querySelectorAll('input[type="checkbox"]');
const checkboxes = this.element.querySelectorAll('input[type="checkbox"]:not([disabled])');

checkboxes.forEach((checkbox) => {
checkbox.checked = true;
Expand All @@ -24,7 +24,7 @@ export default class extends Controller {
}

uncheckAll (event) {
const checkboxes = this.element.querySelectorAll('input[type="checkbox"]');
const checkboxes = this.element.querySelectorAll('input[type="checkbox"]:not([disabled])');

checkboxes.forEach((checkbox) => {
checkbox.checked = false;
Expand Down
9 changes: 7 additions & 2 deletions assets/stylesheets/components/forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ input[type="checkbox"]:focus + label::before {
outline: var(--width-outline) solid var(--color-primary9);
}

input[type="checkbox"]:checked + label::before,
input[type="radio"]:checked + label::before {
input[type="checkbox"]:not([disabled]):checked + label::before,
input[type="radio"]:not([disabled]):checked + label::before {
border-color: var(--color-grey11);
}

Expand Down Expand Up @@ -172,6 +172,11 @@ input[type="radio"]:checked + label::after {
border-radius: 50%;
}

input[type="checkbox"]:disabled:checked + label::after,
input[type="radio"]:disabled:checked + label::after {
border-color: var(--color-grey11);
}

select {
width: 100%;
padding: 0.5rem 0.75rem;
Expand Down

0 comments on commit 8862664

Please sign in to comment.