2022-09-30 03:56:41 +08:00
|
|
|
import styled, { css } from 'styled-components';
|
2021-11-02 20:26:36 +08:00
|
|
|
import {
|
|
|
|
colorBlueLight,
|
|
|
|
colorText,
|
|
|
|
colorGrayLighter,
|
2022-09-30 03:56:41 +08:00
|
|
|
colorGrayLight,
|
2021-11-02 20:26:36 +08:00
|
|
|
colorPrimary,
|
|
|
|
} from '/imports/ui/stylesheets/styled-components/palette';
|
|
|
|
import {
|
|
|
|
smPaddingX,
|
|
|
|
smPaddingY,
|
|
|
|
borderRadius,
|
|
|
|
borderSize,
|
|
|
|
} from '/imports/ui/stylesheets/styled-components/general';
|
|
|
|
import { fontSizeBase } from '/imports/ui/stylesheets/styled-components/typography';
|
|
|
|
import TextareaAutosize from 'react-autosize-textarea';
|
2022-05-20 04:41:18 +08:00
|
|
|
import EmojiPickerComponent from '/imports/ui/components/emoji-picker/component';
|
2022-02-15 04:20:50 +08:00
|
|
|
import Button from '/imports/ui/components/common/button/component';
|
2021-11-02 20:26:36 +08:00
|
|
|
|
|
|
|
const Form = styled.form`
|
|
|
|
flex-grow: 0;
|
|
|
|
flex-shrink: 0;
|
|
|
|
align-self: flex-end;
|
|
|
|
width: 100%;
|
|
|
|
position: relative;
|
|
|
|
margin-bottom: calc(-1 * ${smPaddingX});
|
|
|
|
margin-top: .2rem;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Wrapper = styled.div`
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Input = styled(TextareaAutosize)`
|
|
|
|
flex: 1;
|
|
|
|
background: #fff;
|
|
|
|
background-clip: padding-box;
|
|
|
|
margin: 0;
|
|
|
|
color: ${colorText};
|
|
|
|
-webkit-appearance: none;
|
|
|
|
padding: calc(${smPaddingY} * 2.5) calc(${smPaddingX} * 1.25);
|
|
|
|
resize: none;
|
|
|
|
transition: none;
|
|
|
|
border-radius: ${borderRadius};
|
|
|
|
font-size: ${fontSizeBase};
|
|
|
|
line-height: 1;
|
|
|
|
min-height: 2.5rem;
|
|
|
|
max-height: 10rem;
|
|
|
|
border: 1px solid ${colorGrayLighter};
|
|
|
|
box-shadow: 0 0 0 1px ${colorGrayLighter};
|
|
|
|
|
|
|
|
&:disabled,
|
|
|
|
&[disabled] {
|
|
|
|
cursor: not-allowed;
|
|
|
|
opacity: .75;
|
|
|
|
background-color: rgba(167,179,189,0.25);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
border-radius: ${borderSize};
|
|
|
|
box-shadow: 0 0 0 ${borderSize} ${colorBlueLight}, inset 0 0 0 1px ${colorPrimary};
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover,
|
|
|
|
&:active,
|
|
|
|
&:focus {
|
|
|
|
outline: transparent;
|
|
|
|
outline-style: dotted;
|
|
|
|
outline-width: ${borderSize};
|
|
|
|
}
|
2022-09-30 03:56:41 +08:00
|
|
|
|
|
|
|
${({ emojiEnabled }) => emojiEnabled ?
|
|
|
|
css`
|
|
|
|
padding-left: calc(${smPaddingX} * 3);
|
|
|
|
`
|
|
|
|
: null
|
|
|
|
}
|
2021-11-02 20:26:36 +08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const SendButton = styled(Button)`
|
|
|
|
margin:0 0 0 ${smPaddingX};
|
|
|
|
align-self: center;
|
|
|
|
font-size: 0.9rem;
|
|
|
|
|
|
|
|
[dir="rtl"] & {
|
|
|
|
margin: 0 ${smPaddingX} 0 0;
|
|
|
|
-webkit-transform: scale(-1, 1);
|
|
|
|
-moz-transform: scale(-1, 1);
|
|
|
|
-ms-transform: scale(-1, 1);
|
|
|
|
-o-transform: scale(-1, 1);
|
|
|
|
transform: scale(-1, 1);
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2022-05-20 04:41:18 +08:00
|
|
|
const EmojiButton = styled(Button)`
|
|
|
|
margin:0 0 0 ${smPaddingX};
|
|
|
|
align-self: center;
|
|
|
|
font-size: 0.5rem;
|
|
|
|
|
|
|
|
[dir="rtl"] & {
|
|
|
|
margin: 0 ${smPaddingX} 0 0;
|
|
|
|
-webkit-transform: scale(-1, 1);
|
|
|
|
-moz-transform: scale(-1, 1);
|
|
|
|
-ms-transform: scale(-1, 1);
|
|
|
|
-o-transform: scale(-1, 1);
|
|
|
|
transform: scale(-1, 1);
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const EmojiPickerWrapper = styled.div`
|
2023-10-17 01:17:11 +08:00
|
|
|
em-emoji-picker {
|
|
|
|
width: 100%;
|
|
|
|
max-height: 300px;
|
2022-05-20 04:41:18 +08:00
|
|
|
}
|
2023-10-17 01:17:11 +08:00
|
|
|
padding-bottom: 5px;
|
2022-05-20 04:41:18 +08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const EmojiPicker = styled(EmojiPickerComponent)``;
|
|
|
|
|
2022-09-30 03:56:41 +08:00
|
|
|
const EmojiButtonWrapper = styled.div`
|
|
|
|
color: ${colorGrayLight};
|
|
|
|
width: 2.5rem;
|
|
|
|
height: 2.5rem;
|
|
|
|
border: none;
|
|
|
|
position: absolute;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
font-size: ${fontSizeBase};
|
|
|
|
cursor: pointer;
|
|
|
|
`;
|
|
|
|
|
2021-11-02 20:26:36 +08:00
|
|
|
export default {
|
|
|
|
Form,
|
|
|
|
Wrapper,
|
|
|
|
Input,
|
|
|
|
SendButton,
|
2022-05-20 04:41:18 +08:00
|
|
|
EmojiButton,
|
|
|
|
EmojiButtonWrapper,
|
|
|
|
EmojiPicker,
|
|
|
|
EmojiPickerWrapper,
|
2021-11-02 20:26:36 +08:00
|
|
|
};
|