ast-render-svg.js 882 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * Set inline CSS class.
  3. * @param {object} props - The block object.
  4. * @return {array} The inline CSS class.
  5. */
  6. import astIcons from "../../../assets/svg/ast-social-icons"
  7. import parseSVG from "./ast-parse-svg"
  8. import React from 'react';
  9. function renderSVG ( svg ) {
  10. svg = parseSVG( svg )
  11. var fontAwesome = astIcons[svg]
  12. if ( "undefined" != typeof fontAwesome ) {
  13. var viewbox_array = ( fontAwesome["svg"].hasOwnProperty("brands") ) ? fontAwesome["svg"]["brands"]["viewBox"] : fontAwesome["svg"]["solid"]["viewBox"]
  14. var path = ( fontAwesome["svg"].hasOwnProperty("brands") ) ? fontAwesome["svg"]["brands"]["path"] : fontAwesome["svg"]["solid"]["path"]
  15. var viewBox = viewbox_array.join( " " )
  16. return (
  17. <svg xmlns="http://www.w3.org/2000/svg" viewBox={viewBox}><path d={path}></path></svg>
  18. )
  19. }
  20. }
  21. export default renderSVG;