2024-10-03 06:28:02 +08:00
|
|
|
import styled, { css } from 'styled-components';
|
2024-10-18 09:11:47 +08:00
|
|
|
import ReactMarkdown from 'react-markdown';
|
2024-10-03 06:28:02 +08:00
|
|
|
import {
|
2024-10-17 03:10:27 +08:00
|
|
|
colorGrayLightest,
|
|
|
|
colorPrimary,
|
2024-10-18 09:11:47 +08:00
|
|
|
colorText,
|
2024-10-18 00:18:23 +08:00
|
|
|
colorWhite,
|
2024-10-03 06:28:02 +08:00
|
|
|
} from '/imports/ui/stylesheets/styled-components/palette';
|
2024-10-17 03:10:27 +08:00
|
|
|
import {
|
|
|
|
mdPadding, smPadding, smPaddingX, xlPadding,
|
|
|
|
} from '/imports/ui/stylesheets/styled-components/general';
|
|
|
|
import EmojiButton from '../chat-message-list/page/chat-message/message-toolbar/emoji-button/component';
|
2024-10-03 06:28:02 +08:00
|
|
|
|
|
|
|
const Container = styled.div<{ $hidden: boolean; $animations: boolean }>`
|
2024-10-17 03:10:27 +08:00
|
|
|
border-radius: 0.375rem;
|
2024-10-18 00:18:23 +08:00
|
|
|
background-color: ${colorWhite};
|
2024-10-17 03:10:27 +08:00
|
|
|
box-shadow: inset 0 0 0 1px ${colorGrayLightest};
|
|
|
|
display: flex;
|
2024-10-18 09:11:47 +08:00
|
|
|
align-items: center;
|
|
|
|
overflow: hidden;
|
2024-10-17 03:10:27 +08:00
|
|
|
|
|
|
|
[dir='ltr'] & {
|
|
|
|
border-right: 0.375rem solid ${colorPrimary};
|
|
|
|
}
|
|
|
|
|
|
|
|
[dir='rtl'] & {
|
|
|
|
border-left: 0.375rem solid ${colorPrimary};
|
|
|
|
}
|
2024-10-03 06:28:02 +08:00
|
|
|
|
|
|
|
${({ $hidden }) => ($hidden
|
|
|
|
? css`
|
|
|
|
height: 0;
|
2024-10-17 03:10:27 +08:00
|
|
|
min-height: 0;
|
2024-10-03 06:28:02 +08:00
|
|
|
`
|
|
|
|
: css`
|
2024-10-18 09:11:47 +08:00
|
|
|
min-height: calc(1rlh + ${mdPadding} * 2);
|
|
|
|
height: calc(1rlh + ${mdPadding} * 2);
|
2024-10-17 03:10:27 +08:00
|
|
|
padding: ${mdPadding} calc(${smPaddingX} * 1.25);
|
|
|
|
margin-bottom: ${smPadding};
|
|
|
|
|
|
|
|
[dir='ltr'] & {
|
|
|
|
margin-right: ${xlPadding};
|
|
|
|
}
|
|
|
|
|
|
|
|
[dir='rtl'] & {
|
|
|
|
margin-left: ${xlPadding};
|
|
|
|
}
|
2024-10-03 06:28:02 +08:00
|
|
|
`
|
|
|
|
)}
|
|
|
|
|
|
|
|
${({ $animations }) => $animations
|
|
|
|
&& css`
|
2024-10-17 03:10:27 +08:00
|
|
|
transition-property: height, min-height;
|
2024-10-03 06:28:02 +08:00
|
|
|
transition-duration: 0.1s;
|
|
|
|
`}
|
|
|
|
`;
|
|
|
|
|
2024-10-18 09:11:47 +08:00
|
|
|
const Message = styled.div`
|
|
|
|
line-height: 1rlh;
|
|
|
|
flex-grow: 1;
|
2024-10-03 06:28:02 +08:00
|
|
|
`;
|
|
|
|
|
2024-10-18 09:11:47 +08:00
|
|
|
const Markdown = styled(ReactMarkdown)<{
|
|
|
|
$emphasizedMessage: boolean;
|
|
|
|
}>`
|
|
|
|
color: ${colorText};
|
|
|
|
|
|
|
|
${({ $emphasizedMessage }) => $emphasizedMessage && `
|
|
|
|
font-weight: bold;
|
|
|
|
`}
|
|
|
|
|
|
|
|
& img {
|
|
|
|
max-width: 100%;
|
|
|
|
max-height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
& p {
|
|
|
|
line-height: 1rlh;
|
|
|
|
margin: 0;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
|
|
|
|
|
|
|
& code {
|
|
|
|
line-height: 1rlh;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
2024-10-04 03:24:25 +08:00
|
|
|
`;
|
2024-10-03 06:28:02 +08:00
|
|
|
|
2024-10-17 03:10:27 +08:00
|
|
|
const CloseBtn = styled(EmojiButton)`
|
|
|
|
font-size: 75%;
|
|
|
|
height: 1rem;
|
|
|
|
padding: 0;
|
2024-10-03 06:28:02 +08:00
|
|
|
`;
|
|
|
|
|
|
|
|
export default {
|
|
|
|
Container,
|
|
|
|
CloseBtn,
|
|
|
|
Message,
|
2024-10-18 09:11:47 +08:00
|
|
|
Markdown,
|
2024-10-03 06:28:02 +08:00
|
|
|
};
|