diff --git a/src/components/MemberList/MemberListItem.tsx b/src/components/MemberList/MemberListItem.tsx
index 7a82703..2e371fe 100644
--- a/src/components/MemberList/MemberListItem.tsx
+++ b/src/components/MemberList/MemberListItem.tsx
@@ -1,9 +1,23 @@
+import {
+ FloatingPortal,
+ flip,
+ offset,
+ shift,
+ useClick,
+ useDismiss,
+ useFloating,
+ useInteractions,
+ useRole,
+} from "@floating-ui/react";
import { PresenceUpdateStatus } from "@spacebarchat/spacebar-api-types/v9";
+import { motion } from "framer-motion";
+import { useState } from "react";
import styled from "styled-components";
-import useFloating from "../../hooks/useFloating";
import { useAppStore } from "../../stores/AppStore";
import GuildMember from "../../stores/objects/GuildMember";
+import User from "../../stores/objects/User";
import Avatar from "../Avatar";
+import UserProfilePopout from "../floating/UserProfilePopout";
const ListItem = styled.div<{ isCategory?: boolean }>`
padding: ${(props) => (props.isCategory ? "16px 8px 0 0" : "1px 8px 0 0")};
@@ -62,28 +76,55 @@ function MemberListItem({ item }: Props) {
const app = useAppStore();
const presence = app.presences.get(item.guild.id)?.get(item.user!.id);
- const { refs, getReferenceProps } = useFloating({
- placement: "left-start",
- type: "userPopout",
- config: {
- user: item.user!,
- member: item,
- },
+ const [open, setOpen] = useState(false);
+
+ const floating = useFloating({
+ placement: "right-start",
+ open,
+ onOpenChange: setOpen,
+ // whileElementsMounted: autoUpdate,
+ middleware: [offset(5), flip(), shift()],
});
+ const click = useClick(floating.context);
+ const dismiss = useDismiss(floating.context);
+ const role = useRole(floating.context);
+ const interactions = useInteractions([click, dismiss, role]);
+
return (
-
-
-
-
-
-
-
- {item.nick ?? item.user?.username}
-
-
-
-
+ <>
+
+
+
+
+
+
+
+ {item.nick ?? item.user?.username}
+
+
+
+
+
+ {open && (
+
+
+
+
+
+
+
+ )}
+ >
);
}
diff --git a/src/components/UserPanel.tsx b/src/components/UserPanel.tsx
index 4be53ad..f89296e 100644
--- a/src/components/UserPanel.tsx
+++ b/src/components/UserPanel.tsx
@@ -1,11 +1,24 @@
+import {
+ FloatingPortal,
+ flip,
+ offset,
+ shift,
+ useClick,
+ useDismiss,
+ useFloating,
+ useInteractions,
+ useRole,
+} from "@floating-ui/react";
+import { motion } from "framer-motion";
+import { useState } from "react";
import styled from "styled-components";
-import useFloating from "../hooks/useFloating";
import { useAppStore } from "../stores/AppStore";
import User from "../stores/objects/User";
import Avatar from "./Avatar";
import Icon from "./Icon";
import IconButton from "./IconButton";
import Tooltip from "./Tooltip";
+import UserProfilePopout from "./floating/UserProfilePopout";
const Section = styled.section`
flex: 0 0 auto;
@@ -69,37 +82,64 @@ const ActionsWrapper = styled.div`
function UserPanel() {
const app = useAppStore();
+ const [open, setOpen] = useState(false);
- const { refs, getReferenceProps } = useFloating({
- placement: "right-start",
- type: "userPopout",
- config: {
- user: app.account as unknown as User,
- },
+ const floating = useFloating({
+ placement: "bottom",
+ open,
+ onOpenChange: setOpen,
+ // whileElementsMounted: autoUpdate,
+ middleware: [offset(5), flip(), shift()],
});
+ const click = useClick(floating.context);
+ const dismiss = useDismiss(floating.context);
+ const role = useRole(floating.context);
+ const interactions = useInteractions([click, dismiss, role]);
+
const openSettingsModal = () => {};
return (
-
-
-
-
-
- {app.account?.username}
- #{app.account?.discriminator}
-
-
+ <>
+
+
+
+
+
+ {app.account?.username}
+ #{app.account?.discriminator}
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ {open && (
+
+
+
+
+
+
+
+ )}
+ >
);
}
diff --git a/src/controllers/modals/floating/FloatingRenderer.tsx b/src/controllers/modals/floating/FloatingRenderer.tsx
index 4b151bd..d8c2dbd 100644
--- a/src/controllers/modals/floating/FloatingRenderer.tsx
+++ b/src/controllers/modals/floating/FloatingRenderer.tsx
@@ -2,21 +2,8 @@ import { FloatingPortal } from "@floating-ui/react";
import { observer } from "mobx-react-lite";
import { floatingController } from "./FloatingController";
-export default observer(() => {
- // useEffect(() => {
- // function keyDown(event: KeyboardEvent) {
- // if (event.key === "Escape") {
- // modalController.pop("close");
- // } else if (event.key === "Enter") {
- // if (event.target instanceof HTMLSelectElement) return;
- // modalController.pop("confirm");
- // }
- // }
-
- // document.addEventListener("keydown", keyDown);
- // return () => document.removeEventListener("keydown", keyDown);
- // }, []);
- console.log(floatingController.elements);
-
+function FloatingRender() {
return {floatingController.rendered};
-});
+}
+
+export default observer(FloatingRender);