|
1 | | -export default (iconset, name, spinning) => { |
| 1 | +type iconset = 'bi' | 'fa'; |
| 2 | + |
| 3 | +export default (iconset: iconset, name: string, spinning: boolean) => { |
2 | 4 | let biName = name; |
3 | 5 | switch (name) { |
4 | 6 | case 'cog': |
@@ -107,7 +109,8 @@ export default (iconset, name, spinning) => { |
107 | 109 | name = 'question-circle'; |
108 | 110 | biName = 'question-circle'; |
109 | 111 | break; |
110 | | - case 'circle-xmark': |
| 112 | + case 'remove-circle': |
| 113 | + name = 'circle-xmark'; |
111 | 114 | biName = 'x-circle'; |
112 | 115 | break; |
113 | 116 | case 'new-window': |
@@ -164,5 +167,23 @@ export default (iconset, name, spinning) => { |
164 | 167 | biName = 'arrow-clockwise'; |
165 | 168 | break; |
166 | 169 | } |
167 | | - return spinning ? 'spinner-border spinner-border-sm' : `${iconset} ${iconset}-${name}`; |
| 170 | + |
| 171 | + function generateIconClass() { |
| 172 | + if (spinning){ |
| 173 | + return 'spinner-border spinner-border-sm'; |
| 174 | + } |
| 175 | + const iconName = iconset === 'bi' ? biName : name; |
| 176 | + // Handles legacy icons names. For example, fa-remove-circle was changed to fa-circle-xmark in a major version |
| 177 | + // update of font-awesome. To handle cases where customers are still on a very old version of font-awesome add |
| 178 | + // a fallback if statement to handle such cases |
| 179 | + function handleLegacyIconNames() { |
| 180 | + if (iconset === 'fa' && name === 'circle-xmark'){ |
| 181 | + return `${iconset}-${name} ${iconset}-remove-circle` |
| 182 | + } |
| 183 | + return `${iconset}-${iconName}`; |
| 184 | + } |
| 185 | + |
| 186 | + return `${iconset} ${handleLegacyIconNames()}` |
| 187 | + } |
| 188 | + return generateIconClass(); |
168 | 189 | }; |
0 commit comments