Last active
October 16, 2024 13:45
-
-
Save gabalis/91e254ce2e9f5ac090754914ebe7bcae to your computer and use it in GitHub Desktop.
Svelte component handling click events on its parent element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export let inputid = ''; | |
export let content = 'Read more…'; | |
export let handleClick = () => {}; | |
</script> | |
<style> | |
.coveringparentnode { | |
position: absolute; | |
z-index: 0; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
overflow: hidden; | |
text-indent: 100%; | |
white-space: nowrap; | |
cursor: pointer; | |
} | |
.displaynone { | |
display: none; | |
} | |
</style> | |
<label for={inputid} class="coveringparentnode"></label> | |
<button id={inputid} class="displaynone" on:click={handleClick} on:keyup={handleClick} >{content}</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment