mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
Add the ability to hide the channel sidebar
(the left one)
This commit is contained in:
@@ -49,10 +49,14 @@ export function Channel({ id }: { id: string }) {
|
||||
}
|
||||
|
||||
const MEMBERS_SIDEBAR_KEY = "sidebar_members";
|
||||
const CHANNELS_SIDEBAR_KEY = "sidebar_channels";
|
||||
const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
|
||||
const [showMembers, setMembers] = useState(
|
||||
getState().sectionToggle[MEMBERS_SIDEBAR_KEY] ?? true,
|
||||
);
|
||||
const [showChannels, setChannels] = useState(
|
||||
getState().sectionToggle[CHANNELS_SIDEBAR_KEY] ?? true,
|
||||
);
|
||||
|
||||
const id = channel._id;
|
||||
return (
|
||||
@@ -84,6 +88,22 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
|
||||
});
|
||||
}
|
||||
}}
|
||||
toggleChannelSidebar={() => {
|
||||
setChannels(!showChannels);
|
||||
|
||||
if (showChannels) {
|
||||
dispatch({
|
||||
type: "SECTION_TOGGLE_SET",
|
||||
id: CHANNELS_SIDEBAR_KEY,
|
||||
state: false,
|
||||
});
|
||||
} else {
|
||||
dispatch({
|
||||
type: "SECTION_TOGGLE_UNSET",
|
||||
id: CHANNELS_SIDEBAR_KEY,
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ChannelMain>
|
||||
<ChannelContent>
|
||||
|
||||
@@ -20,6 +20,7 @@ import HeaderActions from "./actions/HeaderActions";
|
||||
export interface ChannelHeaderProps {
|
||||
channel: Channel;
|
||||
toggleSidebar?: () => void;
|
||||
toggleChannelSidebar?: () => void;
|
||||
}
|
||||
|
||||
const Info = styled.div`
|
||||
@@ -64,7 +65,16 @@ const Info = styled.div`
|
||||
}
|
||||
`;
|
||||
|
||||
export default observer(({ channel, toggleSidebar }: ChannelHeaderProps) => {
|
||||
const IconConainer = styled.div`
|
||||
cursor: pointer;
|
||||
color: var(--secondary-foreground);
|
||||
|
||||
&:hover {
|
||||
color: var(--foreground);
|
||||
}
|
||||
`
|
||||
|
||||
export default observer(({ channel, toggleSidebar, toggleChannelSidebar }: ChannelHeaderProps) => {
|
||||
const { openScreen } = useIntermediate();
|
||||
|
||||
const name = getChannelName(channel);
|
||||
@@ -88,7 +98,7 @@ export default observer(({ channel, toggleSidebar }: ChannelHeaderProps) => {
|
||||
return (
|
||||
<Header placement="primary">
|
||||
<HamburgerAction />
|
||||
{icon}
|
||||
<IconConainer onClick={toggleChannelSidebar}>{icon}</IconConainer>
|
||||
<Info>
|
||||
<span className="name">{name}</span>
|
||||
{isTouchscreenDevice &&
|
||||
|
||||
Reference in New Issue
Block a user