Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sagiv.bengiat committed Sep 26, 2020
2 parents b888750 + a0a5414 commit a0862ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
14 changes: 2 additions & 12 deletions src/react-elastic-carousel/components/ItemWrapperContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@ import React from "react";
import PropTypes from "prop-types";
import { ItemWrapper } from "./styled";
import consts from "../consts";
import { noop, cssPrefix } from "../utils/helpers";
import { noop } from "../utils/helpers";

class ItemWrapperContainer extends React.Component {
onClick = () => {
const { onClick, id } = this.props;
onClick(id);
};
render() {
const { itemPosition, ...restOfProps } = this.props;
return (
<ItemWrapper
onClick={this.onClick}
className={cssPrefix("item-wrapper")}
itemPosition={itemPosition}
{...restOfProps}
/>
);
return <ItemWrapper {...this.props} onClick={this.onClick} />;
}
}

Expand All @@ -29,8 +21,6 @@ ItemWrapperContainer.defaultProps = {
};

ItemWrapperContainer.propTypes = {
children: PropTypes.element.isRequired,
itemPosition: PropTypes.oneOf([consts.START, consts.CENTER, consts.END]),
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onClick: PropTypes.func
};
Expand Down
21 changes: 20 additions & 1 deletion src/react-elastic-carousel/components/styled/ItemWrapper.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
import styled from "styled-components";
import PropTypes from "prop-types";
import { cssPrefix } from "../../utils/helpers";
import consts from "../../consts";

export default styled.div.attrs(({ style }) => ({ style }))`
const ItemWrapper = styled.div.attrs(({ style }) => ({
style,
className: cssPrefix("item-wrapper")
}))`
box-sizing: border-box;
display: flex;
overflow: hidden;
user-select: none;
justify-content: ${({ itemPosition }) => itemPosition};
`;

ItemWrapper.defaultProps = {
style: {},
itemPosition: consts.CENTER
};

ItemWrapper.propTypes = {
children: PropTypes.element.isRequired,
style: PropTypes.object,
itemPosition: PropTypes.oneOf([consts.START, consts.CENTER, consts.END])
};

export default ItemWrapper;

0 comments on commit a0862ca

Please sign in to comment.