UNPKG

saagie-ui

Version:

Saagie UI from Saagie Design System

50 lines (43 loc) 1.13 kB
import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; 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, timeRange: PropTypes.number.isRequired, }; const defaultProps = { tag: 'div', defaultClassName: 'sui-prj-project-instances-quickview', className: '', }; export const ProjectInstancesQuickview = (props) => { const { tag: Tag, defaultClassName, className, children, timeRange, ...attributes } = props; const classes = classnames( defaultClassName, className ); return ( <Tag {...attributes} className={classes} > {React.Children.map(children, (child) => React.cloneElement(child, { timeRange }))} </Tag> ); }; ProjectInstancesQuickview.propTypes = propTypes; ProjectInstancesQuickview.defaultProps = defaultProps;