accessible checkbox replacement (button-styled controls)
// from https://html5boilerplate.com/
%visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
white-space: nowrap; /* 1 */
// Extends the .visuallyhidden class to allow the element to be focusable when navigated to via the keyboard:
// https://www.drupal.org/node/897638
&.focusable:active,
&.focusable:focus {
clip: auto;
-webkit-clip-path: none;
clip-path: none;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
white-space: inherit;
}
}
@import 'utilities';
$box-shadow-buttons: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
label {
input[type='checkbox'], input[type='radio'] {
@extend %visuallyhidden;
}
input + span {
cursor: pointer;
display: flex;
font-weight: normal;
align-items: center;
justify-content: center;
background-color: #fff;
border-radius: 0.2rem;
box-shadow: $box-shadow-buttons;
padding: 1.6rem 1.5rem 1.4rem;
transition: background-color 0.2s;
}
input:checked + span {
background-color: #99ffbd;
box-shadow: inset $box-shadow-buttons;
}
input:disabled + span {
opacity: 0.5;
}
input[type='checkbox'].focus-ring + span {
box-shadow: 0 0 2px 1px #333;
}
input[type='checkbox']:checked.focus-ring + span {
box-shadow: 0 0 2px 1px #222;
}
}