to-svg.js 615 Bytes
Newer Older
Cole Bemis's avatar
Cole Bemis committed
1
import icons from './icons';
2 3 4

/**
 * Create an SVG string.
Cole Bemis's avatar
Cole Bemis committed
5 6 7
 * @deprecated
 * @param {string} name
 * @param {Object} attrs
8 9
 * @returns {string}
 */
Cole Bemis's avatar
Cole Bemis committed
10 11 12 13 14 15
function toSvg(name, attrs = {}) {
  console.warn(
    'feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.',
  );

  if (!name) {
16 17 18
    throw new Error('The required `key` (icon name) parameter is missing.');
  }

Cole Bemis's avatar
Cole Bemis committed
19 20 21 22 23 24
  if (!icons[name]) {
    throw new Error(
      `No icon matching '${
        name
      }'. See the complete list of icons at https://feathericons.com`,
    );
25 26
  }

Cole Bemis's avatar
Cole Bemis committed
27
  return icons[name].toSvg(attrs);
28 29
}

Cole Bemis's avatar
Cole Bemis committed
30
export default toSvg;