diff --git a/resources/dist/filament-theme-inspector.js b/resources/dist/filament-theme-inspector.js index ec8bbe6..e2fcf47 100644 --- a/resources/dist/filament-theme-inspector.js +++ b/resources/dist/filament-theme-inspector.js @@ -1,11 +1,14 @@ -console.log(window.filamentData.icon);function p(){let e=document.createElement("div");e.style.cssText=` +function c(){let e=document.createElement("div");e.style.cssText=` position: fixed; background: rgba(0, 0, 0, 0.8); padding: 10px 15px; border-radius: 5px; display: none; z-index: 9999; white-space: nowrap; overflow: hidden; - text-overflow: ellipsis; display: flex; align-items: center;`;let t=document.createElement("span");t.style.color="white",t.style.marginRight="10px",e.appendChild(t);let n=document.createElement("button");return n.innerHTML=` + text-overflow: ellipsis; display: flex; align-items: center;`;let n=document.createElement("span");n.style.color="white",n.style.marginRight="10px",e.appendChild(n);let t=document.createElement("button"),i=` - `,n.style.cssText=` + `;t.innerHTML=i,t.style.cssText=` background: rgba(0, 0, 0, 0.5); color: white; border: none; cursor: pointer; padding: 5px 10px; - font-size: 12px; border-radius: 5px;`,n.addEventListener("click",()=>{let s=t.textContent;navigator.clipboard.writeText(s).then(()=>l(e)).catch(i=>console.error("Failed to copy: ",i))}),e.appendChild(n),document.body.appendChild(e),{popup:e,textNode:t}}function h(e,t,n,s,i){t.textContent=n,e.style.left=`${s+10}px`,e.style.top=`${i+10}px`,e.style.display="flex";let o=e.getBoundingClientRect(),d=window.innerWidth,c=window.innerHeight;o.right>d&&(e.style.left=`${d-o.width-10}px`),o.left<0&&(e.style.left="10px"),o.bottom>c&&(e.style.top=`${i-o.height-10}px`)}function l(e){e.style.display="none"}var{popup:a,textNode:x}=p(),r=!1;document.querySelectorAll("[class]").forEach(e=>{e.classList.forEach(t=>{t.startsWith("fi-")&&(e.addEventListener("mouseenter",n=>{r||h(a,x,t,n.clientX,n.clientY)}),e.addEventListener("mouseleave",()=>{r||l(a)}))})});document.addEventListener("keydown",e=>{e.altKey&&(r=!0,a.style.pointerEvents="auto")});document.addEventListener("keyup",e=>{(e.key==="Alt"||e.key==="Meta")&&(r=!1)}); + font-size: 12px; border-radius: 5px;`;let r=` + + + `;return t.addEventListener("click",()=>{let o=n.textContent;navigator.clipboard.writeText(o).then(()=>{t.innerHTML=r,setTimeout(()=>{t.innerHTML=i},2e3)}).catch(s=>console.error("Failed to copy: ",s))}),e.appendChild(t),document.body.appendChild(e),{popup:e,textNode:n}}function p(e,n,t,i,r){n.textContent=t,e.style.left=`${i+10}px`,e.style.top=`${r+10}px`,e.style.display="flex";let o=e.getBoundingClientRect(),s=window.innerWidth,l=window.innerHeight;o.right>s&&(e.style.left=`${s-o.width-10}px`),o.left<0&&(e.style.left="10px"),o.bottom>l&&(e.style.top=`${r-o.height-10}px`)}function h(e){e.style.display="none"}var{popup:a,textNode:u}=c(),d=!1;document.querySelectorAll("[class]").forEach(e=>{e.classList.forEach(n=>{n.startsWith("fi-")&&(e.addEventListener("mouseenter",t=>{d||p(a,u,n,t.clientX,t.clientY)}),e.addEventListener("mouseleave",()=>{d||h(a)}))})});document.addEventListener("keydown",e=>{e.altKey&&(d=!0,a.style.pointerEvents="auto")});document.addEventListener("keyup",e=>{(e.key==="Alt"||e.key==="Meta")&&(d=!1)}); diff --git a/resources/js/index.js b/resources/js/index.js index 583bf74..a580850 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -12,20 +12,35 @@ function createPopup() { popup.appendChild(textNode); const copyButton = document.createElement('button'); - copyButton.innerHTML = ` + let copyIcon = ` `; + copyButton.innerHTML = copyIcon; + copyButton.style.cssText = ` background: rgba(0, 0, 0, 0.5); color: white; border: none; cursor: pointer; padding: 5px 10px; font-size: 12px; border-radius: 5px;`; + const checkmarkSVG = ` + + + `; + copyButton.addEventListener('click', () => { const textToCopy = textNode.textContent; // Get text from the span - navigator.clipboard.writeText(textToCopy).then(() => hidePopup(popup)) - .catch(err => console.error('Failed to copy: ', err)); + navigator.clipboard.writeText(textToCopy).then(() => { + // Change button icon to checkmark + copyButton.innerHTML = checkmarkSVG; + + // Reset button icon after 2 seconds + setTimeout(() => { + copyButton.innerHTML = copyIcon; + }, 2000); + + }).catch(err => console.error('Failed to copy: ', err)); }); popup.appendChild(copyButton);