Files
misode.github.io/src/app/components/BtnLink.tsx
2022-06-16 00:58:14 +02:00

22 lines
607 B
TypeScript

import { Octicon } from './index.js'
interface Props {
link?: string,
icon?: keyof typeof Octicon,
label?: string,
tooltip?: string,
tooltipLoc?: 'se' | 'sw' | 'nw',
swapped?: boolean,
}
export function BtnLink({ link, icon, label, tooltip, tooltipLoc, swapped }: Props) {
return <a {...link ? { href: link } : { disabled: true }} class={`btn btn-link${tooltip ? ` tooltipped tip-${tooltipLoc ?? 'sw'}` : ''}`} aria-label={tooltip}>
{swapped ? <>
{label && <span>{label}</span>}
{icon && Octicon[icon]}
</> : <>
{icon && Octicon[icon]}
{label && <span>{label}</span>}
</>}
</a>
}