function k( selector ) {
class K {
constructor( selector ) {
if ( ( selector === window ) || ( selector instanceof Node ) || ( selector instanceof HTMLElement ) ) {
this.el = selector;
} else {
this.el = document;
this.find( selector );
}
}
find( selector ) {
console.log( selector );
this.el = this.el.querySelector( selector );
return this;
}
on( event, handler ) {
this.el.addEventListener( event, handler );
}
off( event, handler ) {
this.el.removeEventListener( event, handler );
}
}
return new K( selector );
}
export default k;
Object.prototype.find = function( selector ) {
return this.querySelector( selector );
}
document.addEventListener( 'DOMContentLoaded', function() {
ksf.declaration.forEach( function( component ) {
let elList = document.querySelectorAll( component.elSelector );
elList.forEach( function( el ) {
ksf.components[ el.dataset.id ] = new component.classDecl( el );
} );
} );
} );
.checkbox {
min-width: $fr-1;
padding: $gap-sm / 2;
&:focus {
.checkbox__control {
box-shadow: 0 0 0 3px rgba($primary, 0.35);
}
}
&__label {
display: flex;
align-items: center;
color: $dark;
}
&__input {
display: none;
&:hover {
+ .checkbox__label {
.checkbox__control {
background-color: $light2;
}
}
}
&:checked {
+ .checkbox__label {
.checkbox__control {
background-color: $primary;
&::after {
opacity: 1;
}
}
}
}
}
&__control {
position: relative;
display: inline-block;
width: 24px;
height: 24px;
margin-right: $gap-xs;
border: 0;
border-radius: 5px;
background-color: $light;
transition: 0.2s;
&::after {
@include fa-icon(f00c, 16px);
position: absolute;
top: 50%;
left: 50%;
color: $color-white;
opacity: 0;
transform: translate(-50%, -50%);
}
}
}