mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-27 07:52:11 -05:00
Handlers for UserShort.
View user's profile picture. Close #25, adds logic to hamburger.
This commit is contained in:
parent
c8b5753211
commit
f19e334d56
8 changed files with 74 additions and 14 deletions
|
@ -4,6 +4,7 @@ import { User } from "revolt.js/dist/maps/Users";
|
||||||
|
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
|
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
||||||
import { useClient } from "../../../context/revoltjs/RevoltClient";
|
import { useClient } from "../../../context/revoltjs/RevoltClient";
|
||||||
|
|
||||||
import UserIcon from "./UserIcon";
|
import UserIcon from "./UserIcon";
|
||||||
|
@ -67,14 +68,23 @@ export default function UserShort({
|
||||||
size?: number;
|
size?: number;
|
||||||
showServerIdentity?: boolean;
|
showServerIdentity?: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const { openScreen } = useIntermediate();
|
||||||
|
const openProfile = () =>
|
||||||
|
user && openScreen({ id: "profile", user_id: user._id });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UserIcon
|
<UserIcon
|
||||||
size={size ?? 24}
|
size={size ?? 24}
|
||||||
target={user}
|
target={user}
|
||||||
|
onClick={openProfile}
|
||||||
showServerIdentity={showServerIdentity}
|
showServerIdentity={showServerIdentity}
|
||||||
/>
|
/>
|
||||||
<Username user={user} showServerIdentity={showServerIdentity} />
|
<Username
|
||||||
|
user={user}
|
||||||
|
showServerIdentity={showServerIdentity}
|
||||||
|
onClick={openProfile}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
12
src/components/navigation/right/Search.tsx
Normal file
12
src/components/navigation/right/Search.tsx
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/*export const SearchSidebar = observer(
|
||||||
|
({ channel }: { channel: Channel }) => {
|
||||||
|
const keys = [...channel.recipient_ids!];
|
||||||
|
const entries = useEntries(channel, keys);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<GenericSidebarBase>
|
||||||
|
<MemberList entries={entries} context={channel} />
|
||||||
|
</GenericSidebarBase>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);*/
|
|
@ -1,5 +1,8 @@
|
||||||
|
import { Menu } from "@styled-icons/boxicons-regular";
|
||||||
import styled, { css } from "styled-components";
|
import styled, { css } from "styled-components";
|
||||||
|
|
||||||
|
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
borders?: boolean;
|
borders?: boolean;
|
||||||
background?: boolean;
|
background?: boolean;
|
||||||
|
@ -60,3 +63,19 @@ export default styled.div<Props>`
|
||||||
border-start-start-radius: 8px;
|
border-start-start-radius: 8px;
|
||||||
`}
|
`}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export function HamburgerAction() {
|
||||||
|
if (!isTouchscreenDevice) return null;
|
||||||
|
|
||||||
|
function openSidebar() {
|
||||||
|
document
|
||||||
|
.querySelector("#app > div > div")
|
||||||
|
?.scrollTo({ behavior: "smooth", left: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="menu" onClick={openSidebar}>
|
||||||
|
<Menu size={27} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -130,7 +130,20 @@ export const UserProfile = observer(
|
||||||
`linear-gradient( rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7) ), url('${backgroundURL}')`,
|
`linear-gradient( rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7) ), url('${backgroundURL}')`,
|
||||||
}}>
|
}}>
|
||||||
<div className={styles.profile}>
|
<div className={styles.profile}>
|
||||||
<UserIcon size={80} target={user} status animate />
|
<UserIcon
|
||||||
|
size={80}
|
||||||
|
target={user}
|
||||||
|
status
|
||||||
|
animate
|
||||||
|
hover={typeof user.avatar !== "undefined"}
|
||||||
|
onClick={() =>
|
||||||
|
user.avatar &&
|
||||||
|
openScreen({
|
||||||
|
id: "image_viewer",
|
||||||
|
attachment: user.avatar,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
<div className={styles.details}>
|
<div className={styles.details}>
|
||||||
<Localizer>
|
<Localizer>
|
||||||
<span
|
<span
|
||||||
|
|
|
@ -79,7 +79,6 @@ export function grabFiles(
|
||||||
const files = (e.currentTarget as HTMLInputElement)?.files;
|
const files = (e.currentTarget as HTMLInputElement)?.files;
|
||||||
if (!files) return;
|
if (!files) return;
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
alert(file.size);
|
|
||||||
if (file.size > maxFileSize) {
|
if (file.size > maxFileSize) {
|
||||||
return tooLarge();
|
return tooLarge();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import MessageBox from "../../components/common/messaging/MessageBox";
|
||||||
import JumpToBottom from "../../components/common/messaging/bars/JumpToBottom";
|
import JumpToBottom from "../../components/common/messaging/bars/JumpToBottom";
|
||||||
import TypingIndicator from "../../components/common/messaging/bars/TypingIndicator";
|
import TypingIndicator from "../../components/common/messaging/bars/TypingIndicator";
|
||||||
|
|
||||||
import MemberSidebar from "../../components/navigation/right/MemberSidebar";
|
import RightSidebar from "../../components/navigation/RightSidebar";
|
||||||
import ChannelHeader from "./ChannelHeader";
|
import ChannelHeader from "./ChannelHeader";
|
||||||
import { MessageArea } from "./messaging/MessageArea";
|
import { MessageArea } from "./messaging/MessageArea";
|
||||||
import VoiceHeader from "./voice/VoiceHeader";
|
import VoiceHeader from "./voice/VoiceHeader";
|
||||||
|
@ -93,9 +93,7 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
|
||||||
<JumpToBottom channel={channel} />
|
<JumpToBottom channel={channel} />
|
||||||
<MessageBox channel={channel} />
|
<MessageBox channel={channel} />
|
||||||
</ChannelContent>
|
</ChannelContent>
|
||||||
{!isTouchscreenDevice && showMembers && (
|
{!isTouchscreenDevice && showMembers && <RightSidebar />}
|
||||||
<MemberSidebar channel={channel} />
|
|
||||||
)}
|
|
||||||
</ChannelMain>
|
</ChannelMain>
|
||||||
</AgeGate>
|
</AgeGate>
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { getChannelName } from "../../context/revoltjs/util";
|
||||||
|
|
||||||
import { useStatusColour } from "../../components/common/user/UserIcon";
|
import { useStatusColour } from "../../components/common/user/UserIcon";
|
||||||
import UserStatus from "../../components/common/user/UserStatus";
|
import UserStatus from "../../components/common/user/UserStatus";
|
||||||
import Header from "../../components/ui/Header";
|
import Header, { HamburgerAction } from "../../components/ui/Header";
|
||||||
|
|
||||||
import Markdown from "../../components/markdown/Markdown";
|
import Markdown from "../../components/markdown/Markdown";
|
||||||
import HeaderActions from "./actions/HeaderActions";
|
import HeaderActions from "./actions/HeaderActions";
|
||||||
|
@ -87,11 +87,7 @@ export default observer(({ channel, toggleSidebar }: ChannelHeaderProps) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Header placement="primary">
|
<Header placement="primary">
|
||||||
{isTouchscreenDevice && (
|
<HamburgerAction />
|
||||||
<div className="menu">
|
|
||||||
<Menu size={27} />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{icon}
|
{icon}
|
||||||
<Info>
|
<Info>
|
||||||
<span className="name">{name}</span>
|
<span className="name">{name}</span>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
} from "@styled-icons/boxicons-solid";
|
} from "@styled-icons/boxicons-solid";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
|
||||||
|
import { isTouchscreenDevice } from "../../../lib/isTouchscreenDevice";
|
||||||
import { voiceState, VoiceStatus } from "../../../lib/vortex/VoiceState";
|
import { voiceState, VoiceStatus } from "../../../lib/vortex/VoiceState";
|
||||||
|
|
||||||
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
||||||
|
@ -24,6 +25,18 @@ export default function HeaderActions({
|
||||||
const { openScreen } = useIntermediate();
|
const { openScreen } = useIntermediate();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
function openSidebar() {
|
||||||
|
if (isTouchscreenDevice) {
|
||||||
|
const panels = document.querySelector("#app > div > div");
|
||||||
|
panels?.scrollTo({
|
||||||
|
behavior: "smooth",
|
||||||
|
left: panels.clientWidth * 3,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
toggleSidebar?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<UpdateIndicator style="channel" />
|
<UpdateIndicator style="channel" />
|
||||||
|
@ -54,7 +67,7 @@ export default function HeaderActions({
|
||||||
<VoiceActions channel={channel} />
|
<VoiceActions channel={channel} />
|
||||||
{(channel.channel_type === "Group" ||
|
{(channel.channel_type === "Group" ||
|
||||||
channel.channel_type === "TextChannel") && (
|
channel.channel_type === "TextChannel") && (
|
||||||
<IconButton onClick={toggleSidebar}>
|
<IconButton onClick={openSidebar}>
|
||||||
<Group size={25} />
|
<Group size={25} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in a new issue