summaryrefslogtreecommitdiff
path: root/inc/assets/js/ast-render-svg.js
diff options
context:
space:
mode:
Diffstat (limited to 'inc/assets/js/ast-render-svg.js')
-rw-r--r--inc/assets/js/ast-render-svg.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/inc/assets/js/ast-render-svg.js b/inc/assets/js/ast-render-svg.js
new file mode 100644
index 0000000..c354d00
--- /dev/null
+++ b/inc/assets/js/ast-render-svg.js
@@ -0,0 +1,30 @@
+/**
+ * Set inline CSS class.
+ * @param {object} props - The block object.
+ * @return {array} The inline CSS class.
+ */
+
+import astIcons from "../../../assets/svg/ast-social-icons"
+import parseSVG from "./ast-parse-svg"
+import React from 'react';
+
+function renderSVG ( svg ) {
+
+ svg = parseSVG( svg )
+
+ var fontAwesome = astIcons[svg]
+
+ if ( "undefined" != typeof fontAwesome ) {
+
+ var viewbox_array = ( fontAwesome["svg"].hasOwnProperty("brands") ) ? fontAwesome["svg"]["brands"]["viewBox"] : fontAwesome["svg"]["solid"]["viewBox"]
+ var path = ( fontAwesome["svg"].hasOwnProperty("brands") ) ? fontAwesome["svg"]["brands"]["path"] : fontAwesome["svg"]["solid"]["path"]
+ var viewBox = viewbox_array.join( " " )
+
+ return (
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox={viewBox}><path d={path}></path></svg>
+ )
+ }
+
+}
+
+export default renderSVG;