diff --git a/src/components/guilds/GuildSideSelect.tsx b/src/components/guilds/GuildSideSelect.tsx index 05cbba3..ea92ad8 100644 --- a/src/components/guilds/GuildSideSelect.tsx +++ b/src/components/guilds/GuildSideSelect.tsx @@ -1,123 +1,193 @@ -import {For, onMount, Show} from "solid-js"; -import {A} from "@solidjs/router"; +import { For, onMount, Show } from "solid-js"; +import { A, useNavigate } from "@solidjs/router"; -import {getApi} from "../../api/Api"; -import {Guild} from "../../types/guild"; -import GuildIcon, {UnreadIndicator} from "./GuildIcon"; +import { getApi } from "../../api/Api"; +import { Guild } from "../../types/guild"; +import GuildIcon, { UnreadIndicator } from "./GuildIcon"; import tooltip from "../../directives/tooltip"; -import {displayName, noop} from "../../utils"; -import Icon, {IconElement} from "../icons/Icon"; +import { displayName, noop } from "../../utils"; +import Icon, { IconElement } from "../icons/Icon"; import PlusIcon from "../icons/svg/Plus"; import HomeIcon from "../icons/svg/Home"; +import Trash from "../icons/svg/Trash"; +import Gear from "../icons/svg/Gear"; import useContextMenu from "../../hooks/useContextMenu"; -import ContextMenu, {ContextMenuButton, DangerContextMenuButton} from "../ui/ContextMenu"; +import ContextMenu, { + ContextMenuButton, + DangerContextMenuButton, +} from "../ui/ContextMenu"; import RightFromBracket from "../icons/svg/RightFromBracket"; import Code from "../icons/svg/Code"; -import {ModalId, useModal} from "../ui/Modal"; +import { ModalId, useModal } from "../ui/Modal"; import UserPlus from "../icons/svg/UserPlus"; -import {ModalPage, NewGuildModalContextMenu} from "./NewGuildModal"; -import {DmChannel} from "../../types/channel"; -import {Tab} from "../../App"; +import { ModalPage, NewGuildModalContextMenu } from "./NewGuildModal"; +import { DmChannel } from "../../types/channel"; +import { Tab } from "../../App"; -noop(tooltip) +noop(tooltip); -const Separator = () =>
+// TODO: Move UI elements into ../ui/ – for better reusability?? +const Separator = () => ( +
+); -function BasicButton({ icon, alt, href }: { icon: IconElement, alt: string, href: string }) { - let anchor: HTMLAnchorElement | null = null +function SidebarButton({ + icon, + alt, + href, +}: { + icon: IconElement; + alt: string; + href: string; +}) { + let anchor: HTMLAnchorElement | null = null; onMount(() => { - tooltip(anchor!, () => ({ content: alt, placement: 'right' })) - }) + tooltip(anchor!, () => ({ content: alt, placement: "right" })); + }); return ( - + - ) + ); } export function GuildContextMenu(props: { guild: Guild }) { - const api = getApi()! - const {showModal} = useModal() + const api = getApi()!; + const { showModal } = useModal(); + const navigate = useNavigate(); + const guildPermissions = () => + api.cache?.getClientPermissions(props.guild.id); return ( showModal(ModalId.CreateInvite, props.guild)} /> + + navigate(`/guilds/${props.guild.id}/settings`)} + /> + window.navigator.clipboard.writeText(props.guild.id.toString())} + onClick={() => + window.navigator.clipboard.writeText(props.guild.id.toString()) + } /> + + showModal(ModalId.LeaveGuild, props.guild)} /> + + showModal(ModalId.DeleteGuild, props.guild)} + /> + - ) + ); } export default function GuildSideSelect() { - const api = getApi()! - const cache = api.cache! - const [dmChannelOrder] = cache.dmChannelOrder + const api = getApi()!; + const cache = api.cache!; + const [dmChannelOrder] = cache.dmChannelOrder; - const contextMenu = useContextMenu()! - const {showModal} = useModal() + const contextMenu = useContextMenu()!; + const { showModal } = useModal(); return (
- +
{(channelId) => { - const user = cache.getDirectDmRecipient(cache.channels.get(channelId) as DmChannel) - if (!user) return null + const user = cache.getDirectDmRecipient( + cache.channels.get(channelId) as DmChannel, + ); + if (!user) return null; return ( - + + - - ) + ); }} - api.cache!.guilds.get(g)!))}> - {(guild: Guild) => guild && ( - - )}> - - + api.cache!.guilds.get(g)!), )} + > + {(guild: Guild) => + guild && ( + , + )} + > + + + ) + } 0} keyed={false}>
- ) -} \ No newline at end of file + ); +}