Web: Components: row-content: Added theme support and moved styles to separate file.

This commit is contained in:
TatianaLopaeva 2021-02-15 09:46:40 +03:00
parent 80cdc0dee6
commit d5b3a37b3d
3 changed files with 210 additions and 155 deletions

View File

@ -1,161 +1,14 @@
import React from "react";
import styled, { css } from "styled-components";
import PropTypes from "prop-types";
import { tablet, size } from "../../utils/device";
const truncateCss = css`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;
const commonCss = css`
margin: 0 6px;
font-family: "Open Sans";
font-size: 12px;
font-style: normal;
font-weight: 600;
`;
const containerTabletStyle = css`
display: block;
height: 56px;
`;
const mainWrapperTabletStyle = css`
min-width: 140px;
margin-right: 8px;
margin-top: 8px;
width: 95%;
`;
const mainContainerTabletStyle = css`
${truncateCss};
max-width: 100%;
`;
const sideInfoTabletStyle = css`
display: block;
min-width: 160px;
margin: 0 6px;
${commonCss};
color: ${(props) => props.color && props.color};
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;
const StyledRowContent = styled.div`
width: 100%;
display: inline-flex;
${(props) =>
(!props.disableSideInfo &&
props.widthProp &&
props.widthProp < size.tablet) ||
props.isMobile
? `${containerTabletStyle}`
: `
@media ${tablet} {
${containerTabletStyle}
}
`}
`;
const MainContainerWrapper = styled.div`
${commonCss};
display: flex;
align-self: center;
margin-right: auto;
width: ${(props) =>
props.mainContainerWidth ? props.mainContainerWidth : "140px"};
min-width: 140px;
${(props) =>
(!props.disableSideInfo &&
props.widthProp &&
props.widthProp < size.tablet) ||
props.isMobile
? `${mainWrapperTabletStyle}`
: `
@media ${tablet} {
${mainWrapperTabletStyle}
}
`}
`;
const MainContainer = styled.div`
height: 20px;
margin-right: 8px;
max-width: 86%;
${(props) =>
(props.widthProp && props.widthProp < size.tablet) || props.isMobile
? `${mainContainerTabletStyle}`
: `
@media ${tablet} {
${mainContainerTabletStyle}
}
`}
`;
const MainIcons = styled.div`
height: 19px;
align-self: center;
white-space: nowrap;
`;
const SideContainerWrapper = styled.div`
${commonCss};
${(props) =>
(props.widthProp && props.widthProp < size.tablet) || props.isMobile
? `${truncateCss}`
: `
@media ${tablet} {
${truncateCss}
}
`}
align-self: center;
align-items: center;
> a {
vertical-align: middle;
}
width: ${(props) => (props.containerWidth ? props.containerWidth : "40px")};
min-width: ${(props) =>
props.containerMinWidth ? props.containerMinWidth : "40px"};
color: ${(props) => props.color && props.color};
${(props) =>
(!props.disableSideInfo &&
props.widthProp &&
props.widthProp < size.tablet) ||
props.isMobile
? `display: none;`
: `
@media ${tablet} {
display: none;
}
`}
`;
const TabletSideInfo = styled.div`
display: none;
${(props) => (props.color ? `color: ${props.color};` : null)}
${(props) =>
(props.widthProp && props.widthProp < size.tablet) || props.isMobile
? `${sideInfoTabletStyle}`
: `
@media ${tablet} {
${sideInfoTabletStyle}
}
`}
`;
import {
TabletSideInfo,
SideContainerWrapper,
MainContainer,
MainIcons,
MainContainerWrapper,
StyledRowContent,
} from "./styled-row-content";
const getSideInfo = (content, convert) => {
let info = "";

View File

@ -0,0 +1,172 @@
import styled, { css } from "styled-components";
import { Base } from "../../themes";
import { tablet, size } from "../../utils/device";
const truncateCss = css`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;
const commonCss = css`
margin: ${(props) => props.theme.rowContent.margin};
font-family: "Open Sans";
font-size: ${(props) => props.theme.rowContent.fontSize};
font-style: ${(props) => props.theme.rowContent.fontStyle};
font-weight: ${(props) => props.theme.rowContent.fontWeight};
`;
const containerTabletStyle = css`
display: block;
height: ${(props) => props.theme.rowContent.height};
`;
const mainWrapperTabletStyle = css`
min-width: ${(props) => props.theme.rowContent.mainWrapper.minWidth};
margin-right: ${(props) => props.theme.rowContent.mainWrapper.marginRight};
margin-top: ${(props) => props.theme.rowContent.mainWrapper.marginTop};
width: ${(props) => props.theme.rowContent.mainWrapper.width};
`;
const mainContainerTabletStyle = css`
${truncateCss};
max-width: ${(props) => props.theme.rowContent.maxWidth};
`;
const sideInfoTabletStyle = css`
display: block;
min-width: ${(props) => props.theme.rowContent.sideInfo.minWidth};
margin: ${(props) => props.theme.rowContent.sideInfo.margin};
${commonCss};
color: ${(props) => props.color && props.color};
white-space: nowrap;
overflow: ${(props) => props.theme.rowContent.sideInfo.overflow};
text-overflow: ${(props) => props.theme.rowContent.sideInfo.textOverflow};
`;
const StyledRowContent = styled.div`
width: 100%;
display: inline-flex;
${(props) =>
(!props.disableSideInfo &&
props.widthProp &&
props.widthProp < size.tablet) ||
props.isMobile
? `${containerTabletStyle}`
: `
@media ${tablet} {
${containerTabletStyle}
}
`}
`;
StyledRowContent.defaultProps = { theme: Base };
const MainContainerWrapper = styled.div`
${commonCss};
display: flex;
align-self: center;
margin-right: auto;
width: ${(props) =>
props.mainContainerWidth ? props.mainContainerWidth : "140px"};
min-width: 140px;
${(props) =>
(!props.disableSideInfo &&
props.widthProp &&
props.widthProp < size.tablet) ||
props.isMobile
? `${mainWrapperTabletStyle}`
: `
@media ${tablet} {
${mainWrapperTabletStyle}
}
`}
`;
MainContainerWrapper.defaultProps = { theme: Base };
const MainContainer = styled.div`
height: 20px;
margin-right: 8px;
max-width: 86%;
${(props) =>
(props.widthProp && props.widthProp < size.tablet) || props.isMobile
? `${mainContainerTabletStyle}`
: `
@media ${tablet} {
${mainContainerTabletStyle}
}
`}
`;
MainContainer.defaultProps = { theme: Base };
const MainIcons = styled.div`
height: ${(props) => props.theme.rowContent.icons.height};
align-self: center;
white-space: nowrap;
`;
MainIcons.defaultProps = { theme: Base };
const SideContainerWrapper = styled.div`
${commonCss};
${(props) =>
(props.widthProp && props.widthProp < size.tablet) || props.isMobile
? `${truncateCss}`
: `
@media ${tablet} {
${truncateCss}
}
`}
align-self: center;
align-items: center;
> a {
vertical-align: middle;
}
width: ${(props) => (props.containerWidth ? props.containerWidth : "40px")};
min-width: ${(props) =>
props.containerMinWidth ? props.containerMinWidth : "40px"};
color: ${(props) => props.color && props.color};
${(props) =>
(!props.disableSideInfo &&
props.widthProp &&
props.widthProp < size.tablet) ||
props.isMobile
? `display: none;`
: `
@media ${tablet} {
display: none;
}
`}
`;
SideContainerWrapper.defaultProps = { theme: Base };
const TabletSideInfo = styled.div`
display: none;
${(props) => (props.color ? `color: ${props.color};` : null)}
${(props) =>
(props.widthProp && props.widthProp < size.tablet) || props.isMobile
? `${sideInfoTabletStyle}`
: `
@media ${tablet} {
${sideInfoTabletStyle}
}
`}
`;
TabletSideInfo.defaultProps = { theme: Base };
export {
TabletSideInfo,
SideContainerWrapper,
MainContainer,
MainIcons,
MainContainerWrapper,
StyledRowContent,
};

View File

@ -298,6 +298,7 @@ const Base = {
},
},
selectorAddButton: {
background: grayLight,
activeBackground: grayLightMid,
@ -435,6 +436,34 @@ const Base = {
},
},
rowContent: {
icons: {
height: "19px",
},
margin: "0 6px",
fontSize: "12px",
fontStyle: "normal",
fontWeight: "600",
height: "56px",
maxWidth:" 100%",
sideInfo: {
minWidth: "160px",
margin: "0 6px",
overflow: "hidden",
textOverflow: "ellipsis",
},
mainWrapper: {
minWidth: "140px",
marginRight: "8px",
marginTop: "8px",
width: "95%",
},
},
badge: {
border: "1px solid transparent",
padding: "1px",
@ -574,6 +603,7 @@ const Base = {
},
},
searchInput: {
fontSize: "14px",
fontWeight: "600",