@clinic/clinic-common
Version:
Shared parts between the Clinic.js suite
16 lines (13 loc) • 448 B
JavaScript
module.exports = ({ label, classNames = [], leftIcon = '', rightIcon = '', href, title = '', target = '' } = {}) => {
const link = document.createElement('a')
link.classList.add('nc-link', ...classNames)
link.setAttribute('href', href)
link.setAttribute('target', target)
if (title) link.title = title
link.innerHTML = `
${leftIcon}
${label ? `<span class="label">${label}</span>` : ''}
${rightIcon}
`
return link
}