Skip to content

Commit 01425ef

Browse files
authored
Merge pull request #203 from scientist-softserv/200-make-click-boxes-new
200 Make Boxes Clickable
2 parents d9b91e1 + 14f6c61 commit 01425ef

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

src/components/NextLink/NextLink.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@ import React from 'react'
22
import Link from 'next/link'
33
import PropTypes from 'prop-types'
44

5-
const NextLink = ({ addClass, text, path }) => (
5+
const NextLink = ({ addClass, children, path }) => (
66
<Link href={path} passHref>
77
<NextLinkWrapper
88
addClass={addClass}
99
href={path}
10-
text={text}
10+
children={children}
1111
/>
1212
</Link>
1313
)
1414

15-
const NextLinkWrapper = React.forwardRef(({ addClass, text, href }, ref) => (
15+
const NextLinkWrapper = React.forwardRef(({ addClass, children, href }, ref) => (
1616
<a href={href} ref={ref} className={addClass}>
17-
{text}
17+
{children}
1818
</a>
1919
))
2020

2121
NextLink.propTypes = {
22-
text: PropTypes.string.isRequired,
22+
children: PropTypes.oneOfType([
23+
PropTypes.string,
24+
PropTypes.elementType,
25+
]).isRequired,
2326
addClass: PropTypes.string,
2427
path: PropTypes.exact({
2528
pathname: PropTypes.string.isRequired,

src/components/NextLink/NextLink.stories.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Template = (args) => <NextLink {...args} />
1010

1111
export const Default = Template.bind({})
1212
Default.args = {
13-
text: 'Text Here',
13+
children: 'Text Here',
1414
addClass: '',
1515
path: {
1616
pathname: '/test',

src/compounds/Item/CardBody.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CardBody = ({ buttonLink, buttonProps, item,
2424
<Card.Title>
2525
{(withTitleLink) && (
2626
<NextLink
27-
text={name}
27+
children={name}
2828
path={{ pathname: titleLink, query: { id } }}
2929
addClass='text-decoration-none link-hover'
3030
/>

src/compounds/Item/Item.jsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Image from '../../components/Image/Image'
55
import CardBody from './CardBody'
66
import LinkedButton from '../LinkedButton/LinkedButton'
77
import ItemLoading from './ItemLoading'
8+
import NextLink from '../../components/NextLink/NextLink'
89
import './item.scss'
910

1011
const Item = ({ buttonLink, buttonProps, href, isLoading, item, orientation, titleLink, withButtonLink,
@@ -52,22 +53,28 @@ const Item = ({ buttonLink, buttonProps, href, isLoading, item, orientation, tit
5253
</div>
5354
</div>
5455
) : (
55-
<>
56-
<Image
57-
className={`cover ${orientation === 'horizontal' ? 'img-fluid h-100 rounded-start' : 'card-img-top'}`}
58-
src={src}
59-
alt={alt}
60-
/>
61-
<CardBody
62-
buttonLink={link}
63-
buttonProps={buttonProps}
64-
item={item}
65-
orientation={orientation}
66-
titleLink={link}
67-
withButtonLink={withButtonLink}
68-
withTitleLink={withTitleLink}
69-
/>
70-
</>
56+
<NextLink
57+
children={(
58+
<>
59+
<Image
60+
className={`cover ${orientation === 'horizontal' ? 'img-fluid h-100 rounded-start' : 'card-img-top'}`}
61+
src={src}
62+
alt={alt}
63+
/>
64+
<CardBody
65+
buttonLink={link}
66+
buttonProps={buttonProps}
67+
item={item}
68+
orientation={orientation}
69+
titleLink={link}
70+
withButtonLink={withButtonLink}
71+
withTitleLink={withTitleLink}
72+
/>
73+
</>
74+
)}
75+
path={{ pathname: item.href, query: { id }}}
76+
addClass="text-decoration-none link-hover"
77+
/>
7178
)}
7279
</Card>
7380
)

0 commit comments

Comments
 (0)