mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-22 23:20:58 -05:00
Add system message icons. Closes #10
This commit is contained in:
parent
25615cc16d
commit
34e8d54512
2 changed files with 39 additions and 0 deletions
|
@ -124,6 +124,10 @@ export default styled.div<BaseMessageProps>`
|
||||||
time {
|
time {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.system-message-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
import {
|
||||||
|
InfoCircle,
|
||||||
|
UserPlus,
|
||||||
|
UserMinus,
|
||||||
|
ArrowToRight,
|
||||||
|
ArrowToLeft,
|
||||||
|
UserX,
|
||||||
|
ShieldX,
|
||||||
|
EditAlt,
|
||||||
|
Edit,
|
||||||
|
MessageSquareEdit,
|
||||||
|
} from "@styled-icons/boxicons-solid";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { Message } from "revolt.js/dist/maps/Messages";
|
import { Message } from "revolt.js/dist/maps/Messages";
|
||||||
import { User } from "revolt.js/dist/maps/Users";
|
import { User } from "revolt.js/dist/maps/Users";
|
||||||
|
@ -40,6 +52,19 @@ interface Props {
|
||||||
hideInfo?: boolean;
|
hideInfo?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const iconDictionary = {
|
||||||
|
user_added: UserPlus,
|
||||||
|
user_remove: UserMinus,
|
||||||
|
user_joined: ArrowToRight,
|
||||||
|
user_left: ArrowToLeft,
|
||||||
|
user_kicked: UserX,
|
||||||
|
user_banned: ShieldX,
|
||||||
|
channel_renamed: EditAlt,
|
||||||
|
channel_description_changed: Edit,
|
||||||
|
channel_icon_changed: MessageSquareEdit,
|
||||||
|
text: InfoCircle,
|
||||||
|
};
|
||||||
|
|
||||||
export const SystemMessage = observer(
|
export const SystemMessage = observer(
|
||||||
({ attachContext, message, highlight, hideInfo }: Props) => {
|
({ attachContext, message, highlight, hideInfo }: Props) => {
|
||||||
const client = useClient();
|
const client = useClient();
|
||||||
|
@ -89,6 +114,15 @@ export const SystemMessage = observer(
|
||||||
data = { type: "text", content };
|
data = { type: "text", content };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SystemMessageIcon = iconDictionary[data.type] ?? InfoCircle;
|
||||||
|
|
||||||
|
const SystemIcon = styled(SystemMessageIcon)`
|
||||||
|
height: 1.33em;
|
||||||
|
width: 1.33em;
|
||||||
|
margin-right: 0.5em;
|
||||||
|
color: var(--tertiary-foreground);
|
||||||
|
`;
|
||||||
|
|
||||||
let children;
|
let children;
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "text":
|
case "text":
|
||||||
|
@ -161,6 +195,7 @@ export const SystemMessage = observer(
|
||||||
{!hideInfo && (
|
{!hideInfo && (
|
||||||
<MessageInfo>
|
<MessageInfo>
|
||||||
<MessageDetail message={message} position="left" />
|
<MessageDetail message={message} position="left" />
|
||||||
|
<SystemIcon className="system-message-icon" />
|
||||||
</MessageInfo>
|
</MessageInfo>
|
||||||
)}
|
)}
|
||||||
<SystemContent>{children}</SystemContent>
|
<SystemContent>{children}</SystemContent>
|
||||||
|
|
Loading…
Reference in a new issue