Skip to content

Commit 2e3d5ab

Browse files
committed
switching intern drivers
1 parent 78d91b9 commit 2e3d5ab

File tree

3 files changed

+72
-50
lines changed

3 files changed

+72
-50
lines changed

src/components/NextLink/NextLink.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const NextLinkWrapper = React.forwardRef(({ addClass, text, href }, ref) => (
1919
))
2020

2121
NextLink.propTypes = {
22-
text: PropTypes.string.isRequired,
22+
// text: PropTypes.string.isRequired,
2323
addClass: PropTypes.string,
2424
path: PropTypes.exact({
2525
pathname: PropTypes.string.isRequired,

src/compounds/Item/CardBody.jsx

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,70 @@
1-
import React from 'react'
2-
import PropTypes from 'prop-types'
3-
import { Card } from 'react-bootstrap'
4-
import NextLink from '../../components/NextLink/NextLink'
5-
import LinkedButton from '../LinkedButton/LinkedButton'
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
import { Card } from "react-bootstrap";
4+
import NextLink from "../../components/NextLink/NextLink";
5+
import LinkedButton from "../LinkedButton/LinkedButton";
66

7-
const CardBody = ({ buttonLink, buttonProps, item,
8-
orientation, titleLink, withButtonLink, withTitleLink }) => {
9-
const { id, description, name } = item
7+
const CardBody = ({
8+
buttonLink,
9+
buttonProps,
10+
item,
11+
orientation,
12+
titleLink,
13+
withButtonLink,
14+
withTitleLink,
15+
}) => {
16+
const { id, description, name } = item;
1017

1118
return (
12-
<Card.Body className={withButtonLink && 'd-flex flex-column'}>
13-
<div className={orientation === 'horizontal' ? 'd-block d-md-flex align-items-center justify-content-between' : ''}>
14-
<div className={orientation === 'horizontal' ? 'me-2' : ''}>
15-
<Card.Title>
19+
<Card.Body className={withButtonLink && "d-flex flex-column"}>
20+
<div
21+
className={
22+
orientation === "horizontal"
23+
? "d-block d-md-flex align-items-center justify-content-between"
24+
: ""
25+
}
26+
>
27+
<div className={orientation === "horizontal" ? "me-2" : ""}>
28+
<Card.Title >
1629
{(withTitleLink) && (
17-
<NextLink
18-
text={name}
19-
path={{ pathname: titleLink, query: { id } }}
20-
addClass='text-decoration-none link-hover'
21-
/>
22-
)}
23-
{(!withTitleLink) && (
24-
name
30+
<NextLink
31+
text={name}
32+
path={{ pathname: titleLink, query: { id } }}
33+
addClass="text-decoration-none link-hover"
34+
/>)}
35+
{(!withTitleLink) && (
36+
name
2537
)}
2638
</Card.Title>
27-
{description && (
28-
<Card.Text className='fw-light'>
29-
{description}
30-
</Card.Text>
39+
{description && (
40+
<Card.Text className="fw-light">{description}</Card.Text>
41+
)}
42+
</div>
43+
{withButtonLink && (
44+
<div
45+
className={orientation === "horizontal" ? "mt-3 mt-md-0" : "mt-3"}
46+
>
47+
<LinkedButton
48+
addClass={`item-button-${orientation} item-link mt-auto`}
49+
buttonProps={buttonProps}
50+
path={{ pathname: buttonLink, query: { id } }}
51+
/>
52+
</div>
3153
)}
3254
</div>
33-
{(withButtonLink) && (
34-
<div className={orientation === 'horizontal' ? 'mt-3 mt-md-0' : 'mt-3'}>
35-
<LinkedButton
36-
addClass={`item-button-${orientation} item-link mt-auto`}
37-
buttonProps={buttonProps}
38-
path={{ pathname: buttonLink, query: { id }}}
39-
/>
40-
</div>
41-
)}
42-
</div>
43-
</Card.Body>
44-
)
45-
}
55+
</Card.Body>
56+
);
57+
};
4658

4759
CardBody.propTypes = {
4860
buttonLink: PropTypes.string,
4961
// currently overriding the label on a button from being required in this component,
5062
// because it shouldn't be if we are not rendering a button
5163
// refer to the comment below
52-
buttonProps: PropTypes.shape({ ...LinkedButton.propTypes.buttonProps, label: PropTypes.string }),
64+
buttonProps: PropTypes.shape({
65+
...LinkedButton.propTypes.buttonProps,
66+
label: PropTypes.string,
67+
}),
5368
// TODO(alishaevn): is there a way to set conditional proptypes without adding another package?
5469
// buttonProps: props => props.withButtonLink
5570
// ? PropTypes.shape(Button.propTypes)
@@ -64,22 +79,22 @@ CardBody.propTypes = {
6479
name: PropTypes.string.isRequired,
6580
slug: PropTypes.string,
6681
}),
67-
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
82+
orientation: PropTypes.oneOf(["horizontal", "vertical"]),
6883
titleLink: PropTypes.string,
6984
withButtonLink: PropTypes.bool,
7085
withTitleLink: PropTypes.bool,
71-
}
86+
};
7287

7388
CardBody.defaultProps = {
74-
buttonLink: '',
89+
buttonLink: "",
7590
buttonProps: LinkedButton.defaultProps,
7691
item: {
77-
description: '',
92+
description: "",
7893
},
79-
orientation: 'vertical',
80-
titleLink: '',
94+
orientation: "vertical",
95+
titleLink: "",
8196
withButtonLink: false,
8297
withTitleLink: false,
83-
}
98+
};
8499

85-
export default CardBody
100+
export default CardBody;

src/compounds/Item/Item.jsx

Lines changed: 10 additions & 3 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,8 +53,10 @@ const Item = ({ buttonLink, buttonProps, href, isLoading, item, orientation, tit
5253
</div>
5354
</div>
5455
) : (
55-
<>
56-
<Image
56+
<NextLink
57+
text={(
58+
<>
59+
<Image
5760
className={`cover ${orientation === 'horizontal' ? 'img-fluid h-100 rounded-start' : 'card-img-top'}`}
5861
src={src}
5962
alt={alt}
@@ -67,7 +70,11 @@ const Item = ({ buttonLink, buttonProps, href, isLoading, item, orientation, tit
6770
withButtonLink={withButtonLink}
6871
withTitleLink={withTitleLink}
6972
/>
70-
</>
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)