Skip to content

Instantly share code, notes, and snippets.

@roymckenzie
Created October 20, 2023 09:52
Show Gist options
  • Save roymckenzie/e8d9b9299611574680e630aea5e3cd5c to your computer and use it in GitHub Desktop.
Save roymckenzie/e8d9b9299611574680e630aea5e3cd5c to your computer and use it in GitHub Desktop.
Mithril.js - Tailwind/SVG Icons
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