import React from 'react' import PropTypes from 'prop-types' import classNames from 'classnames' import Tag from './tag' import Button from './button' import Icon from './icon' import { isString, github, headingTextClassName } from './util' import classes from '../styles/typography.module.sass' export const H1 = ({ Component = 'h1', className, ...props }) => ( ) export const H2 = ({ className, ...props }) => ( ) export const H3 = ({ className, ...props }) => ( ) export const H4 = ({ className, ...props }) => ( ) export const H5 = ({ className, ...props }) => ( ) export const P = ({ children, ...props }) => { const dontWrap = ['figure'] if ( !Array.isArray(children) && !isString(children) && children.hasOwnProperty('type') && dontWrap.includes(children.type) ) { return children } return

{children}

} export const Abbr = ({ title, children }) => ( {children} ) export const Label = ({ className, ...props }) => ( ) export const InlineList = ({ Component = 'p', gutterBottom = true, className, children }) => { const listClassNames = classNames(classes.inlineList, className, { [classes.noGutter]: !gutterBottom, }) return {children} } export const Help = ({ children, size = 16 }) => ( ) /** * Allows inserting comments that will appear in .md preview on GitHub, but * won't be included in the final build of the site. */ export const Comment = () => null const Permalink = ({ id, children }) => !id ? ( {children} ) : ( {children} ) const Headline = ({ Component, id, name, new: version, model, tag, source, hidden, action, className, children, }) => { // This can be set via hidden="true" and as a prop, so we need to accept both if (hidden === true || hidden === 'true') return null const hasAction = !!source || !!action const headingClassNames = classNames(classes.heading, className, { [classes.clear]: hasAction, }) const tags = tag ? tag.split(',').map(t => t.trim()) : [] return ( {children} {tags.map((tag, i) => ( {tag} ))} {version && ( {version} )} {model && ( {model} )} {hasAction && (
{source && ( )} {action}
)}
) } Headline.propTypes = { Component: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).isRequired, id: PropTypes.oneOfType([PropTypes.string, PropTypes.oneOf([false])]), new: PropTypes.string, model: PropTypes.string, source: PropTypes.string, tag: PropTypes.string, hidden: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['true', 'false'])]), action: PropTypes.node, className: PropTypes.string, }