pinafore/src/routes/_components/ExternalLink.html

48 lines
1.1 KiB
HTML
Raw Normal View History

2018-01-29 05:07:31 +00:00
<a rel="nofollow noopener"
target="_blank"
{href}
aria-label={ariaLabel}
class={computedClass}>
<slot></slot>{#if showIcon}
<SvgIcon className="external-link-svg" href="#fa-external-link" />
{/if}</a>
2018-01-29 03:01:51 +00:00
<style>
2018-01-29 05:07:31 +00:00
.external-link-with-icon {
2018-01-29 03:01:51 +00:00
display: inline-flex;
align-items: center;
}
:global(.external-link-with-icon .external-link-svg) {
2018-01-29 03:01:51 +00:00
margin-left: 4px;
width: 14px;
height: 14px;
fill: var(--deemphasized-text-color);
}
:global(.external-link-with-icon.normal-icon-color .external-link-svg) {
2018-02-10 22:35:21 +00:00
fill: var(--body-text-color);
}
</style>
<script>
import { classname } from '../_utils/classname'
import SvgIcon from './SvgIcon.html'
export default {
data: () => ({
2018-04-30 16:57:49 +00:00
className: void 0,
normalIconColor: false,
ariaLabel: '',
showIcon: false
}),
computed: {
computedClass: ({ className, showIcon, normalIconColor }) => (classname(
'external-link',
className,
showIcon && 'external-link-with-icon',
normalIconColor && 'normal-icon-color'
))
},
components: {
SvgIcon
}
}
</script>