2017-09-18 14:12:01 +03:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import remcalc from 'remcalc';
|
|
|
|
|
|
|
|
import theme from '../../../theme';
|
|
|
|
|
|
|
|
const Span = styled.span`
|
2017-09-20 12:35:44 +03:00
|
|
|
font-size: ${remcalc(13)};
|
2017-09-18 14:12:01 +03:00
|
|
|
position: absolute;
|
2017-09-18 20:23:17 +03:00
|
|
|
top: ${remcalc(14)};
|
2017-09-18 14:12:01 +03:00
|
|
|
right: ${props => (props.type === 'max' ? '1px' : 'auto')};
|
2017-09-20 12:35:44 +03:00
|
|
|
color: ${props => (props.greyed ? theme.greyLight : theme.secondary)};
|
2017-09-18 14:12:01 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
* @param {Object} props
|
|
|
|
* @param {InputRangeClassNames} props.classNames
|
|
|
|
* @param {Function} props.formatLabel
|
|
|
|
* @param {string} props.type
|
|
|
|
*/
|
|
|
|
export default function Label(props) {
|
|
|
|
const labelValue = props.formatLabel
|
|
|
|
? props.formatLabel(props.children, props.type)
|
|
|
|
: props.children;
|
|
|
|
|
2017-09-20 12:35:44 +03:00
|
|
|
return (
|
|
|
|
<Span greyed={props.greyed} type={props.type}>
|
|
|
|
{labelValue}
|
|
|
|
</Span>
|
|
|
|
);
|
2017-09-18 14:12:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {Object}
|
|
|
|
* @property {Function} children
|
|
|
|
* @property {Function} classNames
|
|
|
|
* @property {Function} formatLabel
|
|
|
|
* @property {Function} type
|
|
|
|
*/
|
|
|
|
Label.propTypes = {
|
|
|
|
children: PropTypes.node.isRequired,
|
2017-09-18 20:23:17 +03:00
|
|
|
classNames: PropTypes.objectOf(PropTypes.string),
|
2017-09-18 14:12:01 +03:00
|
|
|
formatLabel: PropTypes.func,
|
2017-09-20 12:35:44 +03:00
|
|
|
type: PropTypes.string,
|
|
|
|
greyed: PropTypes.bool
|
2017-09-18 14:12:01 +03:00
|
|
|
};
|