feat: use background clips instead of a weird absolute whatever
This commit is contained in:
1 parent
aa6650ec76
commit
b6788c7fc1
2 files changed
+44
-29
No files matched your search
@@ -3,17 +3,39 @@
|
||||
export let highlight: boolean = false
|
||||
export let nowrap: boolean = false
|
||||
|
||||
const parseURL = (href: string) => {
|
||||
try {
|
||||
return new URL(href)
|
||||
} catch (e) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
$: richURL = parseURL(href)
|
||||
</script>
|
||||
|
||||
<a {href} class="{highlight ? 'text-blue-500' : ''} hover:underline max-w-full">
|
||||
<slot name="icon" />
|
||||
<slot>
|
||||
<span
|
||||
class="flex gap-0 {nowrap
|
||||
class="flex relative gap-0 {nowrap
|
||||
? 'w-full whitespace-nowrap overflow-hidden text-ellipsis text-xs'
|
||||
: ''} {$$props.class}"
|
||||
: ''} {$$props.class} text-transparent bg-clip-text bg-gradient-to-r
|
||||
from-blue-500 via-blue-500 to-blue-500/0"
|
||||
>
|
||||
{href}
|
||||
{#if richURL}
|
||||
<span class="opacity-60">
|
||||
{richURL.protocol}//
|
||||
</span>
|
||||
<span class="font-medium">
|
||||
{richURL.hostname}
|
||||
</span>
|
||||
<span class="opacity-60">
|
||||
{richURL.pathname}
|
||||
</span>
|
||||
{:else}
|
||||
{href}
|
||||
{/if}
|
||||
</span>
|
||||
</slot>
|
||||
</a>
|
||||
Reference in new issue
Block a user