2022-08-17 09:07:36 +00:00
|
|
|
import styled, { css } from "styled-components";
|
2022-12-09 08:59:47 +00:00
|
|
|
import { isMobileOnly } from "react-device-detect";
|
2021-02-25 21:19:45 +00:00
|
|
|
import Base from "../../themes/base";
|
2021-02-24 17:11:23 +00:00
|
|
|
import NoUserSelect from "../../utils/commonStyles";
|
2021-02-04 10:28:48 +00:00
|
|
|
|
2022-12-12 08:00:50 +00:00
|
|
|
import TriangleDownIcon from "../../../../public/images/triangle.down.react.svg";
|
|
|
|
import commonIconsStyles from "../../utils/common-icons-style";
|
|
|
|
|
|
|
|
const StyledTriangleDownIcon = styled(TriangleDownIcon)`
|
|
|
|
${commonIconsStyles}
|
|
|
|
`;
|
|
|
|
|
2022-08-17 09:07:36 +00:00
|
|
|
const modernViewButton = css`
|
|
|
|
height: ${(props) => props.theme.comboBox.button.heightModernView};
|
|
|
|
background: ${(props) =>
|
|
|
|
props.isOpen
|
2022-12-08 16:51:33 +00:00
|
|
|
? props.theme.comboBox.button.focusBackgroundModernView
|
2022-08-17 09:07:36 +00:00
|
|
|
: props.theme.comboBox.button.backgroundModernView};
|
|
|
|
|
2022-12-08 16:51:33 +00:00
|
|
|
border: none !important;
|
2022-12-12 08:00:50 +00:00
|
|
|
padding-right: 0px;
|
2022-08-17 09:07:36 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
const hoverModernViewButton = css`
|
|
|
|
background: ${(props) =>
|
|
|
|
props.isOpen
|
2022-12-08 16:51:33 +00:00
|
|
|
? props.theme.comboBox.button.focusBackgroundModernView
|
2022-08-17 09:07:36 +00:00
|
|
|
: props.theme.comboBox.button.hoverBackgroundModernView} !important;
|
|
|
|
`;
|
|
|
|
|
2021-02-04 10:28:48 +00:00
|
|
|
const StyledComboButton = styled.div`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2022-12-12 08:00:50 +00:00
|
|
|
justify-content: center;
|
2021-02-04 10:28:48 +00:00
|
|
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
|
|
|
|
|
|
height: ${(props) =>
|
|
|
|
props.noBorder
|
|
|
|
? props.theme.comboBox.button.height
|
|
|
|
: props.theme.comboBox.button.heightWithBorder};
|
|
|
|
width: ${(props) =>
|
|
|
|
(props.scaled && "100%") ||
|
|
|
|
(props.size === "base" && props.theme.comboBox.width.base) ||
|
|
|
|
(props.size === "middle" && props.theme.comboBox.width.middle) ||
|
|
|
|
(props.size === "big" && props.theme.comboBox.width.big) ||
|
|
|
|
(props.size === "huge" && props.theme.comboBox.width.huge) ||
|
|
|
|
(props.size === "content" && "fit-content")};
|
|
|
|
|
|
|
|
${NoUserSelect};
|
|
|
|
|
2022-12-12 08:00:50 +00:00
|
|
|
padding-left: ${(props) =>
|
|
|
|
props.size === "content"
|
|
|
|
? props.theme.comboBox.button.paddingLeft
|
|
|
|
: props.theme.comboBox.button.selectPaddingLeft};
|
|
|
|
|
|
|
|
padding-right: ${(props) =>
|
|
|
|
props.size === "content"
|
|
|
|
? props.displayArrow
|
|
|
|
? props.theme.comboBox.button.paddingRight
|
|
|
|
: props.theme.comboBox.button.paddingRightNoArrow
|
|
|
|
: props.displayArrow
|
|
|
|
? props.theme.comboBox.button.selectPaddingRight
|
|
|
|
: props.theme.comboBox.button.selectPaddingRightNoArrow};
|
2021-02-04 10:28:48 +00:00
|
|
|
|
|
|
|
background: ${(props) =>
|
|
|
|
!props.noBorder
|
|
|
|
? props.theme.comboBox.button.background
|
|
|
|
: props.theme.comboBox.button.backgroundWithBorder};
|
|
|
|
|
|
|
|
color: ${(props) =>
|
|
|
|
props.isDisabled
|
|
|
|
? props.theme.comboBox.button.disabledColor
|
|
|
|
: props.theme.comboBox.button.color};
|
|
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
!props.noBorder &&
|
|
|
|
`
|
|
|
|
border: ${props.theme.comboBox.button.border};
|
|
|
|
border-radius: ${props.theme.comboBox.button.borderRadius};
|
|
|
|
`}
|
|
|
|
|
|
|
|
border-color: ${(props) =>
|
2021-12-13 06:47:27 +00:00
|
|
|
props.isOpen && props.theme.comboBox.button.openBorderColor};
|
2021-02-04 10:28:48 +00:00
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
props.isDisabled &&
|
|
|
|
!props.noBorder &&
|
|
|
|
`
|
|
|
|
border-color: ${props.theme.comboBox.button.disabledBorderColor};
|
|
|
|
background: ${props.theme.comboBox.button.disabledBackground};
|
|
|
|
`}
|
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
!props.noBorder &&
|
|
|
|
`
|
|
|
|
height: 32px;
|
|
|
|
`}
|
|
|
|
|
2022-08-17 09:07:36 +00:00
|
|
|
${(props) => props.modernView && modernViewButton}
|
|
|
|
|
2022-12-12 09:42:15 +00:00
|
|
|
|
|
|
|
.optionalBlock {
|
|
|
|
svg {
|
|
|
|
path {
|
|
|
|
fill: ${(props) =>
|
|
|
|
props.isOpen
|
|
|
|
? props.theme.iconButton.hoverColor
|
|
|
|
: props.theme.iconButton.color};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-04 10:28:48 +00:00
|
|
|
:hover {
|
|
|
|
border-color: ${(props) =>
|
|
|
|
props.isOpen
|
|
|
|
? props.theme.comboBox.button.hoverBorderColorOpen
|
|
|
|
: props.theme.comboBox.button.hoverBorderColor};
|
|
|
|
cursor: ${(props) =>
|
|
|
|
props.isDisabled || (!props.containOptions && !props.withAdvancedOptions)
|
|
|
|
? "default"
|
|
|
|
: "pointer"};
|
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
props.isDisabled &&
|
|
|
|
`
|
|
|
|
border-color: ${props.theme.comboBox.button.hoverDisabledBorderColor};
|
|
|
|
`}
|
2022-12-07 07:13:30 +00:00
|
|
|
|
2022-12-08 16:51:33 +00:00
|
|
|
${(props) => props.modernView && hoverModernViewButton}
|
|
|
|
|
2022-12-07 07:13:30 +00:00
|
|
|
.optionalBlock {
|
|
|
|
svg {
|
|
|
|
path {
|
|
|
|
fill: ${(props) => props.theme.iconButton.hoverColor};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-04 10:28:48 +00:00
|
|
|
}
|
|
|
|
.combo-button-label {
|
|
|
|
margin-right: ${(props) =>
|
|
|
|
props.noBorder
|
|
|
|
? props.theme.comboBox.label.marginRight
|
|
|
|
: props.theme.comboBox.label.marginRightWithBorder};
|
|
|
|
color: ${(props) =>
|
|
|
|
props.isDisabled
|
|
|
|
? props.theme.comboBox.label.disabledColor
|
2021-12-13 06:47:27 +00:00
|
|
|
: props.isSelected
|
|
|
|
? props.theme.comboBox.label.selectedColor
|
2021-02-04 10:28:48 +00:00
|
|
|
: props.theme.comboBox.label.color};
|
|
|
|
|
|
|
|
max-width: ${(props) => props.theme.comboBox.label.maxWidth};
|
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
props.noBorder &&
|
|
|
|
`
|
|
|
|
line-height: ${props.theme.comboBox.label.lineHeightWithoutBorder};
|
|
|
|
`}
|
|
|
|
}
|
2022-10-19 11:47:05 +00:00
|
|
|
|
|
|
|
:focus {
|
|
|
|
outline: none;
|
|
|
|
border-color: ${(props) =>
|
|
|
|
props.isOpen
|
|
|
|
? props.theme.comboBox.button.hoverBorderColorOpen
|
|
|
|
: props.theme.comboBox.button.hoverBorderColor};
|
2022-12-07 07:13:30 +00:00
|
|
|
|
|
|
|
.optionalBlock {
|
|
|
|
svg {
|
|
|
|
path {
|
2022-12-12 09:42:15 +00:00
|
|
|
fill: ${(props) =>
|
|
|
|
props.isOpen
|
|
|
|
? props.theme.iconButton.hoverColor
|
|
|
|
: props.theme.iconButton.color};
|
2022-12-07 07:13:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-19 11:47:05 +00:00
|
|
|
}
|
2021-02-04 10:28:48 +00:00
|
|
|
`;
|
|
|
|
StyledComboButton.defaultProps = { theme: Base };
|
|
|
|
|
|
|
|
const StyledOptionalItem = styled.div`
|
|
|
|
margin-right: ${(props) => props.theme.comboBox.childrenButton.marginRight};
|
|
|
|
|
|
|
|
path {
|
2021-02-05 10:10:03 +00:00
|
|
|
fill: ${(props) =>
|
|
|
|
props.defaultOption
|
|
|
|
? props.isDisabled
|
|
|
|
? props.theme.comboBox.childrenButton.defaultDisabledColor
|
|
|
|
: props.theme.comboBox.childrenButton.defaultColor
|
|
|
|
: props.isDisabled
|
|
|
|
? props.theme.comboBox.childrenButton.disabledColor
|
|
|
|
: props.theme.comboBox.childrenButton.color};
|
2021-02-04 10:28:48 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
StyledOptionalItem.defaultProps = { theme: Base };
|
|
|
|
|
|
|
|
const StyledIcon = styled.div`
|
2021-03-18 10:45:22 +00:00
|
|
|
margin-right: ${(props) => props.theme.comboBox.childrenButton.marginRight};
|
2021-02-04 10:28:48 +00:00
|
|
|
width: ${(props) => props.theme.comboBox.childrenButton.width};
|
|
|
|
height: ${(props) => props.theme.comboBox.childrenButton.height};
|
2021-02-05 10:10:03 +00:00
|
|
|
|
|
|
|
.combo-button_selected-icon {
|
|
|
|
path {
|
|
|
|
fill: ${(props) =>
|
|
|
|
props.defaultOption
|
|
|
|
? props.isDisabled
|
|
|
|
? props.theme.comboBox.childrenButton.defaultDisabledColor
|
|
|
|
: props.theme.comboBox.childrenButton.defaultColor
|
|
|
|
: props.isDisabled
|
|
|
|
? props.theme.comboBox.childrenButton.disabledColor
|
2021-12-13 07:03:32 +00:00
|
|
|
: props.isSelected
|
|
|
|
? props.theme.comboBox.childrenButton.selectedColor
|
2021-02-05 10:10:03 +00:00
|
|
|
: props.theme.comboBox.childrenButton.color};
|
|
|
|
}
|
|
|
|
}
|
2021-02-20 14:54:12 +00:00
|
|
|
svg {
|
|
|
|
&:not(:root) {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
2021-02-04 10:28:48 +00:00
|
|
|
`;
|
|
|
|
StyledIcon.defaultProps = { theme: Base };
|
|
|
|
|
|
|
|
const StyledArrowIcon = styled.div`
|
|
|
|
display: flex;
|
2022-12-06 10:44:28 +00:00
|
|
|
align-self: center;
|
2021-02-04 10:28:48 +00:00
|
|
|
|
2021-02-05 10:10:03 +00:00
|
|
|
.combo-buttons_expander-icon {
|
|
|
|
path {
|
2022-12-06 11:04:15 +00:00
|
|
|
fill: ${(props) => props.theme.comboBox.label.selectedColor};
|
2021-02-05 10:10:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-04 10:28:48 +00:00
|
|
|
width: ${(props) =>
|
2022-12-12 08:00:50 +00:00
|
|
|
props.displayArrow ? props.theme.comboBox.arrow.width : "0px"};
|
2021-03-09 07:54:03 +00:00
|
|
|
flex: ${(props) =>
|
2022-12-12 08:00:50 +00:00
|
|
|
props.displayArrow ? props.theme.comboBox.arrow.flex : "0px"};
|
2021-02-04 10:28:48 +00:00
|
|
|
margin-right: ${(props) =>
|
2022-12-12 08:00:50 +00:00
|
|
|
props.displayArrow ? props.theme.comboBox.arrow.marginRight : "0px"};
|
2021-02-04 10:28:48 +00:00
|
|
|
margin-left: ${(props) =>
|
2022-12-12 08:00:50 +00:00
|
|
|
props.displayArrow ? props.theme.comboBox.arrow.marginLeft : "0px"};
|
2021-02-04 10:28:48 +00:00
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
props.isOpen &&
|
|
|
|
`
|
|
|
|
transform: scale(1, -1);
|
|
|
|
`}
|
2022-12-09 08:59:47 +00:00
|
|
|
|
|
|
|
${isMobileOnly &&
|
|
|
|
css`
|
|
|
|
margin-left: auto;
|
|
|
|
`}
|
2021-02-04 10:28:48 +00:00
|
|
|
`;
|
|
|
|
StyledArrowIcon.defaultProps = { theme: Base };
|
|
|
|
|
2022-12-12 08:00:50 +00:00
|
|
|
export {
|
|
|
|
StyledArrowIcon,
|
|
|
|
StyledIcon,
|
|
|
|
StyledOptionalItem,
|
|
|
|
StyledComboButton,
|
|
|
|
StyledTriangleDownIcon,
|
|
|
|
};
|