Fix infobox with ID [ci skip]

This commit is contained in:
Ines Montani 2020-09-23 13:00:56 +02:00
parent 02b69dd0d5
commit a9da33c4d9

View File

@ -1,4 +1,4 @@
import React from 'react' import React, { Fragment } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import classNames from 'classnames' import classNames from 'classnames'
@ -14,13 +14,14 @@ export default function Infobox({
className, className,
children, children,
}) { }) {
const Wrapper = id ? 'div' : Fragment
const infoboxClassNames = classNames(classes.root, className, { const infoboxClassNames = classNames(classes.root, className, {
[classes.list]: !!list, [classes.list]: !!list,
[classes.warning]: variant === 'warning', [classes.warning]: variant === 'warning',
[classes.danger]: variant === 'danger', [classes.danger]: variant === 'danger',
}) })
return ( return (
<> <Wrapper>
{id && <a id={id} />} {id && <a id={id} />}
<aside className={infoboxClassNames}> <aside className={infoboxClassNames}>
{title && ( {title && (
@ -40,7 +41,7 @@ export default function Infobox({
)} )}
{children} {children}
</aside> </aside>
</> </Wrapper>
) )
} }