Created
June 12, 2020 15:43
-
-
Save jonathanmach/13a5d774ce4939bcc6749308c0740d7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- We're using Vue Functional components here --> | |
<template functional> | |
<div class="link-bookmark"> | |
<!-- The above parent div has been added so the parent scoped styles won't leak into this component --> | |
<a | |
:href="props.href" | |
target="_blank" | |
class="flex items-center border cursor-pointer rounded-md hover:bg-gray-100 py-2 px-4" | |
> | |
<div class="decorator"> | |
<component :is="$options.getIcon(props)" class="h-4 w-auto mr-3" /> | |
</div> | |
<div class="content "> | |
<h4 class="text-sm m-0"><slot /></h4> | |
<p class="text-xs truncate text-gray-600"> | |
{{ props.href }} | |
</p> | |
</div> | |
</a> | |
</div> | |
</template> | |
<script> | |
export default { | |
functional: true, | |
props: { | |
href: { | |
type: String, | |
default: '' | |
}, | |
icon: { | |
type: String, | |
default: null | |
} | |
}, | |
getIcon(props) { | |
if (props.href.includes('youtube.') || props.href.includes('youtu.')) { | |
return 'YoutubeIcon' | |
} else { | |
return props.icon | |
} | |
} | |
} | |
</script> | |
<style scoped> | |
.link-bookmark { | |
@apply pt-3; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment