Skip to content

Commit

Permalink
Merge pull request #203 from scientist-softserv/200-make-click-boxes-new
Browse files Browse the repository at this point in the history
200 Make Boxes Clickable
  • Loading branch information
alishaevn authored Feb 2, 2024
2 parents d9b91e1 + 14f6c61 commit 01425ef
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
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,
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 @@ -24,7 +24,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

0 comments on commit 01425ef

Please sign in to comment.