Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 511fd45

Browse files
authored
fix: don't use options.iconPack, yet
1 parent 316d649 commit 511fd45

File tree

1 file changed

+11
-13
lines changed
  • packages/chakra-ui-core/src/utils

1 file changed

+11
-13
lines changed

packages/chakra-ui-core/src/utils/icons.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { merge } from 'lodash-es'
22

33
/**
4-
* @param {String} pack
5-
* @param {Array} icon
4+
* @param {String} prefix - prefix for the icon pack
5+
* @param {Array} icon - icon definition
66
* @returns {{path: string, viewBox: string, attrs: *}}
77
*/
8-
const createIcon = (pack, icon) => {
8+
const createIcon = (prefix, icon) => {
99
const [w, h, content, svg, data, , attrs] = icon
1010
let path
1111

@@ -21,12 +21,12 @@ const createIcon = (pack, icon) => {
2121
return `<g fill="currentColor" class="${prefix}-group">${paths.join('')}</g>`
2222
}
2323

24-
if (pack === 'fa') {
24+
if (prefix.startsWith('fa')) {
2525
path = Array.isArray(data)
26-
? createGroupedPath(data, pack)
26+
? createGroupedPath(data, prefix.substr(0, 2))
2727
: createPath(data)
2828
} else {
29-
path = pack.startsWith('fe') ? content : svg
29+
path = prefix.startsWith('fe') ? content : svg
3030
}
3131

3232
return {
@@ -38,17 +38,16 @@ const createIcon = (pack, icon) => {
3838

3939
/**
4040
* @description Custom parse all Icons provided by user
41-
* @param {String} pack - the name of the icon pack being used (fe, fa, mdi, etc)
4241
* @param {Object} iconSet - Registered Icons object
4342
* @returns {Object}
4443
*/
45-
const parseIcons = (pack, iconSet = {}) => {
44+
const parseIcons = (iconSet = {}) => {
4645
const parseIcon = (iconObject) => {
47-
const { icon, iconName } = iconObject
46+
const { icon, prefix, iconName } = iconObject
4847
// Is library icon
4948
if (icon) {
5049
return {
51-
[`${iconName}`]: createIcon(pack, icon)
50+
[`${iconName}`]: createIcon(prefix, icon)
5251
}
5352
} else {
5453
return {}
@@ -62,13 +61,12 @@ const parseIcons = (pack, iconSet = {}) => {
6261

6362
/**
6463
* @description Parse Icon packs
65-
* @param {String} pack - the name of the icon pack being used (fe, fa, mdi, etc)
6664
* @param {Object} iconSet Registered Icon set
6765
* @returns {Object} Parsed pack icons object
6866
*/
69-
export const parsePackIcons = (pack, iconSet) => {
67+
export const parsePackIcons = (iconSet) => {
7068
// TODO: Add support for other icon libraries
7169
// - Material Icons: these are string constants, and need lots of work
7270
// - Tailwind Icons (Hero icons)
73-
return parseIcons(pack, iconSet)
71+
return parseIcons(iconSet)
7472
}

0 commit comments

Comments
 (0)