This commit is contained in:
nizune 2021-07-09 23:44:26 +02:00
commit 70cba134e3
9 changed files with 79 additions and 37 deletions

2
external/lang vendored

@ -1 +1 @@
Subproject commit 2054052c791ff2396dcbde68ae257fa13a93ab6c Subproject commit de2b94c8d8615b732cbbec3679041e73fd3c7640

View 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>
)
}

View file

@ -5,12 +5,12 @@ import { Text } from "preact-i18n";
import Tooltip from "../Tooltip"; import Tooltip from "../Tooltip";
interface Props { interface Props {
user: User; user?: User;
tooltip?: boolean; tooltip?: boolean;
} }
export default function UserStatus({ user, tooltip }: Props) { export default function UserStatus({ user, tooltip }: Props) {
if (user.online) { if (user?.online) {
if (user.status?.text) { if (user.status?.text) {
if (tooltip) { if (tooltip) {
return ( return (

View file

@ -27,7 +27,6 @@ import {
useUsers, useUsers,
} from "../../../context/revoltjs/hooks"; } from "../../../context/revoltjs/hooks";
import UserHeader from "../../common/user/UserHeader";
import Category from "../../ui/Category"; import Category from "../../ui/Category";
import placeholderSVG from "../items/placeholder.svg"; import placeholderSVG from "../items/placeholder.svg";
import { mapChannelWithUnread, useUnreads } from "./common"; import { mapChannelWithUnread, useUnreads } from "./common";
@ -81,7 +80,6 @@ function HomeSidebar(props: Props) {
return ( return (
<GenericSidebarBase padding> <GenericSidebarBase padding>
<UserHeader user={client.user!} />
<ConnectionStatus /> <ConnectionStatus />
<GenericSidebarList> <GenericSidebarList>
{!isTouchscreenDevice && ( {!isTouchscreenDevice && (

View file

@ -29,6 +29,7 @@ import LineDivider from "../../ui/LineDivider";
import { mapChannelWithUnread } from "./common"; import { mapChannelWithUnread } from "./common";
import { Children } from "../../../types/Preact"; import { Children } from "../../../types/Preact";
import UserHover from "../../common/user/UserHover";
function Icon({ function Icon({
children, children,
@ -241,9 +242,11 @@ export function ServerListSidebar({ unreads, lastOpened }: Props) {
onClick={() => onClick={() =>
homeActive && openContextMenu("Status") homeActive && openContextMenu("Status")
}> }>
<UserHover user={self}>
<Icon size={42} unread={homeUnread}> <Icon size={42} unread={homeUnread}>
<UserIcon target={self} size={32} status /> <UserIcon target={self} size={32} status />
</Icon> </Icon>
</UserHover>
</div> </div>
<span /> <span />
</ServerEntry> </ServerEntry>

View file

@ -10,6 +10,7 @@ import {
LeftArrowAlt, LeftArrowAlt,
Trash, Trash,
} from "@styled-icons/boxicons-regular"; } from "@styled-icons/boxicons-regular";
import Tooltip from "../components/common/Tooltip";
import { Cog, UserVoice } from "@styled-icons/boxicons-solid"; import { Cog, UserVoice } from "@styled-icons/boxicons-solid";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import { import {
@ -875,8 +876,14 @@ function ContextMenus(props: Props) {
<> <>
<div className="header"> <div className="header">
<div className="main"> <div className="main">
<div>@{client.user!.username}</div> <div className="username"
<div className="status"> onClick={() => writeClipboard(client.user!.username)}>
<Tooltip content={<Text id="app.special.copy_username" />}>
@{client.user!.username}
</Tooltip>
</div>
<div className="status"
onClick={() => contextClick({ action: 'set_status' })}>
<UserStatus user={client.user!} /> <UserStatus user={client.user!} />
</div> </div>
</div> </div>
@ -939,8 +946,6 @@ function ContextMenus(props: Props) {
</IconButton> </IconButton>
)} )}
</MenuItem> </MenuItem>
</> </>
)} )}
</ContextMenuWithData> </ContextMenuWithData>

View file

@ -46,15 +46,3 @@ export type Action =
| NotificationsAction | NotificationsAction
| SectionToggleAction | SectionToggleAction
| { type: "__INIT"; state: State }; | { type: "__INIT"; state: State };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function filter(obj: any, keys: string[]) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const newObj: any = {};
for (const key of keys) {
const v = obj[key];
if (v) newObj[key] = v;
}
return newObj;
}

View file

@ -2,7 +2,6 @@ import type { Theme, ThemeOptions } from "../../context/Theme";
import { setEmojiPack } from "../../components/common/Emoji"; import { setEmojiPack } from "../../components/common/Emoji";
import { filter } from ".";
import type { Sounds } from "../../assets/sounds/Audio"; import type { Sounds } from "../../assets/sounds/Audio";
import type { SyncUpdateAction } from "./sync"; import type { SyncUpdateAction } from "./sync";
@ -67,7 +66,7 @@ export function settings(
return { return {
...state, ...state,
theme: { theme: {
...filter(state.theme, ["custom", "preset", "ligatures"]), ...state.theme,
...action.theme, ...action.theme,
}, },
}; };
@ -94,7 +93,7 @@ export function settings(
return { return {
...state, ...state,
appearance: { appearance: {
...filter(state.appearance, ["emojiPack"]), ...state.appearance,
...action.options, ...action.options,
}, },
}; };

View file

@ -1,5 +1,5 @@
.preact-context-menu .context-menu { .preact-context-menu .context-menu {
z-index: 10000; z-index: 5000;
min-width: 190px; min-width: 190px;
padding: 6px 8px; padding: 6px 8px;
user-select: none; user-select: none;
@ -48,9 +48,17 @@
flex-grow: 1; flex-grow: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.username {
> div {
cursor: pointer;
width: fit-content;
}
}
} }
.status { .status {
cursor: pointer;
max-width: 132px; max-width: 132px;
font-size: .625rem; font-size: .625rem;
color: var(--secondary-foreground); color: var(--secondary-foreground);