forked from abner/for-legacy-web
Server Sidebar: Add home icon hover.
Home Sidebar: Remove top bar.
This commit is contained in:
41
src/components/common/user/UserHover.tsx
Normal file
41
src/components/common/user/UserHover.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Children } from "../../../types/Preact";
|
||||
import { Username } from "./UserShort";
|
||||
import styled from "styled-components";
|
||||
import UserStatus from "./UserStatus";
|
||||
import Tooltip from "../Tooltip";
|
||||
import { User } from "revolt.js";
|
||||
|
||||
interface Props {
|
||||
user?: User,
|
||||
children: Children
|
||||
}
|
||||
|
||||
const Base = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.username {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.status {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
`;
|
||||
|
||||
export default function UserHover({ user, children }: Props) {
|
||||
return (
|
||||
<Tooltip placement="right-end" content={
|
||||
<Base>
|
||||
<Username className="username" user={user} />
|
||||
<span className="status">
|
||||
<UserStatus user={user} />
|
||||
</span>
|
||||
</Base>
|
||||
}>
|
||||
{ children }
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
@@ -5,12 +5,12 @@ import { Text } from "preact-i18n";
|
||||
import Tooltip from "../Tooltip";
|
||||
|
||||
interface Props {
|
||||
user: User;
|
||||
user?: User;
|
||||
tooltip?: boolean;
|
||||
}
|
||||
|
||||
export default function UserStatus({ user, tooltip }: Props) {
|
||||
if (user.online) {
|
||||
if (user?.online) {
|
||||
if (user.status?.text) {
|
||||
if (tooltip) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user