Optimize components

- Use class attribute over className
- Code cleaning
This commit is contained in:
2020-02-26 15:49:56 +01:00
parent b084629b37
commit afb087408c
8 changed files with 18 additions and 72 deletions

View File

@@ -1,20 +1,19 @@
<script>
export let href = '#'
export let type = 'a'
export let className = 'button'
export let text = ''
const hasSlot = arguments[1].$$slots !== undefined
</script>
{#if type === 'button'}
<button class={className} class:button-icon={hasSlot} data-text={text} on:click>
<button class={$$props.class ? $$props.class : 'button'} class:button-icon={hasSlot} data-text={text} on:click>
<slot></slot>
<span>{text}</span>
</button>
{:else}
<a {href} class={className} class:button-icon={hasSlot} data-text={text} on:click>
<a {href} class={$$props.class ? $$props.class : 'button'} class:button-icon={hasSlot} data-text={text} on:click>
<slot></slot>
<span>{text}</span>
</a>