From 40cc0f3ab84dfd6c2ef6230be596683f90a35c24 Mon Sep 17 00:00:00 2001 From: Gavin McDonald Date: Wed, 16 Apr 2025 16:14:03 -0400 Subject: [PATCH] tweaks --- components/CopyButton.tsx | 10 +++++++--- components/Switch.tsx | 6 +++--- components/ToolTip.tsx | 8 ++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/components/CopyButton.tsx b/components/CopyButton.tsx index 2f055de..13dc9bf 100644 --- a/components/CopyButton.tsx +++ b/components/CopyButton.tsx @@ -1,7 +1,7 @@ 'use client'; import { useState } from 'react'; -import { Copy as CopyIcon } from 'lucide-react'; +import { Copy as CopyIcon, Check as CheckIcon } from 'lucide-react'; import ToolTip from '@/components/ToolTip'; @@ -30,8 +30,12 @@ export default function CopyButton({ title, copy }: CopyButtonProps) { className="w-full py-1 px-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg flex flex-col items-start gap-1 shadow transition-all cursor-pointer" >
- {`${copied ? 'Copied' : 'Copy'} ${title}`} - + {`Copy ${title}`} + {copied ? ( + + ) : ( + + )}
diff --git a/components/Switch.tsx b/components/Switch.tsx index d1ad149..340d7e1 100644 --- a/components/Switch.tsx +++ b/components/Switch.tsx @@ -17,9 +17,9 @@ export default function Switch({ label, value, toggleAction }: SwitchProps) { }`} />
diff --git a/components/ToolTip.tsx b/components/ToolTip.tsx index 88be010..f39b50e 100644 --- a/components/ToolTip.tsx +++ b/components/ToolTip.tsx @@ -37,13 +37,17 @@ export default function Tooltip({ const handleMouseMove = (e: React.MouseEvent) => { const { clientX: x, clientY: y } = e; + const ttWidth = ttRef.current?.offsetWidth || 0; const ttHeight = ttRef.current?.offsetHeight || 0; + const viewportWidth = window.innerWidth - edgeBuffer; const viewportHeight = window.innerHeight - edgeBuffer; + const ttRight = ttWidth + offsetX + x; const ttBottom = ttHeight + offsetY + y; - const adjustment = ttBottom > viewportHeight ? ttBottom - viewportHeight : 0; + const adjustX = ttRight > viewportWidth ? ttRight - viewportWidth : 0; + const adjustY = ttBottom > viewportHeight ? ttBottom - viewportHeight : 0; - setPos({ x, y: y - adjustment }); + setPos({ x: x - adjustX, y: y - adjustY }); }; const handleTouchStart = () => {