Skip to content

Commit a0862ca

Browse files
author
sagiv.bengiat
committed
2 parents b888750 + a0a5414 commit a0862ca

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/react-elastic-carousel/components/ItemWrapperContainer.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@ import React from "react";
22
import PropTypes from "prop-types";
33
import { ItemWrapper } from "./styled";
44
import consts from "../consts";
5-
import { noop, cssPrefix } from "../utils/helpers";
5+
import { noop } from "../utils/helpers";
66

77
class ItemWrapperContainer extends React.Component {
88
onClick = () => {
99
const { onClick, id } = this.props;
1010
onClick(id);
1111
};
1212
render() {
13-
const { itemPosition, ...restOfProps } = this.props;
14-
return (
15-
<ItemWrapper
16-
onClick={this.onClick}
17-
className={cssPrefix("item-wrapper")}
18-
itemPosition={itemPosition}
19-
{...restOfProps}
20-
/>
21-
);
13+
return <ItemWrapper {...this.props} onClick={this.onClick} />;
2214
}
2315
}
2416

@@ -29,8 +21,6 @@ ItemWrapperContainer.defaultProps = {
2921
};
3022

3123
ItemWrapperContainer.propTypes = {
32-
children: PropTypes.element.isRequired,
33-
itemPosition: PropTypes.oneOf([consts.START, consts.CENTER, consts.END]),
3424
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
3525
onClick: PropTypes.func
3626
};
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
import styled from "styled-components";
2+
import PropTypes from "prop-types";
3+
import { cssPrefix } from "../../utils/helpers";
4+
import consts from "../../consts";
25

3-
export default styled.div.attrs(({ style }) => ({ style }))`
6+
const ItemWrapper = styled.div.attrs(({ style }) => ({
7+
style,
8+
className: cssPrefix("item-wrapper")
9+
}))`
410
box-sizing: border-box;
511
display: flex;
612
overflow: hidden;
713
user-select: none;
814
justify-content: ${({ itemPosition }) => itemPosition};
915
`;
16+
17+
ItemWrapper.defaultProps = {
18+
style: {},
19+
itemPosition: consts.CENTER
20+
};
21+
22+
ItemWrapper.propTypes = {
23+
children: PropTypes.element.isRequired,
24+
style: PropTypes.object,
25+
itemPosition: PropTypes.oneOf([consts.START, consts.CENTER, consts.END])
26+
};
27+
28+
export default ItemWrapper;

0 commit comments

Comments
 (0)