tweb-i2p/src/scss/partials/_checkbox.scss

224 lines
4.2 KiB
SCSS
Raw Normal View History

.checkbox-field {
2021-01-20 01:38:59 +00:00
--size: 18px;
margin: 1.5rem 1.1875rem;
display: block;
text-align: left;
position: relative;
cursor: pointer;
2021-01-20 01:38:59 +00:00
min-width: var(--size);
min-height: var(--size);
@include respond-to(handhelds) {
margin-bottom: 27px;
}
2021-01-20 01:38:59 +00:00
.checkbox-box {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: var(--size);
height: var(--size);
border-radius: 3px;
overflow: hidden;
html.is-safari & {
-webkit-mask-image: -webkit-radial-gradient(circle, white 100%, black 100%); // fix safari overflow
}
&-check, &-background, &-border {
position: absolute;
2021-01-20 01:38:59 +00:00
top: 0;
left: 0;
}
2021-01-03 15:59:13 +00:00
2021-01-20 01:38:59 +00:00
&-border {
right: 0;
bottom: 0;
border-radius: inherit;
border: 2px solid #8d969c;
//border-color: #000;
}
2021-01-20 01:38:59 +00:00
&-background {
top: -15%;
right: -15%;
bottom: -15%;
left: -15%;
background-color: $button-primary-background;
transform: scale(1);
transition: transform .2s 0s ease-in-out;
border-radius: 50%;
2021-01-20 01:38:59 +00:00
}
2021-01-03 15:59:13 +00:00
2021-01-20 01:38:59 +00:00
&-check {
--offset: 1px;
width: calc(var(--size) - var(--offset));
height: calc(var(--size) - var(--offset));
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
use {
stroke: #fff;
stroke-width: 2.75;
stroke-linecap: round;
stroke-dasharray: 24.19, 24.19;
stroke-dashoffset: 0;
transition: stroke-dasharray .1s .2s ease-in-out, visibility 0s .2s;
2021-01-03 15:59:13 +00:00
}
}
}
2021-01-20 01:38:59 +00:00
.checkbox-caption {
position: relative;
padding-left: 3.3125rem;
cursor: pointer;
display: inline-block;
height: 24px;
line-height: 26px;
user-select: none;
transition: .2s opacity;
body.animation-level-0 & {
transition: none;
}
2021-01-20 01:38:59 +00:00
}
}
2021-01-20 01:38:59 +00:00
.checkbox-field-round {
--size: 1.5rem;
.checkbox-box {
border-radius: 50%;
&-border {
border: 2px solid #fff;
z-index: 1;
}
&-check {
--offset: 10px;
}
}
}
.radio-field {
position: relative;
text-align: left;
margin: 1.25rem 0;
line-height: 1.5rem;
cursor: pointer;
&.hidden-widget {
cursor: default;
.radio-field-main {
&::before, &::after {
visibility: hidden;
}
}
}
> input {
&:checked {
& ~ .radio-field-main {
&::before {
border-color: $button-primary-background;
}
&::after {
opacity: 1;
}
}
}
}
// ! can't use &-main here, check popup create poll
.radio-field-main {
padding-left: 3.5rem;
position: relative;
&::before, &::after {
content: '';
display: block;
position: absolute;
left: 0;
top: 50%;
width: 1.25rem;
height: 1.25rem;
transform: translateY(-50%);
2021-01-03 15:59:13 +00:00
body.animation-level-0 & {
transition: none;
}
}
&::before {
border: 2px solid #8d969c;
border-radius: 50%;
background-color: white;
opacity: 1;
transition: border-color .1s ease, opacity .1s ease;
}
&::after {
left: .3125rem;
width: .625rem;
height: .625rem;
border-radius: 50%;
background: $button-primary-background;
opacity: 0;
transition: opacity .1s ease;
}
/* &-subtitle {
color: #707579 !important;
font-size: 14px !important;
} */
}
/* &-with-subtitle {
.radio-field-main {
margin-bottom: 1.5rem;
&-subtitle {
margin-bottom: -1.5rem;
}
}
} */
}
[type="checkbox"], [type="radio"] {
box-sizing: border-box;
padding: 0;
opacity: 0;
z-index: var(--z-below);
position: absolute;
}
.checkbox-field [type="checkbox"] {
2021-01-20 01:38:59 +00:00
&:not(:checked) + .checkbox-box {
.checkbox-box-check {
use {
stroke-dasharray: 0, 24.19;
visibility: hidden;
transition: stroke-dasharray .1s ease-in-out, visibility 0s .1s;
2021-01-03 15:59:13 +00:00
}
}
2021-01-20 01:38:59 +00:00
.checkbox-box-background {
transition: transform .2s .1s ease-in-out;
transform: scale(0);
}
}
2021-01-20 01:38:59 +00:00
&:checked + .checkbox-box {
}
2021-01-20 01:38:59 +00:00
&:disabled + .checkbox-box, &:disabled ~ .checkbox-caption {
cursor: default;
opacity: .25;
}
}