Newer
Older
import { Text } from "preact-i18n";
import styled, { css } from "styled-components";
import { MessageObject } from "../../../context/revoltjs/util";
export interface BaseMessageProps {
head?: boolean,
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
mention?: boolean,
blocked?: boolean,
sending?: boolean,
contrast?: boolean
}
export default styled.div<BaseMessageProps>`
display: flex;
overflow-x: none;
padding: .125rem;
flex-direction: row;
padding-right: 16px;
${ props => props.contrast && css`
padding: .3rem;
border-radius: 4px;
background: var(--hover);
` }
${ props => props.head && css`
margin-top: 12px;
` }
${ props => props.mention && css`
background: var(--mention);
` }
${ props => props.blocked && css`
filter: blur(4px);
transition: 0.2s ease filter;
&:hover {
filter: none;
}
` }
${ props => props.sending && css`
opacity: 0.8;
color: var(--tertiary-foreground);
` }
gap: 8px;
display: flex;
align-items: center;
}
&:hover {
text-decoration: underline;
}
}
}
&:hover {
background: var(--hover);
time {
opacity: 1;
}
}
`;
export const MessageInfo = styled.div`
width: 62px;
display: flex;
flex-shrink: 0;
padding-top: 2px;
flex-direction: row;
justify-content: center;
.copyBracket {
opacity: 0;
position: absolute;
}
.copyTime {
opacity: 0;
position: absolute;
&:active {
transform: translateY(1px);
}
cursor: default;
display: inline;
font-size: 10px;
color: var(--tertiary-foreground);
}
time, .edited > div {
&::selection {
background-color: transparent;
color: var(--tertiary-foreground);
}
}
`;
export const MessageContent = styled.div`
min-width: 0;
flex-grow: 1;
display: flex;
overflow: hidden;
flex-direction: column;
justify-content: center;
`;
export const DetailBase = styled.div`
gap: 4px;
font-size: 10px;
display: inline-flex;
color: var(--tertiary-foreground);
`;
export function MessageDetail({ message, position }: { message: MessageObject, position: 'left' | 'top' }) {
if (position === 'left') {
if (message.edited) {
return (
<time className="copyTime">
<i className="copyBracket">[</i>
{dayjs(decodeTime(message._id)).format("H:mm")}
<i className="copyBracket">]</i>
</time>
<span className="edited">
<Tooltip content={dayjs(message.edited).format("LLLL")}>
<Text id="app.main.channel.edited" />
</Tooltip>
</span>
</>
)
} else {
return (
<>
<time>
{ dayjs(decodeTime(message._id)).format("H:mm") }
{ message.edited && <Tooltip content={dayjs(message.edited).format("LLLL")}>
<Text id="app.main.channel.edited" />
</Tooltip> }
</DetailBase>