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 11import { merge } from 'lodash-es'
22
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+
321/**
422 * @description Custom parse all Icons provided by user
523 * @param {Object } iconSet - Registered Icons object
@@ -14,7 +32,7 @@ const parseIcons = (iconSet = {}) => {
1432 return {
1533 [ `${ iconObject . iconName } ` ] : {
1634 path : iconObject . prefix . startsWith ( 'fa' )
17- ? `< path d=" ${ path } " fill="currentColor" />`
35+ ? parseFontAwesomeIcon ( path )
1836 : iconObject . prefix . startsWith ( 'fe' )
1937 ? content
2038 : svg ,
You can’t perform that action at this time.
0 commit comments