Skip to content

Commit 2dba641

Browse files
committed
refactor requestlist
1 parent 9b186c7 commit 2dba641

File tree

6 files changed

+66
-47
lines changed

6 files changed

+66
-47
lines changed

src/assets/theme/bootstrap-preview.scss

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// these colors match what is in the webstore, and must be updated here as well. this file enables us to see the preview of what these overrides will look like without actually importing these from here into the webstore project.
1+
// these colors and variables match what is in the webstore's theme.module.scss file. this file enables us to see the preview of what these overrides will look like without actually importing these from here into the webstore project. In order to see a preview in storybook of how components will look with custom colors, these values must be updated.
22

33
$primary: #333333;
44
$secondary: #CCCCCC;
@@ -10,5 +10,17 @@ $light: #f8f9fa;
1010
$dark: #212529;
1111
$white: #ffffff;
1212

13-
@import '../../../node_modules/bootstrap/scss/bootstrap.scss'
13+
// these imports must be AFTER the theme color overrides above in order to properly override bootstrap's colors, but before the theme maps.
14+
@import "../../../node_modules/bootstrap/scss/functions";
15+
@import "../../../node_modules/bootstrap/scss/variables";
16+
@import "../../../node_modules/bootstrap/scss/mixins";
1417

18+
// create our own custom colors map, and merge it with bootstrap's theme-colors map to generate utility functions that can be used throughout the map
19+
$custom-colors: (
20+
"light-2": darken($light, 3%),
21+
"light-3": darken($light, 10%)
22+
);
23+
$theme-colors: map-merge($theme-colors, $custom-colors);
24+
25+
// the full bootstrap import must be last in order to properly override bootstrap's theme maps
26+
@import '../../../node_modules/bootstrap/scss/bootstrap.scss';

src/compounds/RequestItem/RequestItem.jsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,32 @@ import Badge from '../../components/Badge/Badge'
44
import Image from '../../components/Image/Image'
55
import TextBox from '../../components/TextBox/TextBox'
66
import Title from '../../components/Title/Title'
7-
import './request-item.css'
7+
import './request-item.scss'
88

9-
const RequestItem = React.forwardRef(({ createdAt, description, href, img, title, status, updatedAt }, ref) => {
9+
const RequestItem = React.forwardRef(({ createdAt, description, href, img, index, title, status, updatedAt }, ref) => {
1010
const { backgroundColor, text, textColor } = status
1111
const image = { ...img, height: 70, width: 70 }
1212

1313
return (
14-
<article className='request-item mt-2'>
15-
<Image {...image} />
16-
<div className='request-item-details'>
17-
<a href={href} ref={ref} className='link pointer-cursor'>
18-
<Title title={title} size='small' />
19-
</a>
20-
<TextBox text={description} />
14+
<article
15+
className={`request-item p-3 d-flex flex-column flex-md-row justify-content-between gap-3 bg-light
16+
${index % 2 === 0 ? ' bg-light' : ' bg-light-2'}`}
17+
>
18+
<div className='d-flex flex-column flex-sm-row gap-3 request-item-details'>
19+
<Image {...image} addClass='align-self-md-center' />
20+
<div className='align-self-sm-center'>
21+
<a href={href} ref={ref} className='link pointer-cursor'>
22+
<Title title={title} size='small' />
23+
</a>
24+
<TextBox text={description} />
25+
</div>
2126
</div>
22-
<div className='status'>
27+
<div className='status bg-light-3 p-2 rounded'>
2328
<Badge
2429
backgroundColor={backgroundColor}
2530
text={text}
2631
textColor={textColor}
32+
addClass='mb-2'
2733
/>
2834
<TextBox text={`Created: ${createdAt}`} />
2935
<TextBox text={`Updated: ${updatedAt}`} />
@@ -35,11 +41,20 @@ const RequestItem = React.forwardRef(({ createdAt, description, href, img, title
3541
RequestItem.propTypes = {
3642
createdAt: PropTypes.string.isRequired,
3743
description: PropTypes.string.isRequired,
44+
href: PropTypes.string,
3845
id: PropTypes.number,
46+
index: PropTypes.number.isRequired,
3947
img: PropTypes.shape(Image.propTypes).isRequired,
4048
status: PropTypes.shape(Badge.propTypes).isRequired,
4149
title: PropTypes.string.isRequired,
4250
updatedAt: PropTypes.string.isRequired,
4351
}
4452

53+
RequestItem.defaultProps = {
54+
href: '',
55+
id: null,
56+
}
57+
58+
RequestItem.displayName = 'Request Item'
59+
4560
export default RequestItem

src/compounds/RequestItem/request-item.css

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.request-item-details {
2+
flex: 2;
3+
}
4+
5+
.status {
6+
max-height: 175px;
7+
@media (min-width: 768px) {
8+
width: 260px;
9+
}
10+
}

src/compounds/RequestList/RequestList.jsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ import RequestItem from '../RequestItem/RequestItem'
77
const RequestList = ({ requests }) => (
88
<>
99
<Title title='My Requests' size='medium' />
10-
{requests.map((req) => (
11-
<Link key={req.id} href={`${req.href}`} passHref legacyBehavior>
12-
<RequestItem
13-
createdAt={req.createdAt}
14-
description={req.description}
15-
img={req.img}
16-
title={req.title}
17-
status={req.status}
18-
updatedAt={req.updatedAt}
19-
/>
20-
</Link>
21-
))}
10+
<div className='rounded overflow-hidden'>
11+
{requests.map((req, index) => (
12+
<Link key={req.id} href={`${req.href}`} passHref legacyBehavior>
13+
<RequestItem
14+
createdAt={req.createdAt}
15+
description={req.description}
16+
img={req.img}
17+
title={req.title}
18+
status={req.status}
19+
updatedAt={req.updatedAt}
20+
index={index}
21+
/>
22+
</Link>
23+
))}
24+
</div>
2225
</>
2326
)
2427

src/compounds/RequestList/RequestList.stories.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Default.args = {
2626
},
2727
{
2828
createdAt: 'November 15, 2022',
29-
description: 'this is a test.',
29+
// eslint-disable-next-line max-len
30+
description: 'General Information When do you plan to work with this supplier? Urgently Name of supplier: Alisha Supplier web address: http://scientist.com Is this new supplier onboarding request related to any of the following areas: Research area: In Vivo Contact Information Supplier contact name: Alisha Evans Supplier email a...',
3031
href: '/request/706D8F',
3132
id: 2,
3233
img: defaultImage,

0 commit comments

Comments
 (0)