@chayns-components/emoji-input
Version:
Input field that supports HTML elements and emojis
151 lines (144 loc) • 3.64 kB
JavaScript
import { motion } from 'motion/react';
import styled, { css } from 'styled-components';
import { getFontFamily } from '../../utils/font';
export const StyledEmojiInput = styled.div`
align-items: center;
background-color: ${_ref => {
let {
theme,
$shouldChangeColor
} = _ref;
return theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100'];
}};
border-radius: 3px;
display: flex;
border: 1px solid rgba(160, 160, 160, 0.3);
min-height: 42px;
opacity: ${_ref2 => {
let {
$isDisabled
} = _ref2;
return $isDisabled ? 0.5 : 1;
}};
pointer-events: ${_ref3 => {
let {
$isDisabled
} = _ref3;
return $isDisabled ? 'none' : 'initial';
}};
position: relative;
transition: opacity 0.3s ease;
`;
export const StyledMotionEmojiInputProgress = styled(motion.div)`
background-color: ${_ref4 => {
let {
theme
} = _ref4;
return theme['402'];
}};
height: 100%;
position: absolute;
z-index: 2;
border-radius: 3px;
`;
export const StyledEmojiInputContent = styled.div`
align-items: end;
border-radius: 3px;
display: flex;
flex: 1 1 auto;
gap: 10px;
padding: 8px 10px;
z-index: 3;
`;
export const StyledMotionEmojiInputEditor = styled(motion.div)`
color: ${_ref5 => {
let {
theme,
$shouldShowContent
} = _ref5;
return $shouldShowContent ? theme.text : theme['100'];
}};
flex: 1 1 auto;
font-family: ${getFontFamily};
overflow-y: scroll;
overflow-x: hidden;
word-break: break-word;
// This fixes a bug where the field is not editable in certain browsers.
// This is for example the case on iOS 15 or older.
-webkit-user-modify: read-write;
-webkit-user-select: text;
lc_mention,
nerIgnore,
nerReplace {
font-weight: bold;
span {
opacity: 0.5;
}
}
// Styles for custom scrollbar
${_ref6 => {
let {
$browser,
theme
} = _ref6;
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 StyledEmojiInputRightWrapper = styled.div`
align-self: stretch;
border-bottom-right-radius: 3px;
border-top-right-radius: 3px;
flex: 0 0 auto;
overflow: hidden;
`;
export const StyledEmojiInputLabel = styled.label`
color: rgba(${_ref7 => {
let {
theme
} = _ref7;
return theme['text-rgb'];
}}, 0.45);
left: ${_ref8 => {
let {
$offsetWidth
} = _ref8;
return $offsetWidth ? `${$offsetWidth + 10}px` : '10px';
}};
top: 12px;
align-items: baseline;
display: flex;
flex: 0 0 auto;
gap: 4px;
line-height: 1.3;
pointer-events: none;
position: absolute;
user-select: none;
white-space: nowrap;
max-width: ${_ref9 => {
let {
$maxWidth,
$offsetWidth
} = _ref9;
return `${$maxWidth - ($offsetWidth ?? 0)}px`;
}};
overflow: hidden;
`;
//# sourceMappingURL=EmojiInput.styles.js.map