Skip to content

Commit

Permalink
Web: Files: Tiles: Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kulak committed Jan 14, 2022
1 parent fe75b6f commit 8e62da4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ const commonCss = css`
const StyledTileContent = styled.div`
width: 100%;
display: inline-flex;
${(props) =>
!props.disableSideInfo &&
css`
@media (max-width: 1024px) {
display: block;
height: 56px;
}
`};
`;

const MainContainerWrapper = styled.div`
Expand All @@ -36,15 +27,6 @@ const MainContainerWrapper = styled.div`
display: flex;
align-self: center;
margin-right: auto;
${(props) =>
!props.disableSideInfo &&
css`
@media (max-width: 1024px) {
margin-right: 8px;
margin-top: 8px;
}
`};
`;

const MainContainer = styled.div`
Expand Down Expand Up @@ -82,87 +64,17 @@ const MainIcons = styled.div`
}
`;

const SideContainerWrapper = styled.div`
${commonCss};
@media (max-width: 1024px) {
${truncateCss};
}
align-self: center;
align-items: center;
> a {
vertical-align: middle;
}
color: ${(props) => props.color && props.color};
${(props) =>
!props.disableSideInfo &&
css`
@media (max-width: 1024px) {
display: none;
}
`};
`;

const TabletSideInfo = styled.div`
display: none;
@media (max-width: 1024px) {
display: block;
color: ${(props) => props.color && props.color};
${commonCss};
${truncateCss};
}
`;

const getSideInfo = (content) => {
let info = "";
const lastIndex = content.length - 1;

content.forEach((element, index) => {
if (element) {
const delimiter = index === lastIndex ? "" : " | ";
if (index > 1) {
info +=
element.props && element.props.children
? element.props.children + delimiter
: "";
}
}
});

return info;
};

const TileContent = (props) => {
const {
children,
disableSideInfo,
id,
className,
style,
sideColor,
onClick,
badges,
} = props;

const sideInfo = getSideInfo(children);
const { children, id, className, style, onClick } = props;

return (
<StyledTileContent
disableSideInfo={disableSideInfo}
id={id}
className={className}
style={style}
onClick={onClick}
>
{badges}
<MainContainerWrapper
disableSideInfo={disableSideInfo}
mainContainerWidth={
children[0].props && children[0].props.containerWidth
}
Expand All @@ -172,42 +84,17 @@ const TileContent = (props) => {
</MainContainer>
<MainIcons className="main-icons">{children[1]}</MainIcons>
</MainContainerWrapper>
{children.map((element, index) => {
if (index > 1 && element) {
return (
<SideContainerWrapper
disableSideInfo={disableSideInfo}
key={"side-" + index}
containerWidth={element.props && element.props.containerWidth}
containerMinWidth={
element.props && element.props.containerMinWidth
}
>
{element}
</SideContainerWrapper>
);
}
return null;
})}
{!disableSideInfo && (
<TabletSideInfo color={sideColor}>{sideInfo}</TabletSideInfo>
)}
</StyledTileContent>
);
};

TileContent.propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string,
disableSideInfo: PropTypes.bool,
id: PropTypes.string,
onClick: PropTypes.func,
sideColor: PropTypes.string,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
};

TileContent.defaultProps = {
disableSideInfo: false,
};

export default TileContent;
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ export default inject(
fileActionId: fileActionStore.id,
isEmptyFilesList,
setDragging,
startDrag,
setStartDrag,
folderId: selectedFolderStore.id,
setTooltipPosition,
isRecycleBinFolder: treeFoldersStore.isRecycleBinFolder,
Expand Down

0 comments on commit 8e62da4

Please sign in to comment.