Web: Components: group-button: Added theme support, moved styles to a separate file.

This commit is contained in:
TatianaLopaeva 2021-02-10 19:14:47 +03:00
parent d02485121f
commit d958a39e17
3 changed files with 143 additions and 101 deletions

View File

@ -1,111 +1,18 @@
import React from "react";
import styled, { css } from "styled-components";
import PropTypes from "prop-types";
import { Icons } from "../icons";
import DropDown from "../drop-down";
import DropDownItem from "../drop-down-item";
import Checkbox from "../checkbox";
import { tablet } from "../../utils/device";
import { isArrayEqual } from "../../utils/array";
const textColor = "#333333",
disabledTextColor = "#A3A9AE";
const activatedCss = css`
cursor: pointer;
`;
const hoveredCss = css`
cursor: pointer;
`;
const StyledGroupButton = styled.div`
position: relative;
display: inline-flex;
vertical-align: middle;
`;
const StyledDropdownToggle = styled.div`
font-family: Open Sans;
font-style: normal;
font-weight: ${(props) => props.fontWeight};
font-size: 14px;
line-height: 19px;
cursor: default;
outline: 0;
color: ${(props) => (props.disabled ? disabledTextColor : textColor)};
float: left;
height: 19px;
margin: 18px 12px 19px ${(props) => (props.isSelect ? "0px" : "13px")};
overflow: hidden;
padding: 0px;
text-align: center;
text-decoration: none;
white-space: nowrap;
user-select: none;
-o-user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
${(props) =>
!props.disabled &&
(props.activated
? `${activatedCss}`
: css`
&:active {
${activatedCss}
}
`)}
${(props) =>
!props.disabled &&
(props.hovered
? `${hoveredCss}`
: css`
&:hover {
${hoveredCss}
}
`)}
`;
const Caret = styled.div`
display: inline-block;
width: 8px;
margin-left: 6px;
${(props) =>
props.isOpen &&
`
padding-bottom: 2px;
transform: scale(1, -1);
`}
`;
const Separator = styled.div`
vertical-align: middle;
border: 1px solid #eceef1;
width: 0px;
height: 24px;
margin: 16px 12px 0 12px;
`;
const StyledCheckbox = styled.div`
display: inline-block;
margin: auto 0 auto 24px;
@media ${tablet} {
margin: auto 0 auto 16px;
}
& > * {
margin: 0px;
}
`;
import {
StyledCheckbox,
Separator,
Caret,
StyledDropdownToggle,
StyledGroupButton,
} from "./styled-group-button";
class GroupButton extends React.Component {
constructor(props) {

View File

@ -0,0 +1,112 @@
import styled, { css } from "styled-components";
import { tablet } from "../../utils/device";
import NoUserSelect from "../../utils/commonStyles";
import { Base } from "../../themes";
const activatedCss = css`
cursor: pointer;
`;
const hoveredCss = css`
cursor: pointer;
`;
const StyledGroupButton = styled.div`
position: relative;
display: inline-flex;
vertical-align: middle;
`;
const StyledDropdownToggle = styled.div`
font-family: Open Sans;
font-style: normal;
font-weight: ${(props) => props.fontWeight};
font-size: ${(props) => props.theme.groupButton.fontSize};
line-height: ${(props) => props.theme.groupButton.lineHeight};
cursor: default;
outline: 0;
color: ${(props) =>
props.disabled
? props.theme.groupButton.disableColor
: props.theme.groupButton.color};
float: ${(props) => props.theme.groupButton.float};
height: ${(props) => props.theme.groupButton.height};
margin: 18px 12px 19px ${(props) => (props.isSelect ? "0px" : "13px")};
overflow: ${(props) => props.theme.groupButton.overflow};
padding: ${(props) => props.theme.groupButton.padding};
text-align: center;
text-decoration: none;
white-space: nowrap;
${NoUserSelect}
${(props) =>
!props.disabled &&
(props.activated
? `${activatedCss}`
: css`
&:active {
${activatedCss}
}
`)}
${(props) =>
!props.disabled &&
(props.hovered
? `${hoveredCss}`
: css`
&:hover {
${hoveredCss}
}
`)}
`;
StyledDropdownToggle.defaultProps = { theme: Base };
const Caret = styled.div`
display: inline-block;
width: 8px;
margin-left: 6px;
${(props) =>
props.isOpen &&
`
padding-bottom: 2px;
transform: scale(1, -1);
`}
`;
const Separator = styled.div`
vertical-align: middle;
border: ${(props) => props.theme.groupButton.separator.border};
width: ${(props) => props.theme.groupButton.separator.width};
height: ${(props) => props.theme.groupButton.separator.height};
margin: ${(props) => props.theme.groupButton.separator.margin};
`;
Separator.defaultProps = { theme: Base };
const StyledCheckbox = styled.div`
display: inline-block;
margin: ${(props) => props.theme.groupButton.checkbox.margin};
@media ${tablet} {
margin: ${(props) => props.theme.groupButton.checkbox.tabletMargin};
}
& > * {
margin: 0px;
}
`;
StyledCheckbox.defaultProps = { theme: Base };
export {
StyledCheckbox,
Separator,
Caret,
StyledDropdownToggle,
StyledGroupButton,
};

View File

@ -253,6 +253,29 @@ const Base = {
},
},
groupButton: {
fontSize: "14px",
lineHeight: "19px",
color: black,
disableColor: gray,
float: "left",
height: "19px",
overflow: "hidden",
padding: "0px",
separator: {
border: `1px solid ${globalColors.grayLightMid}`,
width: "0px",
height: "24px",
margin: "16px 12px 0 12px",
},
checkbox: {
margin: "auto 0 auto 24px",
tabletMargin: "auto 0 auto 16px",
},
},
selectorAddButton: {
background: grayLight,
activeBackground: grayLightMid,