Skip to content

Commit

Permalink
fix: Correct <Button> semantics by not wrapping the content (#221)
Browse files Browse the repository at this point in the history
refactor: simplify <Button>
  • Loading branch information
KTibow authored and oSumAtrIX committed Mar 3, 2024
1 parent 662839a commit d1363c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
36 changes: 17 additions & 19 deletions src/lib/components/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
export let label = '';
</script>

<button on:click>
{#if href}
<a {href} {target} {...$$restProps} class={`button-${type}`} aria-label={label}>
{#if icon}
<img src="../icons/{icon}.svg" alt={icon} />
{/if}
<slot />
</a>
{:else}
<div {...$$restProps} class={`button-${type}`} aria-label={label}>
{#if icon}
<img src="../icons/{icon}.svg" alt={icon} />
{/if}
<slot />
</div>
{/if}
</button>
{#if href}
<a {href} {target} class={`button-${type}`} aria-label={label}>
{#if icon}
<img src="../icons/{icon}.svg" alt={icon} />
{/if}
<slot />
</a>
{:else}
<button on:click class={`button-${type}`} aria-label={label}>
{#if icon}
<img src="../icons/{icon}.svg" alt={icon} />
{/if}
<slot />
</button>
{/if}

<style>
button {
Expand All @@ -33,7 +31,7 @@
}
a,
div {
button {
min-width: max-content;
font-size: 0.95rem;
text-decoration: none;
Expand Down Expand Up @@ -72,7 +70,7 @@
letter-spacing: 0.01rem;
}
div:hover,
button:hover,
a:hover {
filter: brightness(85%);
}
Expand Down
2 changes: 0 additions & 2 deletions src/routes/download/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<Button
type="text"
href={data.assets[0].browser_download_url}
download
on:click={() => (warningDialogue = false)}>Okay</Button
>
</Query>
Expand All @@ -100,7 +99,6 @@
type="filled"
icon="download"
href={data.assets[0].browser_download_url}
download
>
{data.metadata.tag_name}
</Button>
Expand Down

0 comments on commit d1363c7

Please sign in to comment.