Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/components/NextLink/NextLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ import React from 'react'
import Link from 'next/link'
import PropTypes from 'prop-types'

const NextLink = ({ addClass, text, path }) => (
const NextLink = ({ addClass, children, path }) => (
<Link href={path} passHref>
<NextLinkWrapper
addClass={addClass}
href={path}
text={text}
children={children}
/>
</Link>
)

const NextLinkWrapper = React.forwardRef(({ addClass, text, href }, ref) => (
const NextLinkWrapper = React.forwardRef(({ addClass, children, href }, ref) => (
<a href={href} ref={ref} className={addClass}>
{text}
{children}
</a>
))

NextLink.propTypes = {
text: PropTypes.string.isRequired,
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.elementType,
]).isRequired,
Comment on lines +22 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏾

addClass: PropTypes.string,
path: PropTypes.exact({
pathname: PropTypes.string.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion src/components/NextLink/NextLink.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Template = (args) => <NextLink {...args} />

export const Default = Template.bind({})
Default.args = {
text: 'Text Here',
children: 'Text Here',
addClass: '',
path: {
pathname: '/test',
Expand Down
2 changes: 1 addition & 1 deletion src/compounds/Item/CardBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const CardBody = ({ buttonLink, buttonProps, item,
<Card.Title>
{(withTitleLink) && (
<NextLink
text={name}
children={name}
path={{ pathname: titleLink, query: { id } }}
addClass='text-decoration-none link-hover'
/>
Expand Down
39 changes: 23 additions & 16 deletions src/compounds/Item/Item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Image from '../../components/Image/Image'
import CardBody from './CardBody'
import LinkedButton from '../LinkedButton/LinkedButton'
import ItemLoading from './ItemLoading'
import NextLink from '../../components/NextLink/NextLink'
import './item.scss'

const Item = ({ buttonLink, buttonProps, href, isLoading, item, orientation, titleLink, withButtonLink,
Expand Down Expand Up @@ -52,22 +53,28 @@ const Item = ({ buttonLink, buttonProps, href, isLoading, item, orientation, tit
</div>
</div>
) : (
<>
<Image
className={`cover ${orientation === 'horizontal' ? 'img-fluid h-100 rounded-start' : 'card-img-top'}`}
src={src}
alt={alt}
/>
<CardBody
buttonLink={link}
buttonProps={buttonProps}
item={item}
orientation={orientation}
titleLink={link}
withButtonLink={withButtonLink}
withTitleLink={withTitleLink}
/>
</>
<NextLink
children={(
<>
<Image
className={`cover ${orientation === 'horizontal' ? 'img-fluid h-100 rounded-start' : 'card-img-top'}`}
src={src}
alt={alt}
/>
<CardBody
buttonLink={link}
buttonProps={buttonProps}
item={item}
orientation={orientation}
titleLink={link}
withButtonLink={withButtonLink}
withTitleLink={withTitleLink}
/>
</>
)}
path={{ pathname: item.href, query: { id }}}
addClass="text-decoration-none link-hover"
/>
)}
</Card>
)
Expand Down
Loading