import { Plus } from "@styled-icons/boxicons-regular"; import { Cog, Compass } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Link, useHistory, useLocation, useParams } from "react-router-dom"; import { RelationshipStatus } from "revolt-api/types/Users"; import styled, { css } from "styled-components/macro"; import { Ref } from "preact"; import { refContextMenu } from "preact-context-menu"; import ConditionalLink from "../../../lib/ConditionalLink"; import PaintCounter from "../../../lib/PaintCounter"; import { isTouchscreenDevice } from "../../../lib/isTouchscreenDevice"; import { useApplicationState } from "../../../mobx/State"; import { SIDEBAR_CHANNELS } from "../../../mobx/stores/Layout"; import { useIntermediate } from "../../../context/intermediate/Intermediate"; import { useClient } from "../../../context/revoltjs/RevoltClient"; import ChannelIcon from "../../common/ChannelIcon"; import ServerIcon from "../../common/ServerIcon"; import Tooltip from "../../common/Tooltip"; import UserHover from "../../common/user/UserHover"; import UserIcon from "../../common/user/UserIcon"; import IconButton from "../../ui/IconButton"; import LineDivider from "../../ui/LineDivider"; import { Children } from "../../../types/Preact"; function Icon({ children, unread, count, size, }: { children: Children; unread?: "mention" | "unread"; count: number | 0; size: number; }) { return ( ); } const ServersBase = styled.div` width: 58px; height: 100%; padding-inline-start: 2px; display: flex; flex-shrink: 0; flex-direction: column; ${isTouchscreenDevice && css` padding-bottom: 50px; `} `; const ServerList = styled.div` flex-grow: 1; display: flex; overflow-y: scroll; padding-bottom: 20px; flex-direction: column; scrollbar-width: none; > :first-child > svg { margin: 6px 0 6px 4px; } &::-webkit-scrollbar { width: 0px; } `; const ServerEntry = styled.div<{ active: boolean; home?: boolean }>` height: 54px; display: flex; align-items: center; //transition: 0.2s ease height; :focus { outline: 3px solid blue; } > div { height: 42px; padding-inline-start: 6px; display: grid; place-items: center; border-start-start-radius: 50%; border-end-start-radius: 50%; &:active { transform: translateY(1px); } ${(props) => props.active && css` &:active { transform: none; } `} } > span { width: 0; display: relative; ${(props) => !props.active && css` display: none; `} svg { margin-top: 5px; pointer-events: none; } } ${(props) => (!props.active || props.home) && css` cursor: pointer; `} `; const ServerCircle = styled.div` width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; .circle { display: flex; align-items: center; justify-content: center; background-color: var(--primary-background); border-radius: 50%; height: 42px; width: 42px; transition: background-color 0.1s ease-in; cursor: pointer; > div svg { color: var(--accent); } &:active { transform: translateY(1px); } } `; const SettingsButton = styled.div` width: 50px; height: 56px; display: grid; place-items: center; `; function Swoosh() { const sidebarOpen = useApplicationState().layout.getSectionState( SIDEBAR_CHANNELS, true, ); const fill = sidebarOpen ? "var(--sidebar-active)" : "var(--primary-background)"; return ( ); } export default observer(() => { const client = useClient(); const state = useApplicationState(); const { server: server_id } = useParams<{ server?: string }>(); const server = server_id ? client.servers.get(server_id) : undefined; const servers = [...client.servers.values()]; const channels = [...client.channels.values()]; const history = useHistory(); const path = useLocation().pathname; const { openScreen } = useIntermediate(); let alertCount = [...client.users.values()].filter( (x) => x.relationship === RelationshipStatus.Incoming, ).length; const homeActive = typeof server === "undefined" && !path.startsWith("/invite") && !path.startsWith("/discover"); return (
} onClick={() => homeActive && history.push("/settings") }> 0 ? "mention" : undefined } count={alertCount}>
{channels .filter( (x) => (x.channel_type === "DirectMessage" || x.channel_type === "Group") && x.unread, ) .map((x) => { const unreadCount = x.mentions.length; return ( }>
0 ? "mention" : "unread" } count={unreadCount}> {x.channel_type === "DirectMessage" ? ( ) : ( )}
); })} {servers.map((server) => { const active = server._id === server_id; const isUnread = server.isUnread(state.notifications); const mentionCount = server.getMentions( state.notifications, ).length; return ( }> 0 ? "mention" : isUnread ? "unread" : undefined } count={mentionCount}> ); })} {/**/}
openScreen({ id: "special_input", type: "create_server", }) }>
{!isTouchscreenDevice && (
Discover Revolt
NEW
} placement="right">
)}
{!isTouchscreenDevice && (
)}
); });