accounts-frontend/src/components/ui/form.scss

237 lines
4.0 KiB
SCSS
Raw Normal View History

@import '~components/ui/colors.scss';
@import '~components/ui/fonts.scss';
@mixin form-transition() {
// Анимация фона должна быть быстрее анимации рамки, т.к. визуально фон заполняется медленнее
transition: border-color .25s,
background-color .20s;
}
/**
* Input
*/
2016-01-09 19:45:03 +05:30
@mixin input-theme($themeName, $color) {
.#{$themeName}TextField {
composes: textField;
&:focus {
border-color: $color;
~ .formFieldIcon {
background: $color;
border-color: $color;
}
}
}
}
.formRow {
position: relative;
height: 50px;
max-width: 100%;
margin: 10px 0;
}
.formIconRow {
composes: formRow;
.textField {
padding-left: 60px;
}
}
.textField {
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
height: 50px;
width: 100%;
border: 2px solid lighter($black);
background: $black;
font-size: 18px;
color: #aaa;
font-family: $font-family-title;
padding: 0 10px;
transition: border-color .25s;
&::placeholder {
opacity: 1;
color: #444;
}
&:hover {
&,
~ .formFieldIcon {
border-color: #aaa;
}
}
&:focus {
color: #fff;
outline: none;
~ .formFieldIcon {
color: #fff;
}
}
}
.formFieldIcon {
box-sizing: border-box;
position: absolute;
left: 0;
top: 0;
height: 50px;
width: 50px;
line-height: 46px;
text-align: center;
border: 2px solid lighter($black);
color: #444;
cursor: default;
@include form-transition();
}
2016-01-09 19:45:03 +05:30
@include input-theme('green', $green);
@include input-theme('blue', $blue);
@include input-theme('red', $red);
@include input-theme('darkBlue', $dark_blue);
@include input-theme('lightViolet', $light_violet);
2016-01-09 19:45:03 +05:30
/**
* Checkbox
*/
2016-01-09 19:45:03 +05:30
@mixin checkbox-theme($themeName, $color) {
.#{$themeName}CheckboxRow {
composes: checkboxRow;
.checkboxContainer {
&:hover {
.checkbox {
border-color: $color;
}
}
}
.checkboxInput {
&:checked {
+ .checkbox {
background: $color;
border-color: $color;
}
}
}
}
}
.checkboxRow {
height: 22px;
margin-top: 15px;
}
.checkboxContainer {
display: inline-block;
position: relative;
padding-left: 27px;
font-family: $font-family-title;
font-size: 16px;
line-height: 24px;
color: #fff;
cursor: pointer;
}
.checkboxPosition {
position: absolute;
box-sizing: border-box;
left: 0;
top: 0;
margin: 0;
width: 22px;
height: 22px;
}
.checkboxInput {
composes: checkboxPosition;
opacity: 0;
&:checked {
+ .checkbox {
&:before {
opacity: 1;
}
}
}
}
.checkbox {
composes: checkboxPosition;
composes: checkmark from './icons.scss';
border: 2px #dcd8cd solid;
font-size: 10px;
line-height: 18px;
@include form-transition();
&:before {
opacity: 0;
transition: opacity 0.3s;
}
}
2016-01-09 19:45:03 +05:30
@include checkbox-theme('green', $green);
@include checkbox-theme('blue', $blue);
@include checkbox-theme('red', $red);
/**
* Form validation
*/
.formTouched .textField:invalid {
box-shadow: none;
&,
~ .formFieldIcon {
border-color: #3e2727;
}
~ .formFieldIcon {
color: #3e2727;
}
&:hover {
&,
~ .formFieldIcon {
border-color: $red;
}
}
&:focus {
border-color: $red;
~ .formFieldIcon {
background: $red;
border-color: $red;
color: #fff;
}
}
}
.formTouched .checkboxInput:invalid {
~ .checkbox {
border-color: $red;
}
}