UNPKG

saagie-ui

Version:

Saagie UI from Saagie Design System

52 lines (46 loc) 1.14 kB
import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; const propTypes = { children: PropTypes.node, className: PropTypes.string, defaultClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]), isInteractive: PropTypes.bool, currentStep: PropTypes.number, /** * The component used for the root node. * Either a string to use a DOM element or a component. */ tag: PropTypes.elementType, }; const defaultProps = { children: '', className: '', defaultClassName: 'sui-a-step-indicator', isInteractive: false, currentStep: 0, tag: 'div', }; export const StepIndicator = ({ children, className, defaultClassName, isInteractive, currentStep, tag: Tag, ...attributes }) => { const classes = classnames( className, defaultClassName, isInteractive ? 'as--interactive' : '', currentStep ? `as--step-${currentStep}` : '', ); return ( <Tag className={classes} {...attributes}> {children} </Tag> ); }; StepIndicator.propTypes = propTypes; StepIndicator.defaultProps = defaultProps;