From c50ba5b2b47a7c3d929b67be09e6267bb5f4a1dd Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Sat, 12 Oct 2024 13:20:52 -0400 Subject: [PATCH 1/2] feat(contextmenu): adds context menu support to the ap i can now create a context menu for anything --- bun.lockb | Bin 114724 -> 115127 bytes package.json | 1 + src/App.tsx | 1 + src/components/ContextMenuPortal.tsx | 44 ++++++++++++++ src/components/ImageCard.tsx | 82 ++++++++++++++++++++------- src/components/NoteCard.tsx | 39 +++++++++++++ 6 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 src/components/ContextMenuPortal.tsx diff --git a/bun.lockb b/bun.lockb index dbb1abe2df37987ad8f701e3bb754fcfe37797d7..56b29729f01466dd2139be249306079413266702 100755 GIT binary patch delta 19976 zcmeI4dwfk-+Q-j2a&Tx+iA%&K?m`n1Nsb6P?#fBriMTc-I4VLCDpgGkZKJBis&1;Z zN)e>3DykTzw54e2Wopu!&Qu$EL8lj;!TWvo-ls7$rqg*p^Zxg)Pk#GZzqOuqdDeQ? z+Ux9-vo{n~*}b63(&)$z-(7C7U_h%8LDT-^pP`q2u<6B>v&;9kSorY8_Y20gXqMXg zpmIoPzbvhZ_q%o$aX2RUCr90tlbgAYtWbxeXkt!oR@Bry$DJAeoIA6oJ64c>3+V;O zn#f7WkY%OK3*QfNI2w`gGO{6Zjm;M#!{C|72xK2*V`K|tGo%aI1bMEKCEq|weu>SO zAf>)sWH>Sl8H}8flb1g+FVE4qn#l``LW%HKG(BT_jz81k$jX~A%RepCagOfRCjA{` z2=V|@EGxCsSK0i2J3rq}zr#-NkF1M+g3X&C>%rZ2`VZBm-V{gCXGEmpw~^A|KAUeu zN(CAz9k>@+2RYTwA7Y_D}cE$jHk}ukUcU;bo+YtjX-iOlBf$AWvKA zg+*6Ms71m>q*Pqqz$&m0DFgi|(;;#ZoUtfs$u!BpG(bv&spN~Sfm=xVu}IPXclB81 z3mru(@B`^lprS+6E*;v1zevSfZF$!e|HLU+>d(uXlZEUWVOd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Y(hz??6_25- z#e>brv9$ZIf1UY;*ekD^nK~8^>Y1|;e{OkPIoFNlviq;)It;bT^)RneAk_U`ip{m( z{P_L%e?Lo4tecv4p7CZ>Dm`$v#(wTAuIy#+RlZ|hAG3-&NKLXvKTEcMvSReAmR~)2 z;@eTBRTLMOD8|J7ZHnnLUhD8i^E(=qNYdh7Ac6ZN!)){z}pi;W<8y}wn4}Y zxct35CwNGuKWeo5WRAHUGw*>e=GHWIgUI8^I!C(L%d^?Ok;5BSTu|onIJ?dJUpK3z TtA(3iNmonN=6T~)s}cVN2AoL_ diff --git a/package.json b/package.json index 728dbae..724a55b 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "commit": "cz" }, "dependencies": { + "@kaioken-core/hooks": "^0.0.8", "@tauri-apps/api": "^1", "caniuse-lite": "^1.0.30001667", "kaioken": "^0.32.1", diff --git a/src/App.tsx b/src/App.tsx index 4189a94..1094b82 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,6 +9,7 @@ export function App() { return ( +
) } diff --git a/src/components/ContextMenuPortal.tsx b/src/components/ContextMenuPortal.tsx new file mode 100644 index 0000000..2c57cab --- /dev/null +++ b/src/components/ContextMenuPortal.tsx @@ -0,0 +1,44 @@ +import { useClickOutside, useMouse } from "@kaioken-core/hooks"; +import { Portal, signal, useEffect, useRef } from "kaioken"; + +namespace ContextMenuPortal { + export interface Props { + children: JSX.Children + open: boolean + closeAction: (() => void) | null | undefined + } +} +export function ContextMenuPortal({ children, open, closeAction }: ContextMenuPortal.Props) { + const { mouse } = useMouse() + const pos = signal({ x: 0, y: 0 }) + const ref = useRef(null) + + useClickOutside(ref, () => { + closeAction?.() + }) + + useEffect(() => { + if (!open) return + pos.value = { x: mouse.x, y: mouse.y } + }, [open]) + + if (!open) return null + + return ( + document.querySelector("#context-menu-portal")!} + > +
+ {children} +
+
+ ) +} diff --git a/src/components/ImageCard.tsx b/src/components/ImageCard.tsx index bbecaaa..073ba02 100644 --- a/src/components/ImageCard.tsx +++ b/src/components/ImageCard.tsx @@ -5,6 +5,7 @@ import { LayerEnum } from "../utils/enums" import images, { ImageCardType } from "../signals/images" import { updateLocalStorage } from "../utils/localStorage" import { useThemeDetector } from "../utils/useThemeDetector" +import { ContextMenuPortal } from "./ContextMenuPortal" namespace ImageCard { export interface ImageCardProps { @@ -22,6 +23,7 @@ export function ImageCard({ key: itemKey, data: item }: ImageCard.ImageCardProps const offsetY = useRef(0) const initialResizeX = useRef(0) const initialResizeY = useRef(0) + const openContextMenu = signal(false) function debounceLSUpdate(time?: number) { debounce(() => { @@ -93,29 +95,65 @@ export function ImageCard({ key: itemKey, data: item }: ImageCard.ImageCardProps ImagesSignal.default.images.notify() } - return ( -
- + function _handleMouseClick(e: MouseEvent) { + e.preventDefault() + openContextMenu.value = !openContextMenu.value + } - -
+ function _handleContextClose() { + openContextMenu.value = false + } + + return ( + <> +
+ + + +
+ + +
+
+
+ {item.title} +
+
+ +
+ +
+
    +
  • + +
  • +
  • +
  • +
+
+
+
+ ) } diff --git a/src/components/NoteCard.tsx b/src/components/NoteCard.tsx index 1e1c82d..ff18c7b 100644 --- a/src/components/NoteCard.tsx +++ b/src/components/NoteCard.tsx @@ -9,6 +9,7 @@ import { ChangeEvent } from "tiny-markdown-editor" import { Divider } from "./Divider" import { ExportIcon } from "./icons/ExportIcon" import { createFileAndExport } from "../utils/createFileAndExport" +import { ContextMenuPortal } from "./ContextMenuPortal" namespace NoteCard { export interface NoteCardProps { @@ -26,6 +27,7 @@ export function NoteCard({ key: itemKey, data: item }: NoteCard.NoteCardProps) { const offsetY = useRef(0) const initialResizeX = useRef(0) const initialResizeY = useRef(0) + const openContextMenu = signal(false) const { debounce } = useDebounce() @@ -113,6 +115,15 @@ export function NoteCard({ key: itemKey, data: item }: NoteCard.NoteCardProps) { createFileAndExport("Note", item.contents, "text/markdown") } + function _handleMouseClick(e: MouseEvent) { + e.preventDefault() + openContextMenu.value = !openContextMenu.value + } + + function _handleContextClose() { + openContextMenu.value = false + } + const cardPositionStyle = { zIndex: `${focusedItem.value == itemKey ? LayerEnum.CARD_ELEVATED : LayerEnum.CARD}`, width: `${item.dimensions.w}px`, @@ -127,6 +138,7 @@ export function NoteCard({ key: itemKey, data: item }: NoteCard.NoteCardProps) { return (
+ + +
+
+
+ {item.title} +
+
+ +
+ +
+
    +
  • + +
  • +
  • + +
  • +
+
+
+
) -- 2.43.0 From a2259f40ed8451f1f087e83baee5a6253da38b4a Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Sat, 12 Oct 2024 13:31:15 -0400 Subject: [PATCH 2/2] feat(contextmenu): adds escape keyevent closing menu --- src/components/ContextMenuPortal.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/ContextMenuPortal.tsx b/src/components/ContextMenuPortal.tsx index 2c57cab..e57278a 100644 --- a/src/components/ContextMenuPortal.tsx +++ b/src/components/ContextMenuPortal.tsx @@ -1,4 +1,4 @@ -import { useClickOutside, useMouse } from "@kaioken-core/hooks"; +import { useClickOutside, useKeyStroke, useMouse } from "@kaioken-core/hooks"; import { Portal, signal, useEffect, useRef } from "kaioken"; namespace ContextMenuPortal { @@ -20,6 +20,14 @@ export function ContextMenuPortal({ children, open, closeAction }: ContextMenuPo useEffect(() => { if (!open) return pos.value = { x: mouse.x, y: mouse.y } + function _handleEscapeKey(e: KeyboardEvent) { + if (e.key !== "Escape") return + closeAction?.() + } + document.addEventListener("keydown", _handleEscapeKey) + return () => { + document.removeEventListener("keydown", _handleEscapeKey) + } }, [open]) if (!open) return null -- 2.43.0