mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
18 lines
576 B
TypeScript
18 lines
576 B
TypeScript
import { Octicon } from '.'
|
|
|
|
type BtnProps = {
|
|
icon?: keyof typeof Octicon,
|
|
label?: string,
|
|
active?: boolean,
|
|
tooltip?: string,
|
|
tooltipLoc?: 'se' | 'sw' | 'nw',
|
|
class?: string,
|
|
onClick?: (event: MouseEvent) => unknown,
|
|
}
|
|
export function Btn({ icon, label, active, class: clazz, tooltip, tooltipLoc, onClick }: BtnProps) {
|
|
return <div class={`btn${active ? ' active' : ''}${clazz ? ` ${clazz}` : ''}${tooltip ? ` tooltipped tip-${tooltipLoc ?? 'sw'}` : ''}`} onClick={onClick} aria-label={tooltip}>
|
|
{icon && Octicon[icon]}
|
|
{label && <span>{label}</span>}
|
|
</div>
|
|
}
|