import { MicrophoneOff } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; import { Users } from "revolt.js/dist/api/objects"; import styled, { css } from "styled-components"; import { useContext } from "preact/hooks"; import { ThemeContext } from "../../../context/Theme"; import { AppContext } from "../../../context/revoltjs/RevoltClient"; import { User } from "../../../mobx"; import IconBase, { IconBaseProps } from "../IconBase"; import fallback from "../assets/user.png"; type VoiceStatus = "muted"; interface Props extends IconBaseProps { mask?: string; status?: boolean; voice?: VoiceStatus; } export function useStatusColour(user?: User) { const theme = useContext(ThemeContext); return user?.online && user?.status?.presence !== Users.Presence.Invisible ? user?.status?.presence === Users.Presence.Idle ? theme["status-away"] : user?.status?.presence === Users.Presence.Busy ? theme["status-busy"] : theme["status-online"] : theme["status-invisible"]; } const VoiceIndicator = styled.div<{ status: VoiceStatus }>` width: 10px; height: 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; svg { stroke: white; } ${(props) => props.status === "muted" && css` background: var(--error); `} `; export default observer( (props: Props & Omit, keyof Props>) => { const client = useContext(AppContext); const { target, attachment, size, voice, status, animate, mask, children, as, ...svgProps } = props; const iconURL = client.generateFileURL( target?.avatar ?? attachment, { max_side: 256 }, animate, ) ?? (target ? client.users.getDefaultAvatarURL(target._id) : fallback); return ( ); }, );