spatial-navigation-polyfill
Version:
A polyfill for the spatial navigation
245 lines (209 loc) • 4.59 kB
CSS
/* css for switch */
/* https://codepen.io/guuslieben/pen/YyPRVP */
@import url(https://fonts.googleapis.com/css?family=Roboto:300,500);
* {
margin: 0;
padding: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
html {
height: 280px;
width: 230px;
padding: 12px;
font-size: 14px;
font-weight: 500;
color: rgba(0, 0, 0, 0.64);
}
.align-center {
text-align: center;
}
/* Switch style */
#switch {
display: none;
}
.switch-label {
position: relative;
display: inline-block;
min-width: 180px;
cursor: pointer;
font-size: 15px;
padding: 16px 0 16px 44px;
}
.switch-label:before, .switch-label:after {
content: "";
position: absolute;
margin: 0;
outline: 0;
top: 50%;
-ms-transform: translate(0, -50%);
-webkit-transform: translate(0, -50%);
transform: translate(0, -50%);
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
}
.switch-label:before {
left: 1px;
width: 34px;
height: 14px;
background-color: #9E9E9E;
border-radius: 8px;
}
.switch-label:after {
left: 0;
width: 20px;
height: 20px;
background-color: #FAFAFA;
border-radius: 50%;
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.14), 0 2px 2px 0 rgba(0, 0, 0, 0.098), 0 1px 5px 0 rgba(0, 0, 0, 0.084);
}
#switch:checked + .switch-label:before {
background-color: #A5D6A7;
}
#switch:checked + .switch-label:after {
background-color: #4CAF50;
-ms-transform: translate(80%, -50%);
-webkit-transform: translate(80%, -50%);
transform: translate(80%, -50%);
}
.switch-label .toggle--on {
display: none;
}
.switch-label .toggle--off {
display: inline-block;
}
#switch:checked + .switch-label .toggle--on {
display: inline-block;
}
#switch:checked + .switch-label .toggle--off {
display: none;
}
/* Select */
/* https://codepen.io/pavelvaravko/pen/qjojOr */
.select {
position: relative;
width: 100%;
}
.select-text {
position: relative;
font-family: inherit;
background-color: transparent;
width: 100%;
padding: 10px 10px 10px 0;
font-size: 10px;
border-radius: 0;
border: none;
border-bottom: 1px solid rgba(0,0,0, 0.12);
}
/* Remove focus */
.select-text:focus {
outline: none;
border-bottom: 1px solid rgba(0,0,0, 0);
}
/* Use custom arrow */
.select .select-text {
appearance: none;
-webkit-appearance:none
}
.select:after {
position: absolute;
top: 18px;
right: 10px;
/* Styling the down arrow */
width: 0;
height: 0;
padding: 0;
content: '';
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 6px solid rgba(0, 0, 0, 0.12);
pointer-events: none;
}
/* Label */
.popup-label {
display: block;
margin-top: 18px;
color: #2F80ED;
font-size: 11px;
font-weight: bold;
}
/* Bottom bars */
.select-bar {
position: relative;
display: block;
width: 100%;
}
.select-bar:before, .select-bar:after {
content: '';
height: 2px;
width: 0;
bottom: 1px;
position: absolute;
background: #2F80ED;
transition: 0.2s ease all;
}
.select-bar:before {
left: 50%;
}
.select-bar:after {
right: 50%;
}
/* Active state */
.select-text:focus ~ .select-bar:before, .select-text:focus ~ .select-bar:after {
width: 50%;
}
/* Radio button */
/* https://codepen.io/hansmaad/pen/zBdzxp */
.md-radio {
margin: 8px;
font-size: 12px;
}
.md-radio.md-radio-inline {
display: inline-block;
transform: scale(1);
}
.md-radio input[type="radio"] {
display: none;
}
.md-radio input[type="radio"]:checked + label:before {
border-color: #337ab7;
animation: ripple 0.2s linear forwards;
}
.md-radio input[type="radio"]:checked + label:after {
transform: scale(0.65);
margin: 2px 0 0 2px;
}
.md-radio label {
display: inline-block;
height: 20px;
position: relative;
margin: 5px 0 0 0;
padding: 3px 0 0 30;
margin-bottom: 0;
cursor: pointer;
vertical-align: bottom;
}
.md-radio label:before, .md-radio label:after {
position: absolute;
content: '';
border-radius: 50%;
transition: all .3s ease;
transition-property: transform, border-color;
}
.md-radio label:before {
left: 0;
top: 0;
width: 18px;
height: 18px;
border: 2px solid rgba(0, 0, 0, 0.54);
}
.md-radio label:after {
top: 0px;
left: 0px;
width: 18px;
height: 18px;
transform: scale(0);
background: #337ab7;
}