jobiqo-cl
Version:
[](https://circleci.com/gh/jobiqo/jobiqo-cl)
126 lines (113 loc) • 3.57 kB
JavaScript
import styled from 'styled-components';
const ToggleGroup = styled.div `
position: relative;
display: flex;
flex-direction: row-reverse;
height: auto;
height: ${props => (props.height ? props.height : props.theme.toggle.height) + 5};
margin-top: ${props => ((props.height ? props.height : props.theme.toggle.height) + 5) / 2}px;
opacity: ${props => (props.disabled ? '0.5' : '1')};
.onoffswitch {
position: relative;
width: ${props => (props.width ? props.width : props.theme.toggle.width)}px;
display: inline-block;
font-size: 80%;
.onoffswitch-label {
display: block;
overflow: hidden;
cursor: pointer;
border: 1px solid ${props => props.theme.colors.gray1};
border-radius: ${props => props.theme.toggle.borderRadius};
margin: 0;
}
.onoffswitch-inner {
width: 200%;
margin-left: -100%;
transition: margin 0.15s ease-in-out;
&:before,
&:after {
float: left;
width: 50%;
height: ${props => (props.height ? props.height : props.theme.toggle.height) + 2}px;
padding: 0;
line-height: ${props => (props.height ? props.height : props.theme.toggle.height) + 2}px;
font-size: 80%;
color: ${props => props.theme.toggle.backgroundColor[props.switchStyle]};
font-weight: normal;
box-sizing: border-box;
}
&:before {
content: '${props => props.textOn}';
padding-left: 10px;
background-color: ${props => props.theme.toggle.backgroundColor[props.switchStyle]};
color: ${props => props.theme.toggle.color[props.switchStyle]};
}
&:after {
content: '${props => props.textOff}';
padding-right: 10px;
background-color: ${props => props.theme.colors.gray2};
color: ${props => props.theme.font.color};
text-align: right;
}
}
.onoffswitch-switch {
width: ${props => (props.height ? props.height : props.theme.toggle.height) + 4}px;
height: ${props => (props.height ? props.height : props.theme.toggle.height) + 4}px;
margin: 0;
background: ${props => props.theme.toggle.circleBackground[props.switchStyle]};
box-shadow: ${props => props.theme.toggle.boxShadow};
border-radius: ${props => props.theme.toggle.switchBorderRadius};
position: absolute;
top: 0;
bottom: 0;
right: ${props => (props.width ? props.width : props.theme.toggle.width) / 2}px;
transition: right 0.15s ease-in-out;
}
}
`;
const ToggleLabel = styled.label `
width: auto;
position: relative;
padding: 0;
display: block;
height: auto;
cursor: pointer;
margin-left: 0.5rem;
display: inline-block;
text-align: left;
width: 100%;
z-index: 1;
font-weight: 200;
`;
const ToggleInput = styled.input `
visibility: hidden;
opacity: 0;
&:checked ~ .onoffswitch .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
&:checked ~ .onoffswitch .onoffswitch-label .onoffswitch-switch {
right: 1px;
box-shadow: ${props => props.theme.toggle.boxShadow};
}
&:focus ~ .onoffswitch {
outline: thin dotted #333;
outline: 0;
}
`;
const Aural = styled.span `
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
overflow: hidden;
position: absolute;
width: 1px;
&:focus {
clip: rect(0, 0, 0, 0);
font-size: 1em;
height: auto;
outline: thin dotted;
position: static !important;
width: auto;
overflow: visible;
}
`;
export { Aural, ToggleGroup, ToggleInput, ToggleLabel };