@chayns-components/core
Version:
A set of beautiful React components for developing your own applications with chayns.
324 lines (313 loc) • 7.29 kB
JavaScript
import { motion } from 'motion/react';
import styled, { css } from 'styled-components';
import { ComboBoxDirection } from '../../types/comboBox';
export const StyledComboBox = styled.div`
user-select: none;
position: relative;
${_ref => {
let {
$shouldUseFullWidth,
$minWidth,
$shouldUseCurrentItemWidth
} = _ref;
if (typeof $minWidth !== 'number') {
return css`
width: fit-content;
`;
}
if ($shouldUseFullWidth) {
return css`
min-width: ${$minWidth}px;
width: 100%;
`;
}
if ($shouldUseCurrentItemWidth) {
return '';
}
return css`
min-width: ${$minWidth}px;
max-width: ${$minWidth}px;
`;
}}
`;
export const StyledComboBoxHeader = styled.div`
display: flex;
background-color: ${_ref2 => {
let {
theme,
$shouldChangeColor
} = _ref2;
return theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100'];
}};
border: 1px solid rgba(160, 160, 160, 0.3);
cursor: ${_ref3 => {
let {
$isDisabled
} = _ref3;
return !$isDisabled ? 'pointer' : 'default';
}};
justify-content: space-between;
opacity: ${_ref4 => {
let {
$isDisabled
} = _ref4;
return $isDisabled ? 0.5 : 1;
}};
transition: background-color 0.2s ease-in-out;
${_ref5 => {
let {
$shouldShowBigImage
} = _ref5;
return $shouldShowBigImage && css`
height: 42px;
`;
}}
${_ref6 => {
let {
$isOpen,
$direction
} = _ref6;
if ($isOpen) {
return [ComboBoxDirection.BOTTOM, ComboBoxDirection.BOTTOM_LEFT, ComboBoxDirection.BOTTOM_RIGHT].includes($direction) ? css`
border-top-left-radius: 3px;
border-top-right-radius: 3px;
` : css`
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
`;
}
return css`
border-radius: 3px;
`;
}}
${_ref7 => {
let {
$isTouch,
$isDisabled,
theme
} = _ref7;
return !$isTouch && !$isDisabled && css`
&:hover {
background-color: ${theme['secondary-102']};
}
`;
}}
`;
export const StyledComboBoxPlaceholder = styled.div`
align-items: center;
color: ${_ref8 => {
let {
theme
} = _ref8;
return theme.text;
}};
display: flex;
flex: 1 1 auto;
gap: 10px;
min-width: 0;
opacity: ${_ref9 => {
let {
$shouldReduceOpacity
} = _ref9;
return $shouldReduceOpacity ? 0.5 : 1;
}};
`;
export const StyledComboBoxPlaceholderText = styled.div`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
export const StyledComboBoxPrefixAndPlaceholderWrapper = styled.div`
align-items: center;
display: flex;
flex: 1 1 auto;
min-width: 0;
padding: 4px 10px;
`;
export const StyledComboBoxPrefix = styled.div`
flex: 0 0 auto;
min-width: 32px;
padding-right: 5px;
`;
export const StyledComboBoxInput = styled.input`
color: ${_ref0 => {
let {
theme
} = _ref0;
return theme.text;
}};
border: none;
background-color: transparent;
width: 100%;
`;
export const StyledComboBoxPlaceholderImage = styled.img`
box-shadow: 0 0 0 1px
rgba(${_ref1 => {
let {
theme
} = _ref1;
return theme['009-rgb'];
}}, 0.15);
height: ${_ref10 => {
let {
$shouldShowBigImage
} = _ref10;
return $shouldShowBigImage ? '32px' : '22px';
}};
width: ${_ref11 => {
let {
$shouldShowBigImage
} = _ref11;
return $shouldShowBigImage ? '32px' : '22px';
}};
${_ref12 => {
let {
$shouldShowRoundImage
} = _ref12;
return $shouldShowRoundImage && css`
border-radius: 50%;
`;
}}
`;
export const StyledComboBoxClearIconWrapper = styled.div`
align-items: center;
cursor: pointer;
display: flex;
flex: 0 0 auto;
height: 40px;
justify-content: center;
width: 40px;
`;
export const StyledComboBoxIconWrapper = styled.div`
align-items: center;
border-left: ${_ref13 => {
let {
$shouldShowBorderLeft
} = _ref13;
return $shouldShowBorderLeft ? '1px solid rgba(160, 160, 160, 0.3)' : 'none';
}};
cursor: pointer;
display: flex;
flex: 0 0 auto;
height: 40px;
justify-content: center;
width: 40px;
`;
export const StyledMotionComboBoxBody = styled(motion.div)`
background: ${_ref14 => {
let {
theme
} = _ref14;
return theme['000'];
}};
display: flex;
position: absolute;
z-index: 4;
flex-direction: column;
border: 1px solid rgba(160, 160, 160, 0.3);
cursor: pointer;
max-height: ${_ref15 => {
let {
$maxHeight
} = _ref15;
return $maxHeight;
}};
overflow-y: ${_ref16 => {
let {
$overflowY
} = _ref16;
return $overflowY;
}};
overflow-x: hidden;
transform: ${_ref17 => {
let {
$translateX,
$translateY
} = _ref17;
return `translate(${$translateX}, ${$translateY})`;
}};
min-width: ${_ref18 => {
let {
$minWidth
} = _ref18;
return $minWidth;
}}px;
${_ref19 => {
let {
$minWidth,
$overflowY,
$shouldUseCurrentItemWidth
} = _ref19;
return !$shouldUseCurrentItemWidth && css`
max-width: ${$minWidth - ($overflowY === 'scroll' ? 5 : 0)}px;
`;
}}
${_ref20 => {
let {
$direction
} = _ref20;
if ([ComboBoxDirection.BOTTOM, ComboBoxDirection.BOTTOM_LEFT, ComboBoxDirection.BOTTOM_RIGHT].includes($direction)) {
return css`
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.2);
`;
}
return css`
border-top-left-radius: 3px;
border-top-right-radius: 3px;
box-shadow: 0 -3px 10px 0 rgba(0, 0, 0, 0.2);
`;
}}
// Styles for custom scrollbar
${_ref21 => {
let {
$browser,
theme
} = _ref21;
return $browser === 'firefox' ? css`
scrollbar-color: rgba(${theme['text-rgb']}, 0.15) transparent;
scrollbar-width: thin;
` : css`
&::-webkit-scrollbar {
width: 5px;
}
&::-webkit-scrollbar-track {
background-color: transparent;
}
&::-webkit-scrollbar-button {
background-color: transparent;
height: 5px;
}
&::-webkit-scrollbar-thumb {
background-color: rgba(${theme['text-rgb']}, 0.15);
border-radius: 20px;
}
`;
}}
`;
export const StyledComboBoxTopic = styled.div`
align-items: center;
color: rgba(${_ref22 => {
let {
theme
} = _ref22;
return theme['text-rgb'];
}}, 0.65);
position: sticky;
top: 0;
border: black 5px;
cursor: default;
font-weight: bold;
display: flex;
gap: 10px;
z-index: 10;
padding: 4px 10px;
background-color: ${_ref23 => {
let {
theme
} = _ref23;
return theme['secondary-101'];
}};
`;
//# sourceMappingURL=ComboBox.styles.js.map