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 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;
}
};
onMounted(() => {
document.addEventListener('mousedown', handleMouseDown);
document.addEventListener('click', handleMouseDown);
});
onUnmounted(() => {
document.removeEventListener('mousedown', handleMouseDown);
document.removeEventListener('click', handleMouseDown);
});
</script>

View File

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

View File

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