Created
October 20, 2023 09:52
-
-
Save roymckenzie/e8d9b9299611574680e630aea5e3cd5c to your computer and use it in GitHub Desktop.
Mithril.js - Tailwind/SVG Icons
This file contains 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
import m from 'mithril'; | |
import trashIcon from '../../../public/trash.svg?raw'; | |
import bars3 from '../../../public/bars-3.svg?raw'; | |
import bars4 from '../../../public/bars-4.svg?raw'; | |
const IconMap = { | |
trash: trashIcon, | |
'bars-3': bars3, | |
'bars-4': bars4 | |
}; | |
type IconName = keyof typeof IconMap; | |
export default (name: IconName, attributes: m.Attributes = {}) => { | |
return m('span.icon', attributes, m.trust(IconMap[name])); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment