diff options
| author | codetorso <[email protected]> | 2024-06-04 21:08:22 +0530 |
|---|---|---|
| committer | codetorso <[email protected]> | 2024-06-04 21:08:22 +0530 |
| commit | 7ceaddf6f499cda8f4ded9a02e6f511a7372f11b (patch) | |
| tree | fbd6631a3f0fb99b8dbb5f427de06017cda96955 | |
| parent | Implemented Highlight in Extension (diff) | |
| download | supermemory-7ceaddf6f499cda8f4ded9a02e6f511a7372f11b.tar.xz supermemory-7ceaddf6f499cda8f4ded9a02e6f511a7372f11b.zip | |
Implement extension
| -rw-r--r-- | apps/an-extension/background.ts | 7 | ||||
| -rw-r--r-- | apps/an-extension/content/ContentApp.tsx | 50 | ||||
| -rw-r--r-- | apps/an-extension/content/content.css | 9 | ||||
| -rw-r--r-- | apps/an-extension/content/content.tsx | 2 | ||||
| -rw-r--r-- | apps/an-extension/public/tailwind_bg.png | bin | 174555 -> 0 bytes | |||
| -rw-r--r-- | apps/an-extension/tailwind.config.js | 1 | ||||
| -rw-r--r-- | apps/an-extension/tsconfig.json | 1 | ||||
| -rw-r--r-- | packages/ui/shadcn/use-toast.ts | 2 |
8 files changed, 38 insertions, 34 deletions
diff --git a/apps/an-extension/background.ts b/apps/an-extension/background.ts index 3428b484..4e453b95 100644 --- a/apps/an-extension/background.ts +++ b/apps/an-extension/background.ts @@ -10,10 +10,6 @@ chrome.runtime.onInstalled.addListener(function () { chrome.contextMenus.onClicked.addListener(function (info, tab) { if (info.menuItemId === 'selection') { - console.log(info.pageUrl) - chrome.tabs.sendMessage(tab?.id || 1, info.selectionText); - console.log(info.selectionText) - // you can add a link to a cf worker or whatever u want // fetch("", { // method: "POST", @@ -22,5 +18,8 @@ chrome.contextMenus.onClicked.addListener(function (info, tab) { // data: info.selectionText, // }), // }); + + //so you first save it and then send the reponse to the screen + chrome.tabs.sendMessage(tab?.id || 1, info.selectionText); } }); diff --git a/apps/an-extension/content/ContentApp.tsx b/apps/an-extension/content/ContentApp.tsx index 8773c71d..45ca64b4 100644 --- a/apps/an-extension/content/ContentApp.tsx +++ b/apps/an-extension/content/ContentApp.tsx @@ -1,45 +1,45 @@ import React, { useEffect } from "react"; -import tailwindBg from "../public/tailwind_bg.png"; export default function ContentApp() { const [text, setText] = React.useState(""); + const [hover, setHover] = React.useState(false); useEffect(() => { const messageListener = (message: any) => { setText(message); setTimeout(() => setText(""), 2000); }; - chrome.runtime.onMessage.addListener(messageListener); + + document.addEventListener('mousemove', (e)=> { + const percentageX = (e.clientX / window.innerWidth) * 100; + const percentageY = (e.clientY / window.innerHeight) * 100; + + if (percentageX > 75 && percentageY > 75){ + setHover(true) + } else { + setHover(false) + } + }) return () => { chrome.runtime.onMessage.removeListener(messageListener); }; }, []); return ( - <div - className={`pointer-events-none ${text ? "opacity-100" : "opacity-0"} transition mx-auto max-w-7xl md:px-0 lg:px-6 lg:py-2`} - > - <div className="relative isolate overflow-hidden bg-gray-900 px-6 py-4 shadow-2xl lg:rounded-3xl md:pt-24 md:h-full sm:h-[100vh] lg:flex lg:gap-x-20 lg:px-24 lg:pt-0"> - <div className="absolute z-20 top-0 inset-x-0 flex justify-center overflow-hidden pointer-events-none"> - <div className="w-[108rem] flex-none flex justify-end"> - <picture> - <img - src={tailwindBg} - alt="" - className="w-[90rem] flex-none max-w-none hidden dark:block" - decoding="async" - /> - </picture> - </div> - </div> - <div className="mx-auto max-w-md text-center lg:py-12 lg:mx-0 lg:flex-auto lg:text-left"> - <div className="flex items-center justify-center space-x-4 my-4 mx-auto"></div> - <h2 className="text-3xl font-bold tracking-tight text-white sm:text-4xl"> - Saved: {text} - </h2> - </div> + <div className="pointer-events-none flex justify-end items-end h-screen w-full absolute z-99999"> + <div className="h-[30vh] absolute flex justify-end items-center"> + <div + className={`${hover && "opacity-100 "} transition bg-red-600 opacity-0 h-12 w-12 `} + ></div> + </div> + + <div + className={`mx-4 my-2 flex flex-col gap-3 rounded-3xl bg-gray-900 text-xl py-4 px-6 overflow-hidden min-w-[20vw] min-h-24 max-w-96 max-h-40 ${text ? "translate-y-0 opacity-100" : "translate-y-[15%] opacity-0"} transition`} + > + <h2 className="text-2xl font-extrabold text-white">Saved!</h2> + <h2 className="text-lg font-medium text-white">{text}</h2> </div> </div> ); -} +}
\ No newline at end of file diff --git a/apps/an-extension/content/content.css b/apps/an-extension/content/content.css index b8195ee8..a860749f 100644 --- a/apps/an-extension/content/content.css +++ b/apps/an-extension/content/content.css @@ -1,6 +1,9 @@ #extension-root { + pointer-events: none; position: fixed; - bottom: 0; - right: 0; - z-index: 99999; + top: 0; + left: 0; + height: 100vh; + width: 100%; + z-index: 999999; } diff --git a/apps/an-extension/content/content.tsx b/apps/an-extension/content/content.tsx index d9e5a4ed..17436ef2 100644 --- a/apps/an-extension/content/content.tsx +++ b/apps/an-extension/content/content.tsx @@ -11,5 +11,5 @@ function initial() { document.body.appendChild(rootDiv) const root = ReactDOM.createRoot(rootDiv) - root.render(<ContentApp />) + root.render(<><ContentApp /></>) } diff --git a/apps/an-extension/public/tailwind_bg.png b/apps/an-extension/public/tailwind_bg.png Binary files differdeleted file mode 100644 index edc40be8..00000000 --- a/apps/an-extension/public/tailwind_bg.png +++ /dev/null diff --git a/apps/an-extension/tailwind.config.js b/apps/an-extension/tailwind.config.js index 069e1bc3..8ddba0a5 100644 --- a/apps/an-extension/tailwind.config.js +++ b/apps/an-extension/tailwind.config.js @@ -6,3 +6,4 @@ module.exports = { }, plugins: [] } +module.exports = require("@repo/tailwind-config/tailwind.config"); diff --git a/apps/an-extension/tsconfig.json b/apps/an-extension/tsconfig.json index 520f3602..4d9801e2 100644 --- a/apps/an-extension/tsconfig.json +++ b/apps/an-extension/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "@repo/typescript-config/nextjs.json", "compilerOptions": { "allowJs": true, "allowSyntheticDefaultImports": true, diff --git a/packages/ui/shadcn/use-toast.ts b/packages/ui/shadcn/use-toast.ts index 6f6180cc..80c3abff 100644 --- a/packages/ui/shadcn/use-toast.ts +++ b/packages/ui/shadcn/use-toast.ts @@ -3,7 +3,7 @@ // Inspired by react-hot-toast library import * as React from "react"; -import type { ToastActionElement, ToastProps } from "packages/ui/src/toast"; +import type { ToastActionElement, ToastProps } from "@repo/ui/shadcn/toast"; const TOAST_LIMIT = 1; const TOAST_REMOVE_DELAY = 1000000; |