import { Subscriber } from 'joy-react-broadcast'; import is from 'styled-is'; import PropTypes from 'prop-types'; import React from 'react'; import Baseline from '../baseline'; import Label from '../label'; const StyledLabel = Label.extend` ${is('right')` float: right; `}; ${is('error')` color: ${props => props.theme.red}; `}; ${is('warning')` color: ${props => props.theme.orange}; `}; ${is('success')` color: ${props => props.theme.green}; `}; `; const Meta = props => { const render = value => { const { meta = {} } = value; const msg = props.children || props.error || props.warning || props.success || meta.error || meta.warning || meta.success || value.error || value.warning || value.success; const hasError = Boolean(props.error || meta.error || value.error); const hasWarning = Boolean(props.warning || meta.warning || value.warning); const hasSuccess = Boolean(props.success || meta.success || value.success); const isRight = !props.left; return ( {msg} ); }; return {render}; }; Meta.propTypes = { children: PropTypes.node, error: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), left: PropTypes.bool, success: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), warning: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]) }; export default Baseline(Meta);