1
0
mirror of https://github.com/yldio/copilot.git synced 2024-09-22 14:23:50 +03:00
copilot/ui/src/components/radio-group/item.js

78 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-10-28 02:37:31 +03:00
const React = require('react');
2016-12-13 13:01:18 +02:00
// const composers = require('../../shared/composers');
const fns = require('../../shared/functions');
const Styled = require('styled-components');
const constants = require('../../shared/constants');
// const {
// verticallyAlignCenter
// } = composers;
const {
remcalc
} = fns;
const {
boxes
} = constants;
const {
default: styled
} = Styled;
const RadioItem = styled.div`
background: #FFFFFF;
border: ${boxes.border.unchecked};
cursor: pointer;
flaot: left;
margin-bottom: ${remcalc(15)};
padding: ${remcalc(25)};
outline: none;
&:last-child {
margin-bottom: initial;
}
&[aria-checked="true"] {
border: ${boxes.border.checked};
2017-01-12 21:41:04 +02:00
box-shadow: ${boxes.borderRadius};
2016-12-13 13:01:18 +02:00
}
&.disabled {
cursor: default;
}
`;
2016-10-28 02:37:31 +03:00
const Item = ({
children,
checked = false,
2016-12-13 13:01:18 +02:00
itemContent = '',
2016-10-28 02:37:31 +03:00
disabled = false,
onClick,
tabIndex
}) => {
return (
2016-12-13 13:01:18 +02:00
<RadioItem
2016-10-28 02:37:31 +03:00
aria-checked={checked}
aria-disabled={disabled}
onClick={onClick}
role='radio'
tabIndex={tabIndex}
>
{children}
2016-12-13 13:01:18 +02:00
</RadioItem>
2016-10-28 02:37:31 +03:00
);
};
Item.propTypes = {
checked: React.PropTypes.bool,
children: React.PropTypes.node,
disabled: React.PropTypes.bool,
2016-12-13 13:01:18 +02:00
itemContent: React.PropTypes.node,
2016-10-28 02:37:31 +03:00
onClick: React.PropTypes.func,
tabIndex: React.PropTypes.number
};
module.exports = Item;