2016-10-26 20:02:59 +03:00
|
|
|
const React = require('react');
|
2016-12-09 17:04:06 +02:00
|
|
|
const constants = require('../../shared/constants');
|
|
|
|
const Styled = require('styled-components');
|
2016-12-14 15:53:19 +02:00
|
|
|
const fns = require('../../shared/functions');
|
2016-12-09 17:04:06 +02:00
|
|
|
|
|
|
|
const {
|
|
|
|
boxes
|
|
|
|
} = constants;
|
|
|
|
|
2016-12-14 15:53:19 +02:00
|
|
|
const {
|
|
|
|
remcalc
|
|
|
|
} = fns;
|
|
|
|
|
2016-12-09 17:04:06 +02:00
|
|
|
const {
|
|
|
|
default: styled,
|
|
|
|
} = Styled;
|
|
|
|
|
2016-12-14 14:30:25 +02:00
|
|
|
const CustomInputCircle = `
|
|
|
|
content: '';
|
|
|
|
position: absolute;
|
2016-12-14 15:53:19 +02:00
|
|
|
width: 14px;
|
|
|
|
height: 14px;
|
|
|
|
background: #646464;
|
|
|
|
top: -16px;
|
|
|
|
left: 12px;
|
2016-12-14 14:30:25 +02:00
|
|
|
border-radius: 100%;
|
|
|
|
`;
|
|
|
|
|
2016-12-09 17:04:06 +02:00
|
|
|
const StyledInput = styled.input`
|
|
|
|
visibility: hidden;
|
2016-12-14 14:30:25 +02:00
|
|
|
display: none;
|
2016-12-09 17:04:06 +02:00
|
|
|
|
2016-12-14 14:30:25 +02:00
|
|
|
&:checked + span::after {
|
|
|
|
${CustomInputCircle}
|
2016-12-09 17:04:06 +02:00
|
|
|
}
|
2016-12-14 14:30:25 +02:00
|
|
|
&:disabled + span {
|
2016-12-14 15:53:19 +02:00
|
|
|
background-color: #F9f9F9;
|
2016-12-09 17:04:06 +02:00
|
|
|
}
|
2016-12-14 14:30:25 +02:00
|
|
|
&:disabled + span::after {
|
2016-12-09 17:04:06 +02:00
|
|
|
opacity: 0.3;
|
2016-12-14 14:30:25 +02:00
|
|
|
${CustomInputCircle}
|
2016-12-09 17:04:06 +02:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const StyledLabel = styled.label`
|
2016-12-14 14:30:25 +02:00
|
|
|
`;
|
|
|
|
|
2016-12-14 15:53:19 +02:00
|
|
|
const StyledContent = styled.div`
|
|
|
|
margin-left: ${remcalc(45)};
|
|
|
|
padding-top: ${remcalc(10)};
|
|
|
|
`;
|
|
|
|
|
2016-12-14 14:30:25 +02:00
|
|
|
const StyledSpan = styled.span`
|
2016-12-14 15:53:19 +02:00
|
|
|
color: #646464;
|
2016-12-14 14:30:25 +02:00
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
content: '';
|
2016-12-09 17:04:06 +02:00
|
|
|
position: absolute;
|
2016-12-14 15:53:19 +02:00
|
|
|
width: ${remcalc(26)};
|
|
|
|
height: ${remcalc(26)};
|
|
|
|
background-color: #FFFFFF;
|
2016-12-09 17:04:06 +02:00
|
|
|
box-shadow: ${boxes.insetShaddow};
|
|
|
|
border: ${boxes.border.unchecked};
|
2016-12-14 15:53:19 +02:00
|
|
|
top: 5px;
|
|
|
|
left: 5px;
|
2016-12-14 14:30:25 +02:00
|
|
|
border-radius: 100%;
|
|
|
|
}
|
2016-12-09 17:04:06 +02:00
|
|
|
|
2016-12-14 14:30:25 +02:00
|
|
|
&:hover {
|
2016-12-09 17:04:06 +02:00
|
|
|
&::after {
|
2016-12-14 14:30:25 +02:00
|
|
|
opacity: 0.3;
|
2016-12-09 17:04:06 +02:00
|
|
|
}
|
2016-12-14 14:30:25 +02:00
|
|
|
}
|
2016-12-09 17:04:06 +02:00
|
|
|
`;
|
2016-10-26 20:02:59 +03:00
|
|
|
|
|
|
|
const Radio = ({
|
|
|
|
checked,
|
2016-10-28 02:37:31 +03:00
|
|
|
children,
|
2016-10-26 20:02:59 +03:00
|
|
|
className,
|
2016-10-28 02:37:31 +03:00
|
|
|
defaultChecked,
|
|
|
|
disabled = false,
|
2016-10-31 18:02:33 +02:00
|
|
|
form,
|
2016-10-26 20:02:59 +03:00
|
|
|
id,
|
2016-10-28 02:37:31 +03:00
|
|
|
label,
|
|
|
|
name,
|
2016-10-26 20:02:59 +03:00
|
|
|
onChange,
|
2016-10-31 18:02:33 +02:00
|
|
|
readOnly,
|
|
|
|
required,
|
|
|
|
selectionDirection,
|
2016-10-28 02:37:31 +03:00
|
|
|
style,
|
2016-10-31 18:02:33 +02:00
|
|
|
tabIndex,
|
2016-10-28 02:37:31 +03:00
|
|
|
value
|
2016-10-26 20:02:59 +03:00
|
|
|
}) => {
|
|
|
|
|
|
|
|
return (
|
2016-12-14 14:30:25 +02:00
|
|
|
<StyledLabel>
|
|
|
|
<StyledInput
|
|
|
|
checked={checked}
|
|
|
|
defaultChecked={defaultChecked}
|
|
|
|
disabled={disabled}
|
|
|
|
form={form}
|
|
|
|
id={id}
|
|
|
|
name={name}
|
|
|
|
onChange={onChange}
|
|
|
|
readOnly={readOnly}
|
|
|
|
required={required}
|
|
|
|
selectionDirection={selectionDirection}
|
|
|
|
tabIndex={tabIndex}
|
|
|
|
type='radio'
|
|
|
|
value={value}
|
|
|
|
/>
|
|
|
|
<StyledSpan>
|
2016-12-14 15:53:19 +02:00
|
|
|
<StyledContent>
|
|
|
|
{children}
|
|
|
|
</StyledContent>
|
2016-12-14 14:30:25 +02:00
|
|
|
</StyledSpan>
|
|
|
|
</StyledLabel>
|
2016-10-26 20:02:59 +03:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Radio.propTypes = {
|
2016-10-27 12:51:47 +03:00
|
|
|
checked: React.PropTypes.bool,
|
2016-10-28 02:37:31 +03:00
|
|
|
children: React.PropTypes.node,
|
2016-10-26 20:02:59 +03:00
|
|
|
className: React.PropTypes.string,
|
2016-10-28 02:37:31 +03:00
|
|
|
defaultChecked: React.PropTypes.bool,
|
2016-10-27 12:51:47 +03:00
|
|
|
disabled: React.PropTypes.bool,
|
2016-10-31 18:02:33 +02:00
|
|
|
form: React.PropTypes.string,
|
2016-10-27 12:51:47 +03:00
|
|
|
id: React.PropTypes.string,
|
2016-10-28 02:37:31 +03:00
|
|
|
label: React.PropTypes.string,
|
2016-12-13 13:01:18 +02:00
|
|
|
name: React.PropTypes.string,
|
2016-10-27 12:51:47 +03:00
|
|
|
onChange: React.PropTypes.func,
|
2016-10-31 18:02:33 +02:00
|
|
|
readOnly: React.PropTypes.bool,
|
|
|
|
required: React.PropTypes.bool,
|
|
|
|
selectionDirection: React.PropTypes.string,
|
2016-10-27 12:51:47 +03:00
|
|
|
style: React.PropTypes.object,
|
2016-10-31 18:02:33 +02:00
|
|
|
tabIndex: React.PropTypes.string,
|
2016-10-28 02:37:31 +03:00
|
|
|
value: React.PropTypes.string.isRequired
|
2016-10-26 20:02:59 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Radio;
|