joyent-portal/ui/src/components/add-metric/button.js

54 lines
1005 B
JavaScript
Raw Normal View History

const React = require('react');
const Styled = require('styled-components');
const fns = require('../../shared/functions');
const Button = require('../button');
const {
default: styled
} = Styled;
const {
remcalc
} = fns;
const StyledButton = styled(Button)`
position: absolute;
left: ${remcalc(24)};
bottom: ${remcalc(24)};
`;
const AddMetricButton = ({
children,
disabled,
2017-01-12 14:17:25 +02:00
metric,
onClick
}) => {
2017-01-12 14:17:25 +02:00
const onButtonClick = (e) => onClick(metric);
return disabled ?
(
<StyledButton
disabled
name='add-metric-button'
>
{children}
</StyledButton>
) : (
<StyledButton
name='add-metric-button'
2017-01-12 14:17:25 +02:00
onClick={onButtonClick}
secondary
>
{children}
</StyledButton>
);
};
AddMetricButton.propTypes = {
children: React.PropTypes.node,
disabled: React.PropTypes.bool,
2017-01-12 14:17:25 +02:00
metric: React.PropTypes.string,
onClick: React.PropTypes.func,
};
module.exports = AddMetricButton;