spaCy/website/src/components/card.js
Marcus Blättermann 49237f05a6
Fix aria-hidden element (#12163)
* Rename CSS class to make use more clear

* Rename component prop to improve code readability

* Fix `aria-hidden` directly on a link element

This link wouldn't have been clickable by screenreaders

* Refactor component

This removes a unnessary `div` and a duplicate link

Co-authored-by: Ines Montani <ines@ines.io>
2023-01-24 14:44:47 +01:00

47 lines
1.4 KiB
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import ImageNext from 'next/image'
import Link from './link'
import { H5 } from './typography'
import classes from '../styles/card.module.sass'
export default function Card({ title, to, image, header, small, onClick, children }) {
return (
<div className={classNames(classes.root, { [classes.small]: !!small })}>
{header && (
<Link to={to} onClick={onClick} noLinkLayout>
{header}
</Link>
)}
{(title || image) && (
<H5 className={classes.title}>
{image && (
<div className={classes.image}>
<ImageNext src={image} height={35} width={35} alt={`${title} Logo`} />
</div>
)}
{title && (
<Link to={to} onClick={onClick} noLinkLayout>
{title}
</Link>
)}
</H5>
)}
<Link to={to} onClick={onClick} noLinkLayout>
{children}
</Link>
</div>
)
}
Card.propTypes = {
title: PropTypes.node,
header: PropTypes.node,
to: PropTypes.string,
image: PropTypes.string,
onClick: PropTypes.func,
children: PropTypes.node,
}