mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-24 22:52:09 -05:00
Server Sidebar: Add home icon hover.
Home Sidebar: Remove top bar.
This commit is contained in:
parent
f403875ae6
commit
54185b5839
9 changed files with 79 additions and 37 deletions
2
external/lang
vendored
2
external/lang
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 2054052c791ff2396dcbde68ae257fa13a93ab6c
|
Subproject commit de2b94c8d8615b732cbbec3679041e73fd3c7640
|
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";
|
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 (
|
||||||
|
|
|
@ -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 && (
|
||||||
|
|
|
@ -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")
|
||||||
}>
|
}>
|
||||||
<Icon size={42} unread={homeUnread}>
|
<UserHover user={self}>
|
||||||
<UserIcon target={self} size={32} status />
|
<Icon size={42} unread={homeUnread}>
|
||||||
</Icon>
|
<UserIcon target={self} size={32} status />
|
||||||
|
</Icon>
|
||||||
|
</UserHover>
|
||||||
</div>
|
</div>
|
||||||
<span />
|
<span />
|
||||||
</ServerEntry>
|
</ServerEntry>
|
||||||
|
|
|
@ -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>
|
||||||
|
@ -924,23 +931,21 @@ function ContextMenus(props: Props) {
|
||||||
<Text id={`app.status.invisible`} />
|
<Text id={`app.status.invisible`} />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<LineDivider />
|
<LineDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
data={{ action: "set_status" }}
|
data={{ action: "set_status" }}
|
||||||
disabled={!isOnline}>
|
disabled={!isOnline}>
|
||||||
<UserVoice size={18} />
|
<UserVoice size={18} />
|
||||||
<Text
|
<Text
|
||||||
id={`app.context_menu.custom_status`}
|
id={`app.context_menu.custom_status`}
|
||||||
/>
|
/>
|
||||||
{client.user!.status?.text && (
|
{client.user!.status?.text && (
|
||||||
<IconButton>
|
<IconButton>
|
||||||
<MenuItem data={{ action: "clear_status" }}>
|
<MenuItem data={{ action: "clear_status" }}>
|
||||||
<Trash size={18} />
|
<Trash size={18} />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</ContextMenuWithData>
|
</ContextMenuWithData>
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -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,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue