Skip to content

Commit 45cff71

Browse files
authored
Merge pull request #140 from scientist-softserv/139-improve-requests-page
Refactor requestlist
2 parents d11bdfe + b1904fb commit 45cff71

File tree

7 files changed

+92
-74
lines changed

7 files changed

+92
-74
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: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,33 @@ 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(({ index, request }, ref) => {
10+
const { createdAt, description, href, img, title, status, updatedAt } = request
1011
const { backgroundColor, text, textColor } = status
1112
const image = { ...img, height: 70, width: 70 }
1213

1314
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} />
15+
<article
16+
className={`request-item p-3 d-flex flex-column flex-md-row justify-content-between gap-3 bg-light
17+
${index % 2 === 0 ? ' bg-light' : ' bg-light-2'}`}
18+
>
19+
<div className='d-flex flex-column flex-sm-row gap-3 request-item-details'>
20+
<Image {...image} addClass='align-self-md-center' />
21+
<div className='align-self-sm-center'>
22+
<a href={href} ref={ref} className='link pointer-cursor'>
23+
<Title title={title} size='small' />
24+
</a>
25+
<TextBox text={description} />
26+
</div>
2127
</div>
22-
<div className='status'>
28+
<div className='status bg-light-3 p-2 rounded mt-4 mt-md-0'>
2329
<Badge
2430
backgroundColor={backgroundColor}
2531
text={text}
2632
textColor={textColor}
33+
addClass='mb-2'
2734
/>
2835
<TextBox text={`Created: ${createdAt}`} />
2936
<TextBox text={`Updated: ${updatedAt}`} />
@@ -33,13 +40,22 @@ const RequestItem = React.forwardRef(({ createdAt, description, href, img, title
3340
})
3441

3542
RequestItem.propTypes = {
36-
createdAt: PropTypes.string.isRequired,
37-
description: PropTypes.string.isRequired,
38-
id: PropTypes.number,
39-
img: PropTypes.shape(Image.propTypes).isRequired,
40-
status: PropTypes.shape(Badge.propTypes).isRequired,
41-
title: PropTypes.string.isRequired,
42-
updatedAt: PropTypes.string.isRequired,
43+
index: PropTypes.number,
44+
request: PropTypes.shape({
45+
createdAt: PropTypes.string.isRequired,
46+
description: PropTypes.string.isRequired,
47+
href: PropTypes.string.isRequired,
48+
img: PropTypes.shape(Image.propTypes).isRequired,
49+
status: PropTypes.shape(Badge.propTypes).isRequired,
50+
title: PropTypes.string.isRequired,
51+
updatedAt: PropTypes.string.isRequired,
52+
}).isRequired,
4353
}
4454

55+
RequestItem.defaultProps = {
56+
index: null,
57+
}
58+
59+
RequestItem.displayName = 'Request Item'
60+
4561
export default RequestItem

src/compounds/RequestItem/RequestItem.stories.jsx

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,34 @@ const Template = (args) => <RequestItem {...args} />
1111

1212
export const Default = Template.bind({})
1313
Default.args = {
14-
createdAt: 'September 9, 2022',
15-
description: 'Does the Company offer services related to Flow Cytometry?',
16-
href: '/request/F575C4',
17-
img: defaultImage,
18-
title: 'F575C4: Assay Depot Coffee Mug',
19-
status: {
20-
text: 'Vendor Review',
21-
},
22-
updatedAt: 'September 9, 2022 at 9:21 am',
14+
index: 0,
15+
request: {
16+
createdAt: 'September 9, 2022',
17+
description: 'Does the Company offer services related to Flow Cytometry?',
18+
href: '/request/F575C4',
19+
img: defaultImage,
20+
title: 'F575C4: Assay Depot Coffee Mug',
21+
status: {
22+
text: 'Vendor Review',
23+
},
24+
updatedAt: 'September 9, 2022 at 9:21 am',
25+
}
2326
}
2427

2528
export const Alternate = Template.bind({})
2629
Alternate.args = {
27-
createdAt: 'September 9, 2022',
28-
description: 'Does the Company offer services related to Flow Cytometry?',
29-
href: '/request/F575C4',
30-
img: defaultImage,
31-
title: 'F575C4: Assay Depot Coffee Mug',
32-
status: {
33-
backgroundColor: '#DEAF17',
34-
text: 'Work In Progress',
35-
textColor: '#FFFFFF',
36-
},
37-
updatedAt: 'November 16, 2022 at 4:45 pm',
30+
index: 1,
31+
request: {
32+
createdAt: 'September 9, 2022',
33+
description: 'Does the Company offer services related to Flow Cytometry?',
34+
href: '/request/F575C4',
35+
img: defaultImage,
36+
title: 'F575C4: Assay Depot Coffee Mug',
37+
status: {
38+
backgroundColor: '#DEAF17',
39+
text: 'Work In Progress',
40+
textColor: '#FFFFFF',
41+
},
42+
updatedAt: 'November 16, 2022 at 4:45 pm',
43+
}
3844
}

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: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@ 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 request={req} index={index} />
14+
</Link>
15+
))}
16+
</div>
2217
</>
2318
)
2419

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)