mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Added background to own messages in chat and the rounded border.
Closes #1985
This commit is contained in:
parent
5e4334ac01
commit
d93922f1d0
@ -1,10 +1,9 @@
|
|||||||
.root {
|
.root {
|
||||||
|
position: relative;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
padding-left: 1rem;
|
padding-left: 1rem;
|
||||||
margin: 8px 5px;
|
margin: 8px 5px;
|
||||||
border-left: 2px solid;
|
|
||||||
border-radius: 0.3rem;
|
|
||||||
.user {
|
.user {
|
||||||
font: var(--theme-header-font-family);
|
font: var(--theme-header-font-family);
|
||||||
color: var(--color-owncast-grey-100);
|
color: var(--color-owncast-grey-100);
|
||||||
@ -28,10 +27,32 @@
|
|||||||
box-decoration-break: clone;
|
box-decoration-break: clone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
.customBorder {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
width: 5px;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
&:after {
|
||||||
|
content: '';
|
||||||
|
width: 10px;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0%;
|
||||||
|
right: 0px;
|
||||||
|
background-color: currentColor;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.ownMessage {
|
||||||
.ownMessage {
|
.customBorder {
|
||||||
border-left: 0px;
|
left: auto;
|
||||||
border-right: 2px solid;
|
right: 0px;
|
||||||
|
&:after {
|
||||||
|
left: 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,18 @@ export default function ChatUserMessage({
|
|||||||
showModeratorMenu,
|
showModeratorMenu,
|
||||||
renderAsPersonallySent, // Move the border to the right and render a background
|
renderAsPersonallySent, // Move the border to the right and render a background
|
||||||
}: Props) {
|
}: Props) {
|
||||||
|
const [bgColor, setBgColor] = useState<string>();
|
||||||
const { body, user, timestamp } = message;
|
const { body, user, timestamp } = message;
|
||||||
const { displayName, displayColor } = user;
|
const { displayName, displayColor } = user;
|
||||||
|
|
||||||
const color = `var(--theme-user-colors-${displayColor})`;
|
const color = `var(--theme-user-colors-${displayColor})`;
|
||||||
// TODO: Need to convert the above color to a background color.
|
|
||||||
const bgColor = `hsl(100, 20%, 25%)`;
|
|
||||||
const formattedTimestamp = `Sent at ${formatTimestamp(timestamp)}`;
|
const formattedTimestamp = `Sent at ${formatTimestamp(timestamp)}`;
|
||||||
const [formattedMessage, setFormattedMessage] = useState<string>(body);
|
const [formattedMessage, setFormattedMessage] = useState<string>(body);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (renderAsPersonallySent) setBgColor(getBgColor(displayColor));
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFormattedMessage(he.decode(body));
|
setFormattedMessage(he.decode(body));
|
||||||
}, [message]);
|
}, [message]);
|
||||||
@ -37,6 +41,7 @@ export default function ChatUserMessage({
|
|||||||
className={cn(s.root, {
|
className={cn(s.root, {
|
||||||
[s.ownMessage]: renderAsPersonallySent,
|
[s.ownMessage]: renderAsPersonallySent,
|
||||||
})}
|
})}
|
||||||
|
data-display-color={displayColor}
|
||||||
style={{ borderColor: color, backgroundColor: bgColor }}
|
style={{ borderColor: color, backgroundColor: bgColor }}
|
||||||
title={formattedTimestamp}
|
title={formattedTimestamp}
|
||||||
>
|
>
|
||||||
@ -47,6 +52,14 @@ export default function ChatUserMessage({
|
|||||||
<div className={s.message}>{formattedMessage}</div>
|
<div className={s.message}>{formattedMessage}</div>
|
||||||
</Highlight>
|
</Highlight>
|
||||||
{showModeratorMenu && <div>Moderator menu</div>}
|
{showModeratorMenu && <div>Moderator menu</div>}
|
||||||
|
<div className={s.customBorder} style={{ color }} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBgColor(displayColor: number, alpha = 13) {
|
||||||
|
const root = document.querySelector(':root');
|
||||||
|
const css = getComputedStyle(root);
|
||||||
|
const hexColor = css.getPropertyValue(`--theme-user-colors-${displayColor}`);
|
||||||
|
return hexColor.concat(alpha.toString());
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user