chore: add event listener for button.

This commit is contained in:
rajat-ht
2025-05-21 17:11:29 +05:30
parent 48e6e60753
commit f23a26e528
3 changed files with 9 additions and 7 deletions

View File

@@ -83,21 +83,24 @@ const featureColumns = ref<Feature[][]>([
], ],
]); ]);
const isVisible = ref(true); const isVisible = ref(false);
const handleMouseDown = (e: MouseEvent) => { const handleMouseDown = (e: MouseEvent) => {
const target = e.target as HTMLElement; const target = e.target as HTMLElement;
if (target.matches('a[class*="editorModal"]') || target.matches('button[class*="editorModal"]')) { if (
(target.tagName === 'A' && target.textContent?.trim() === 'Try Playground') ||
(target.tagName === 'SPAN' && target.textContent?.trim() === '💻 Open Editor')
) {
isVisible.value = !isVisible.value; isVisible.value = !isVisible.value;
} }
}; };
onMounted(() => { onMounted(() => {
document.addEventListener('mousedown', handleMouseDown); document.addEventListener('click', handleMouseDown);
}); });
onUnmounted(() => { onUnmounted(() => {
document.removeEventListener('mousedown', handleMouseDown); document.removeEventListener('click', handleMouseDown);
}); });
</script> </script>

View File

@@ -120,9 +120,7 @@ function nav() {
}, },
{ {
text: '💻 Open Editor', text: '💻 Open Editor',
link: 'https://mermaid.live/edit', link: '/',
target: '_blank',
rel: 'external',
}, },
]; ];
} }

View File

@@ -17,6 +17,7 @@ hero:
actions: actions:
- theme: brand - theme: brand
text: Try Playground text: Try Playground
link: /
- theme: alt - theme: alt
text: Get started text: Get started
link: /intro/ link: /intro/