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

75 lines
1.5 KiB
JavaScript
Raw Normal View History

const React = require('react');
const Styled = require('styled-components');
const fns = require('../../shared/functions');
const constants = require('../../shared/constants');
const Button = require('../button');
const SettingsIcon =
2017-01-23 17:05:51 +02:00
require(
'!babel-loader!svg-react-loader!./icon-settings.svg?name=SettingsIcon'
2017-01-23 17:05:51 +02:00
);
const {
default: styled
} = Styled;
const {
remcalc
} = fns;
const {
colors
} = constants;
const StyledButton = styled(Button)`
position: relative;
display: flex;
margin: 0;
padding: ${remcalc(18)} ${remcalc(24)};
color: ${colors.brandPrimaryColor};
float: right;
background-color: ${colors.brandPrimaryDark};
line-height: 1.5;
border: none;
border-left: solid ${remcalc(1)} ${colors.brandPrimaryDarkest};
&:hover,
&:focus,
&:active,
&:active:hover,
&:active:focus {
background-color: ${colors.brandPrimaryDark};
border: none;
border-left: solid ${remcalc(1)} ${colors.brandPrimaryDarkest};
}
`;
const StyledIcon = styled(SettingsIcon)`
fill: ${colors.brandPrimaryColor};
margin-right: ${remcalc(12)};
`;
const AddMetricButton = ({
children,
2017-01-23 17:05:51 +02:00
metric,
onClick
}) => {
2017-01-23 17:05:51 +02:00
const onButtonClick = (e) => onClick(metric);
return (
<StyledButton
name='add-metric-button'
onClick={onButtonClick}
>
<StyledIcon />
{children}
</StyledButton>
);
};
AddMetricButton.propTypes = {
children: React.PropTypes.node,
2017-01-23 17:05:51 +02:00
metric: React.PropTypes.string,
onClick: React.PropTypes.func,
};
module.exports = AddMetricButton;