@@ -28,8 +28,8 @@ export const PhosphorIcon = React.memo((props: { icon: IconKey } & PhosphorIconP
2828 const PIcon = Icons [ props . icon ] ;
2929
3030 return < PIcon
31- className = 'phosphor-icon'
3231 { ...otherProps }
32+ className = { 'phosphor-icon ' + ( props . className || '' ) }
3333 /> ;
3434} ) ;
3535
@@ -215,7 +215,7 @@ library.add(
215215) ;
216216
217217export interface IconProps {
218- icon : ExtendedIconProp ;
218+ icon : ExtendedIconProp | IconKey ;
219219 color : string ;
220220 size ?: SizeProp ;
221221}
@@ -281,18 +281,52 @@ export const SourceIcons = {
281281 Unknown : { icon : [ 'fas' , 'question' ] , color : '#888' }
282282} as const ;
283283
284- import { FontAwesomeIcon , Props as FAIProps } from '@fortawesome/react-fontawesome' ;
284+ import * as FA from '@fortawesome/react-fontawesome' ;
285285type ExtendedIconProp = IconProp | readonly [ 'fac' , string ] | readonly [ IconPrefix , IconName ] ;
286- export const Icon = React . memo (
287- FontAwesomeIcon as ( props : Omit < FAIProps , 'icon' > & {
286+ const FAIcon = React . memo (
287+ FA . FontAwesomeIcon as ( props : Omit < FA . FontAwesomeIconProps , 'icon' > & {
288288 icon : ExtendedIconProp ,
289289 onClick ?: ( event : React . MouseEvent ) => void ,
290290 onKeyPress ?: ( event : React . KeyboardEvent ) => void
291291 } ) => JSX . Element
292292) ;
293+
294+ export const Icon = ( props : {
295+ icon : ExtendedIconProp | IconKey ,
296+ onClick ?: ( event : React . MouseEvent ) => void ,
297+ onKeyPress ?: ( event : React . KeyboardEvent ) => void ,
298+
299+ spin ?: boolean ,
300+ color ?: string ,
301+ size ?: string ,
302+ fixedWidth ?: boolean ,
303+ className ?: string ,
304+ title ?: string
305+ } ) : JSX . Element => {
306+ if ( Array . isArray ( props . icon ) ) {
307+ return < FAIcon
308+ { ...props }
309+ size = { props . size as FA . FontAwesomeIconProps [ 'size' ] }
310+ icon = { props . icon as ExtendedIconProp }
311+ />
312+ } else {
313+ return < PhosphorIcon
314+ icon = { props . icon as IconKey }
315+
316+ onClick = { props . onClick }
317+ onKeyPress = { props . onKeyPress }
318+
319+ color = { props . color }
320+ size = { props . size || '1.25em' }
321+ className = { props . className }
322+ alt = { props . title }
323+ />
324+ }
325+ } ;
326+
293327export type { ExtendedIconProp as IconProp , SizeProp } ;
294328
295- export const SuggestionIcon = styled ( Icon ) . attrs ( ( ) => ( {
329+ export const SuggestionIcon = styled ( FAIcon ) . attrs ( ( ) => ( {
296330 icon : [ 'fas' , 'lightbulb' ]
297331} ) ) `
298332 margin: 0 6px;
@@ -309,7 +343,7 @@ export const suggestionIconHtml = iconHtml(
309343 }
310344) ;
311345
312- export const WarningIcon = styled ( Icon ) . attrs ( ( ) => ( {
346+ export const WarningIcon = styled ( FAIcon ) . attrs ( ( ) => ( {
313347 icon : [ 'fas' , 'exclamation-triangle' ]
314348} ) ) `
315349 margin: 0 6px;
@@ -326,7 +360,7 @@ export const warningIconHtml = iconHtml(
326360 }
327361) ;
328362
329- export const ArrowIcon = styled ( Icon ) . attrs ( ( ) => ( {
363+ export const ArrowIcon = styled ( FAIcon ) . attrs ( ( ) => ( {
330364 fixedWidth : true ,
331365 icon : [ 'fas' , 'arrow-left' ]
332366} ) ) `
0 commit comments