Skip to content

Commit

Permalink
IconButton: Move click handler to button instead of image (#65)
Browse files Browse the repository at this point in the history
This moves the clickHandler for iconbutons to the <button> elem instead
of the nested <img> so that the entire button area is clickable, instead
of just the nested image height/width.
  • Loading branch information
lesleyjanenorton authored Sep 23, 2024
1 parent a59c396 commit d1a901a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/iconbutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,24 @@ export class IconLinkButton extends LitElement {
}
render() {
return html`
<button title="${this.alt}" class="ghost-btn ghost-icon-btn">
<img
aria-hidden="true"
@click=${() => {
this.onClick();
}}
src="../../assets/img/${this.icon}.svg"
/>
<button
title="${this.alt}"
@click=${() => {
this.onClick();
}}
class="ghost-btn ghost-icon-btn"
>
<img aria-hidden="true" src="../../assets/img/${this.icon}.svg" />
</button>
`;
}

static styles = css`
${ghostButtonStyles}
img {
pointer-events: none;
}
`;
}
customElements.define("mz-iconlink", IconLinkButton);

0 comments on commit d1a901a

Please sign in to comment.