Checkboxes and radios improvements

This commit is contained in:
María Checa 2016-02-02 12:11:08 +01:00
parent fe2439a98b
commit 83984f6bca
3 changed files with 125 additions and 139 deletions

View File

@ -7,15 +7,15 @@
``` ```
<div class="u-iBlock"> <div class="u-iBlock">
<input class="CDB-Checkbox" type="checkbox" name="vehicle" value="Bike" checked> <input class="CDB-Checkbox" type="checkbox" name="vehicle" value="Bike" checked>
<span class="u-iBlock CDB-CheckboxFace"></span> <span class="u-iBlock CDB-Checkbox-face"></span>
</div> </div>
<div class="u-iBlock"> <div class="u-iBlock">
<input class="CDB-Checkbox" type="checkbox" name="vehicle" value="Bus"> <input class="CDB-Checkbox" type="checkbox" name="vehicle" value="Bus">
<span class="u-iBlock CDB-CheckboxFace"></span> <span class="u-iBlock CDB-Checkbox-face"></span>
</div> </div>
<div class="u-iBlock"> <div class="u-iBlock">
<input class="CDB-Checkbox" type="checkbox" name="vehicle" value="Car" disabled> <input class="CDB-Checkbox" type="checkbox" name="vehicle" value="Car" disabled>
<span class="u-iBlock CDB-CheckboxFace"></span> <span class="u-iBlock CDB-Checkbox-face"></span>
</div> </div>
``` ```
*/ */
@ -30,78 +30,71 @@
position: absolute; position: absolute;
vertical-align: middle; vertical-align: middle;
z-index: 1; z-index: 1;
}
~ .CDB-CheckboxFace { .CDB-Checkbox-face {
position: relative; position: relative;
width: $baseSize * 2; width: $baseSize * 2;
height: $baseSize * 2; height: $baseSize * 2;
border: 1px solid $cMainLine; border: 1px solid $cMainLine;
border-radius: 3px; border-radius: 3px;
background: $cWhite; background: $cWhite;
cursor: pointer; cursor: pointer;
box-sizing: border-box; box-sizing: border-box;
&::before, &::before,
&::after { &::after {
display: block; display: block;
position: absolute; position: absolute;
bottom: 3px; bottom: 3px;
width: 2px; width: 2px;
border-radius: 1px; border-radius: 1px;
background: $cSecondaryLine; background: $cSecondaryLine;
content: ''; content: '';
}
&::before {
right: $baseSize / 2;
height: $baseSize;
transform: rotate(45deg);
}
&::after {
left: $baseSize / 2;
height: $baseSize - 2;
transform: rotate(-45deg);
}
} }
&:checked { &::before {
~ .CDB-CheckboxFace { right: $baseSize / 2;
border: 1px solid $cBlue; height: $baseSize;
background: $cBlue; transform: rotate(45deg);
}
~ .CDB-CheckboxFace::before,
~ .CDB-CheckboxFace::after {
background: $cWhite;
}
&:hover ~ .CDB-CheckboxFace {
border: 1px solid $cBlue;
}
} }
&:focus ~ .CDB-CheckboxFace { &::after {
border: 1px solid $cBlue; left: $baseSize / 2;
} height: $baseSize - 2;
transform: rotate(-45deg);
&:hover ~ .CDB-CheckboxFace {
border: 1px solid $cHoverLine;
}
&:disabled {
~ .CDB-CheckboxFace {
border: 1px solid $cSecondaryLine;
background: $cThirdBackground;
}
~ .CDB-CheckboxFace::before,
~ .CDB-CheckboxFace::after {
background: $cWhite;
}
&:hover ~ .CDB-CheckboxFace {
border: 1px solid $cSecondaryLine;
}
} }
} }
.CDB-Checkbox:checked + .CDB-Checkbox-face {
border: 1px solid $cBlue;
background: $cBlue;
&::before,
&::after {
background: $cWhite;
}
}
.CDB-Checkbox:disabled + .CDB-Checkbox-face {
border: 1px solid $cSecondaryLine;
background: $cThirdBackground;
&::before,
&::after {
background: $cWhite;
}
}
.CDB-Checkbox:disabled:hover ~ .CDB-Checkbox-face {
border: 1px solid $cSecondaryLine;
}
.CDB-Checkbox:checked:hover + .CDB-Checkbox-face,
.CDB-Checkbox:focus + .CDB-Checkbox-face {
border: 1px solid $cBlue;
}
.CDB-Checkbox:hover + .CDB-Checkbox-face {
border: 1px solid $cHoverLine;
}

View File

@ -7,12 +7,12 @@
``` ```
<div class="u-iBlock CDB-Text CDB-Size-medium u-rSpace--xl"> <div class="u-iBlock CDB-Text CDB-Size-medium u-rSpace--xl">
<input class="CDB-Radio" type="radio" name="veritas" value="01"> <input class="CDB-Radio" type="radio" name="veritas" value="01">
<span class="u-iBlock CDB-RadioFace"></span> <span class="u-iBlock CDB-Radio-face"></span>
<label class="u-iBlock u-lSpace">True</label> <label class="u-iBlock u-lSpace">True</label>
</div> </div>
<div class="u-iBlock CDB-Text CDB-Size-medium u-rSpace--xl"> <div class="u-iBlock CDB-Text CDB-Size-medium u-rSpace--xl">
<input class="CDB-Radio" type="radio" name="veritas" value="02" checked> <input class="CDB-Radio" type="radio" name="veritas" value="02" checked>
<span class="u-iBlock CDB-RadioFace"></span> <span class="u-iBlock CDB-Radio-face"></span>
<label class="u-iBlock u-lSpace">False</label> <label class="u-iBlock u-lSpace">False</label>
</div> </div>
@ -22,12 +22,12 @@
<div class="u-iblock CDB-Text CDB-Size-medium u-rSpace--xl"> <div class="u-iblock CDB-Text CDB-Size-medium u-rSpace--xl">
<input class="CDB-Checkbox" type="checkbox" name="hobbies" value="Sport"> <input class="CDB-Checkbox" type="checkbox" name="hobbies" value="Sport">
<span class="u-iBlock CDB-CheckboxFace"></span> <span class="u-iBlock CDB-Checkbox-face"></span>
<label class="u-iBlock u-lSpace">Sport</label> <label class="u-iBlock u-lSpace">Sport</label>
</div> </div>
<label class="u-iblock CDB-Text CDB-Size-medium"> <label class="u-iblock CDB-Text CDB-Size-medium">
<input class="CDB-Checkbox" type="checkbox" name="hobbies" value="Travel"> <input class="CDB-Checkbox" type="checkbox" name="hobbies" value="Travel">
<span class="u-iBlock CDB-CheckboxFace"></span> <span class="u-iBlock CDB-Checkbox-face"></span>
<label class="u-iBlock u-lSpace">Travel</label> <label class="u-iBlock u-lSpace">Travel</label>
</label> </label>
@ -41,14 +41,14 @@
<li class="u-iBlock u-rSpace--xl"> <li class="u-iBlock u-rSpace--xl">
<div class="u-iblock CDB-Text CDB-Size-medium u-rSpace--xl"> <div class="u-iblock CDB-Text CDB-Size-medium u-rSpace--xl">
<input class="CDB-Checkbox" type="checkbox" name="hobbies" value="Sport"> <input class="CDB-Checkbox" type="checkbox" name="hobbies" value="Sport">
<span class="u-iBlock CDB-CheckboxFace"></span> <span class="u-iBlock CDB-Checkbox-face"></span>
<label class="u-iBlock u-lSpace">Sport</label> <label class="u-iBlock u-lSpace">Sport</label>
</div> </div>
</li> </li>
<li class="u-iblock"> <li class="u-iblock">
<label class="u-iblock CDB-Text CDB-Size-medium"> <label class="u-iblock CDB-Text CDB-Size-medium">
<input class="CDB-Checkbox" type="checkbox" name="hobbies" value="Travel"> <input class="CDB-Checkbox" type="checkbox" name="hobbies" value="Travel">
<span class="u-iBlock CDB-CheckboxFace"></span> <span class="u-iBlock CDB-Checkbox-face"></span>
<label class="u-iBlock u-lSpace">Travel</label> <label class="u-iBlock u-lSpace">Travel</label>
</label> </label>
</li> </li>

View File

@ -8,15 +8,15 @@
``` ```
<div class="u-iBlock"> <div class="u-iBlock">
<input class="CDB-Radio" type="radio" name="gender" value="01" checked> <input class="CDB-Radio" type="radio" name="gender" value="01" checked>
<span class="u-iBlock CDB-RadioFace"></span> <span class="u-iBlock CDB-Radio-face"></span>
</div> </div>
<div class="u-iBlock"> <div class="u-iBlock">
<input class="CDB-Radio" type="radio" name="gender" value="02"> <input class="CDB-Radio" type="radio" name="gender" value="02">
<span class="u-iBlock CDB-RadioFace"></span> <span class="u-iBlock CDB-Radio-face"></span>
</div> </div>
<div class="u-iBlock"> <div class="u-iBlock">
<input class="CDB-Radio" type="radio" name="gender" value="03" disabled> <input class="CDB-Radio" type="radio" name="gender" value="03" disabled>
<span class="u-iBlock CDB-RadioFace"></span> <span class="u-iBlock CDB-Radio-face"></span>
</div> </div>
``` ```
*/ */
@ -31,67 +31,60 @@
position: absolute; position: absolute;
vertical-align: middle; vertical-align: middle;
z-index: 1; z-index: 1;
}
~ .CDB-RadioFace { .CDB-Radio-face {
position: relative; position: relative;
width: $baseSize * 2; width: $baseSize * 2;
height: $baseSize * 2; height: $baseSize * 2;
border: 1px solid $cMainLine; border: 1px solid $cMainLine;
border-radius: 50%;
background: $cWhite;
text-indent: 20px;
cursor: pointer;
box-sizing: border-box;
&::before {
position: absolute;
top: 50%;
left: 50%;
width: $baseSize - 2;
height: $baseSize - 2;
margin-top: -3px;
margin-left: -3px;
border-radius: 50%; border-radius: 50%;
background: $cWhite; background: $cSecondaryLine;
text-indent: 20px; content: '';
cursor: pointer;
box-sizing: border-box;
&::before {
position: absolute;
top: 50%;
left: 50%;
width: $baseSize - 2;
height: $baseSize - 2;
margin-top: -3px;
margin-left: -3px;
border-radius: 50%;
background: $cSecondaryLine;
content: '';
}
}
&:checked {
~ .CDB-RadioFace {
border: 1px solid $cBlue;
background: $cBlue;
}
~ .CDB-RadioFace::before {
background: $cWhite;
}
&:hover ~ .CDB-RadioFace {
border: 1px solid $cBlue;
}
}
&:focus ~ .CDB-RadioFace {
border: 1px solid $cBlue;
}
&:hover ~ .CDB-RadioFace {
border: 1px solid $cHoverLine;
}
&:disabled {
~ .CDB-RadioFace {
border: 1px solid $cSecondaryLine;
background: $cThirdBackground;
}
~ .CDB-RadioFace::before {
background: $cWhite;
}
&:hover ~ .CDB-RadioFace {
border: 1px solid $cSecondaryLine;
}
} }
} }
.CDB-Radio:checked + .CDB-Radio-face {
border: 1px solid $cBlue;
background: $cBlue;
&::before {
background: $cWhite;
}
}
.CDB-Radio:disabled + .CDB-Radio-face {
border: 1px solid $cSecondaryLine;
background: $cThirdBackground;
&::before {
background: $cWhite;
}
}
.CDB-Radio:disabled:hover + .CDB-Radio-face {
border: 1px solid $cSecondaryLine;
}
.CDB-Radio:hover + .CDB-Radio-face {
border: 1px solid $cHoverLine;
}
.CDB-Radio:focus + .CDB-Radio-face,
.CDB-Radio:checked:hover + .CDB-Radio-face {
border: 1px solid $cBlue;
}