json-theme-even-fork/components/icon.js

16 lines
486 B
JavaScript
Raw Normal View History

2023-02-01 01:47:10 +01:00
import feather from 'feather-icons'
/** @typedef {import('feather-icons').FeatherIconNames} FeatherIconNames */
/**
* @param {string} name
* @param {string} [fallback]
* @returns {string | undefined}
*/
export default function Icon(name, fallback) {
2023-02-01 01:47:10 +01:00
const icon =
feather.icons[/** @type {FeatherIconNames} */ (name.toLowerCase())] ||
(fallback && feather.icons[/** @type {FeatherIconNames} */ (fallback.toLowerCase())])
return icon?.toSvg({ width: 16, height: 16 })
}