Skip to content

Commit 31acc18

Browse files
committed
create an itemPropTypes object, linting and missing ItemGroup story props
1 parent 96d9333 commit 31acc18

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

src/components/Button/Button.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const buttonPropTypes = {
2626
type: PropTypes.string,
2727
}
2828

29-
Button.propTypes = { ...buttonPropTypes }
29+
Button.propTypes = { ...buttonPropTypes }
3030

3131
Button.defaultProps = {
3232
addClass: '',

src/compounds/Item/Item.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ const Item = ({ buttonLink, buttonProps, href, isLoading, item, orientation, tit
7373
)
7474
}
7575

76+
export const itemPropTypes = {
77+
description: PropTypes.string,
78+
id: PropTypes.number.isRequired,
79+
img: PropTypes.shape({
80+
src: PropTypes.string.isRequired,
81+
alt: PropTypes.string,
82+
}).isRequired,
83+
name: PropTypes.string.isRequired,
84+
slug: PropTypes.string,
85+
}
86+
7687
Item.propTypes = {
7788
buttonLink: PropTypes.string,
7889
// currently overriding the label on a button from being required in this component,
@@ -88,16 +99,7 @@ Item.propTypes = {
8899
PropTypes.shape({}),
89100
]),
90101
isLoading: PropTypes.bool,
91-
item: PropTypes.shape({
92-
description: PropTypes.string,
93-
id: PropTypes.number.isRequired,
94-
img: PropTypes.shape({
95-
src: PropTypes.string.isRequired,
96-
alt: PropTypes.string,
97-
}).isRequired,
98-
name: PropTypes.string.isRequired,
99-
slug: PropTypes.string,
100-
}),
102+
item: PropTypes.shape({ ...itemPropTypes }).isRequired,
101103
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
102104
titleLink: PropTypes.string,
103105
withButtonLink: PropTypes.bool,

src/compounds/ItemGroup/ItemGroup.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import { Col, Row } from 'react-bootstrap'
44
import Title from '../../components/Title/Title'
5-
import Item from '../Item/Item'
5+
import Item, { itemPropTypes} from '../Item/Item'
66
import ItemLoading from '../Item/ItemLoading'
77
import './item-group.scss'
88

@@ -53,7 +53,7 @@ ItemGroup.propTypes = {
5353
label: PropTypes.string,
5454
}),
5555
items: PropTypes.arrayOf(PropTypes.shape({
56-
...Item.propTypes,
56+
...itemPropTypes,
5757
imgProps: PropTypes.shape({}),
5858
style: PropTypes.shape({}),
5959
})).isRequired,

src/compounds/ItemGroup/ItemGroup.stories.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Default.args = {
1515
backgroundColor: '#A9A9A9',
1616
label: 'Request this item',
1717
},
18+
isLoading: false,
1819
items: items.slice(0, 3),
1920
orientation: 'vertical',
2021
}
@@ -25,6 +26,7 @@ Horizontal.args = {
2526
backgroundColor: '#A9A9A9',
2627
label: 'Request this item',
2728
},
29+
isLoading: false,
2830
items: items.slice(0, 3),
2931
orientation: 'horizontal',
3032
}
@@ -37,6 +39,7 @@ isLoading.args = {
3739

3840
export const withTitleLink = Template.bind({})
3941
withTitleLink.args = {
42+
isLoading: false,
4043
items: items.slice(0, 6),
4144
withTitleLink: true,
4245
}
@@ -47,6 +50,7 @@ withButtonLink.args = {
4750
backgroundColor: '#A9A9A9',
4851
label: 'Request this item',
4952
},
53+
isLoading: false,
5054
items: items.slice(0, 6),
5155
withButtonLink: true,
5256
}

0 commit comments

Comments
 (0)