react-material-web-components
Version:
React Wrapper for Material Design Components
37 lines (31 loc) • 866 B
JavaScript
import React, {PureComponent} from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
class ToolbarTitle extends PureComponent {
static displayName = 'ToolbarTitle'
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
tagName: PropTypes.oneOf(['span', 'div']),
}
static defaultProps = {
tagName: 'span',
}
render() {
const {
children,
className,
tagName,
...otherProps,
} = this.props
const cssClasses = classNames('mdc-toolbar__title', className)
return React.isValidElement(children) ? React.cloneElement(children, {
className: classNames('mdc-toolbar__title', children.props.className),
}) : React.createElement(
tagName,
{...otherProps, className: cssClasses},
children
)
}
}
export default ToolbarTitle