Skip to content

Commit e7df29e

Browse files
LEARN AcademyLEARN Academy
authored andcommitted
update prop type from text to children
1 parent c396bcf commit e7df29e

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
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
@@ -15,7 +15,7 @@ const CardBody = ({ buttonLink, buttonProps, item,
1515
<Card.Title>
1616
{(withTitleLink) && (
1717
<NextLink
18-
text={name}
18+
children={name}
1919
path={{ pathname: titleLink, query: { id } }}
2020
addClass='text-decoration-none link-hover'
2121
/>

src/compounds/Item/Item.jsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@ const Item = ({ buttonLink, buttonProps, href, isLoading, item, orientation, tit
5454
</div>
5555
) : (
5656
<NextLink
57-
text={(
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"
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"
7777
/>
7878
)}
7979
</Card>

0 commit comments

Comments
 (0)