This repository was archived by the owner on Sep 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
packages/chakra-ui-core/src/utils Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { merge } from 'lodash-es'
2
2
3
+ /**
4
+ * @description Parse FontAwesome icon path
5
+ * @param {String|Array } path a single svg path, or array of paths
6
+ * @returns {String }
7
+ */
8
+ const parseFontAwesomeIcon = ( path ) => {
9
+ // duotone icon
10
+ if ( Array . isArray ( path ) && path . length === 2 ) {
11
+ const paths = path . map ( ( d , idx ) =>
12
+ `<path d="${ d } " fill="currentColor" class="${ idx ? 'fa-primary' : 'fa-secondary' } " />`
13
+ )
14
+
15
+ return `<defs><style>.fa-secondary{opacity:.4}</style></defs><g class="fa-group">${ paths . join ( '' ) } </g>`
16
+ }
17
+
18
+ return `<path d="${ path } " fill="currentColor" />`
19
+ }
20
+
3
21
/**
4
22
* @description Custom parse all Icons provided by user
5
23
* @param {Object } iconSet - Registered Icons object
@@ -14,7 +32,7 @@ const parseIcons = (iconSet = {}) => {
14
32
return {
15
33
[ `${ iconObject . iconName } ` ] : {
16
34
path : iconObject . prefix . startsWith ( 'fa' )
17
- ? `< path d=" ${ path } " fill="currentColor" />`
35
+ ? parseFontAwesomeIcon ( path )
18
36
: iconObject . prefix . startsWith ( 'fe' )
19
37
? content
20
38
: svg ,
You can’t perform that action at this time.
0 commit comments