saagie-ui
Version:
Saagie UI from Saagie Design System
53 lines (47 loc) • 1.2 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { modifierCSS } from '../../../helpers';
const propTypes = {
children: PropTypes.node.isRequired,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
tag: PropTypes.elementType,
defaultClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
className: PropTypes.string,
color: PropTypes.oneOf(['', 'success', 'warning', 'danger']),
size: PropTypes.oneOf(['', 'sm', 'lg']),
isUppercase: PropTypes.bool,
};
const defaultProps = {
tag: 'label',
defaultClassName: 'sui-a-form-label',
className: '',
color: '',
size: '',
isUppercase: false,
};
export const FormLabel = ({
tag: Tag,
defaultClassName,
className,
color,
size,
isUppercase,
...attributes
}) => {
const classes = classnames(
defaultClassName,
modifierCSS(color),
modifierCSS(size),
isUppercase ? 'as--uppercase' : '',
className
);
return (
<Tag {...attributes} className={classes} />
);
};
FormLabel.propTypes = propTypes;
FormLabel.defaultProps = defaultProps;