diff --git a/packages/strapi-helper-plugin/lib/src/components/Label/index.js b/packages/strapi-helper-plugin/lib/src/components/Label/index.js new file mode 100644 index 0000000000..73e946e51f --- /dev/null +++ b/packages/strapi-helper-plugin/lib/src/components/Label/index.js @@ -0,0 +1,57 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { FormattedMessage } from 'react-intl'; +import { isFunction, isObject, upperFirst } from 'lodash'; +import cn from 'classnames'; + +import styles from './styles.scss'; + +function Label(props) { + let content = props.children; + + if (typeof(props.value) === 'string') { + content = props.value; + } + + if (isObject(props.value) && props.value.id) { + content = ; + } + + if (isFunction(props.value)) { + content = props.value(); + } + + return ( + + ); +} + +Label.defaultProps = { + children: '', + className: '', + style: {}, + values: '', +}; + +Label.propTypes = { + children: PropTypes.node, + className: PropTypes.string, + htmlFor: PropTypes.string.isRequired, + style: PropTypes.object, + values: PropTypes.oneOfType([ + PropTypes.func, + PropTypes.string, + PropTypes.shape({ + id: PropTypes.string, + params: PropTypes.object, + }), + ]), +}; + +export default Label; diff --git a/packages/strapi-helper-plugin/lib/src/components/Label/styles.scss b/packages/strapi-helper-plugin/lib/src/components/Label/styles.scss new file mode 100644 index 0000000000..eea081e65d --- /dev/null +++ b/packages/strapi-helper-plugin/lib/src/components/Label/styles.scss @@ -0,0 +1,4 @@ +.label { + margin-bottom: 0; + font-weight: 500; +}