From 54dc1a24ff69f24a6422a9423dd5a3d3109cff6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Mon, 1 Aug 2022 18:09:51 +0200 Subject: [PATCH] Rework conditions for Button - Was prefetching mailto links, so needs to detect if url string is starting - Check if it actually has slots, then add a class --- src/components/atoms/Button.svelte | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/atoms/Button.svelte b/src/components/atoms/Button.svelte index 6c4f54f..c4f8916 100644 --- a/src/components/atoms/Button.svelte +++ b/src/components/atoms/Button.svelte @@ -19,14 +19,14 @@ className, effect ? effect : undefined, ...[color, size].map(variant => variant && `${className}--${variant}`), - $$slots ? `has-icon-${slotPosition}` : undefined, + Object.keys($$slots).length !== 0 ? `has-icon-${slotPosition}` : undefined, $$props.class ].join(' ').trim() // Define external links - let rel: string, target: string - $: isExternal = /(http(s?)):\/\//i.test(url) - $: rel = isExternal ? 'external noopener noreferrer' : null + $: isExternal = /^(http|https):\/\//i.test(url) + $: isProtocol = /^(mailto|tel):/i.test(url) + $: rel = isExternal ? 'external noopener' : null $: target = isExternal ? '_blank' : null @@ -43,9 +43,9 @@ {:else if tag === 'a'}