mirror of
https://github.com/spacebarchat/client.git
synced 2024-11-25 19:52:31 +01:00
togglable member list
This commit is contained in:
parent
ae273f8515
commit
d98ce87c9e
@ -63,14 +63,16 @@ function ChatContent({ channel, guild }: Props2) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Content(props: Props2) {
|
const Content = observer((props: Props2) => {
|
||||||
|
const { memberListVisible } = useAppStore();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WrapperOne>
|
<WrapperOne>
|
||||||
<ChatContent {...props} />
|
<ChatContent {...props} />
|
||||||
<MemberList />
|
{memberListVisible && <MemberList />}
|
||||||
</WrapperOne>
|
</WrapperOne>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main component for rendering channel messages
|
* Main component for rendering channel messages
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import * as Icons from "@mdi/js";
|
import * as Icons from "@mdi/js";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import useLogger from "../../hooks/useLogger";
|
import useLogger from "../../hooks/useLogger";
|
||||||
|
import { useAppStore } from "../../stores/AppStore";
|
||||||
import Channel from "../../stores/objects/Channel";
|
import Channel from "../../stores/objects/Channel";
|
||||||
import Icon from "../Icon";
|
import Icon from "../Icon";
|
||||||
import { SectionHeader } from "../SectionHeader";
|
import { SectionHeader } from "../SectionHeader";
|
||||||
@ -111,19 +113,16 @@ interface ActionItemProps {
|
|||||||
active?: boolean;
|
active?: boolean;
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
tooltip: string;
|
tooltip: string;
|
||||||
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ActionItem({ icon, active, ariaLabel, tooltip }: ActionItemProps) {
|
function ActionItem({ icon, active, ariaLabel, tooltip, onClick }: ActionItemProps) {
|
||||||
const logger = useLogger("ChatHeader.tsx:ActionItem");
|
const logger = useLogger("ChatHeader.tsx:ActionItem");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip title={tooltip}>
|
<Tooltip title={tooltip}>
|
||||||
<IconWrapper>
|
<IconWrapper>
|
||||||
<IconButton
|
<IconButton onClick={onClick}>
|
||||||
onClick={() => {
|
|
||||||
logger.debug("click");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CustomIcon $active={active} icon={icon} size="24px" aria-label={ariaLabel} />
|
<CustomIcon $active={active} icon={icon} size="24px" aria-label={ariaLabel} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</IconWrapper>
|
</IconWrapper>
|
||||||
@ -135,6 +134,8 @@ function ActionItem({ icon, active, ariaLabel, tooltip }: ActionItemProps) {
|
|||||||
* Top header for channel messages section
|
* Top header for channel messages section
|
||||||
*/
|
*/
|
||||||
function ChatHeader({ channel }: Props) {
|
function ChatHeader({ channel }: Props) {
|
||||||
|
const { memberListVisible, toggleMemberList } = useAppStore();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
@ -152,7 +153,8 @@ function ChatHeader({ channel }: Props) {
|
|||||||
icon="mdiAccountMultiple"
|
icon="mdiAccountMultiple"
|
||||||
tooltip="Toggle Member List"
|
tooltip="Toggle Member List"
|
||||||
ariaLabel="Toggle Member List"
|
ariaLabel="Toggle Member List"
|
||||||
active
|
active={memberListVisible}
|
||||||
|
onClick={toggleMemberList}
|
||||||
/>
|
/>
|
||||||
<ActionItem icon="mdiPin" tooltip="Pinned Messages" ariaLabel="Pinned Messages" />
|
<ActionItem icon="mdiPin" tooltip="Pinned Messages" ariaLabel="Pinned Messages" />
|
||||||
<ActionItem icon="mdiBellBadge" tooltip="Notification Settings" ariaLabel="Notification Settings" />
|
<ActionItem icon="mdiBellBadge" tooltip="Notification Settings" ariaLabel="Notification Settings" />
|
||||||
@ -162,4 +164,4 @@ function ChatHeader({ channel }: Props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ChatHeader;
|
export default observer(ChatHeader);
|
||||||
|
@ -50,10 +50,14 @@ export default class AppStore {
|
|||||||
@observable activeGuildId: Snowflake | undefined | "@me" = "@me";
|
@observable activeGuildId: Snowflake | undefined | "@me" = "@me";
|
||||||
@observable activeChannel: Channel | null = null;
|
@observable activeChannel: Channel | null = null;
|
||||||
@observable activeChannelId: string | undefined = undefined;
|
@observable activeChannelId: string | undefined = undefined;
|
||||||
|
@observable memberListVisible: boolean = true;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
|
|
||||||
|
// bind this in toggleMemberList
|
||||||
|
this.toggleMemberList = this.toggleMemberList.bind(this);
|
||||||
|
|
||||||
window.addEventListener("online", () => this.setNetworkConnected(true));
|
window.addEventListener("online", () => this.setNetworkConnected(true));
|
||||||
window.addEventListener("offline", () => this.setNetworkConnected(false));
|
window.addEventListener("offline", () => this.setNetworkConnected(false));
|
||||||
}
|
}
|
||||||
@ -138,6 +142,11 @@ export default class AppStore {
|
|||||||
setFpsShown(value: boolean) {
|
setFpsShown(value: boolean) {
|
||||||
this.fpsShown = value;
|
this.fpsShown = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
toggleMemberList() {
|
||||||
|
this.memberListVisible = !this.memberListVisible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const appStore = new AppStore();
|
export const appStore = new AppStore();
|
||||||
|
Loading…
Reference in New Issue
Block a user