Skip to content

Instantly share code, notes, and snippets.

@gabalis
Last active October 16, 2024 13:45
Show Gist options
  • Save gabalis/91e254ce2e9f5ac090754914ebe7bcae to your computer and use it in GitHub Desktop.
Save gabalis/91e254ce2e9f5ac090754914ebe7bcae to your computer and use it in GitHub Desktop.
Svelte component handling click events on its parent element
<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