UNPKG

saagie-ui

Version:

Saagie UI from Saagie Design System

65 lines (58 loc) 1.6 kB
import React from 'react'; import PropTypes from 'prop-types'; import { Manager } from 'react-popper'; import classnames from 'classnames'; import { InstanceQuickviewDot } from './InstanceQuickviewDot'; const propTypes = { /** * 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, instanceInfos: PropTypes.shape({ main: PropTypes.string, secondary: PropTypes.string, }), size: PropTypes.number, status: PropTypes.oneOf(['awaiting', 'requested', 'queued', 'running', 'succeeded', 'stopping', 'stopped', 'skipped', 'failed']).isRequired, }; const defaultProps = { tag: 'span', defaultClassName: 'sui-prj-instance-quickview__item', className: '', instanceInfos: { main: '', secondary: '' }, size: null, }; export const InstanceQuickviewItem = (props) => { const { tag: Tag, defaultClassName, className, status, size, instanceInfos, ...attributes } = props; const classes = classnames( defaultClassName, status ? `as--${status}` : '', className ); return ( <Manager> <Tag {...attributes} className={classes} style={{ flexGrow: size, }} > <InstanceQuickviewDot status={status} instanceInfos={instanceInfos} /> </Tag> </Manager> ); }; InstanceQuickviewItem.propTypes = propTypes; InstanceQuickviewItem.defaultProps = defaultProps;