Button: Fix the spacing with an icon

This commit is contained in:
2020-02-14 12:35:38 +01:00
parent dfcc3f9f7a
commit 29f6e7e645
2 changed files with 20 additions and 10 deletions

View File

@@ -4,20 +4,17 @@
export let className = 'button'
export let text = ''
// Wrap string's each letters into a span
// const textSpans = text
// .replace(/(<.*?>)|(.)/g, letter => letter.replace(/./g, '<span>$&</span>'))
// .replace(/ /g, '\u00a0')
const hasSlot = arguments[1].$$slots !== undefined
</script>
{#if type === 'button'}
<button class={className} data-text={text}>
<button class={className} class:button-icon={hasSlot} data-text={text}>
<slot></slot>
<span>{text}</span>
</button>
{:else}
<a {href} class={className} data-text={text}>
<a {href} class={className} class:button-icon={hasSlot} data-text={text}>
<slot></slot>
<span>{text}</span>
</a>