saagie-ui
Version:
Saagie UI from Saagie Design System
71 lines (64 loc) • 1.59 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { modifierCSS } from '../../../helpers';
import { Icon } from '../icon/Icon';
const propTypes = {
className: PropTypes.string,
color: PropTypes.oneOf(['', 'warning', 'danger', 'success']),
defaultClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
isActive: PropTypes.bool,
isDisabled: PropTypes.bool,
message: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
tag: PropTypes.elementType,
};
const defaultProps = {
className: '',
color: '',
defaultClassName: 'sui-a-step-indicator__step',
isActive: false,
isDisabled: false,
message: '',
tag: 'button',
};
export const StepIndicatorItem = ({
className,
color,
defaultClassName,
isActive,
isDisabled,
message,
tag: Tag,
...attributes
}) => {
const classes = classnames(
className,
modifierCSS(color),
defaultClassName,
isActive ? 'as--active' : '',
isDisabled ? 'as--disabled' : '',
);
const getIconName = () => {
switch (color) {
case 'danger':
return 'fa-warning';
case 'warning':
return 'fa-warning';
case 'success':
return 'fa-check';
default:
return '';
}
};
return (
<Tag type="button" className={classes} {...attributes}>
{color ? <Icon name={getIconName()} /> : ''}
</Tag>
);
};
StepIndicatorItem.propTypes = propTypes;
StepIndicatorItem.defaultProps = defaultProps;