ProtrakFontAwesomeIcon
Reference
- This component is ideal for rendering FontAwesome icons with additional customization and dynamic fetching capabilities.
- The
ProtrakFontAwesomeIconcomponent is a wrapper around theFontAwesomeIconcomponent from the @fortawesome/react-fontawesome library. - It simplifies the usage of FontAwesome icons by integrating a utility function to fetch icons dynamically.
- It Fetches FontAwesome icons dynamically based on the provided name.
- It Supports custom styles, classes, and event handling.
- It Displays a tooltip using the
titleprop.
Props
-
className- Type:
string - Description: The CSS class name(s) to apply to the icon for styling.
- Type:
-
fontAwesomeIconName- Type:
string - Default:
'' - Description: The name of the FontAwesome icon to render.
- Type:
-
style- Type:
object - Default:
{} - Description: Inline styles to apply to the icon.
- Type:
-
onClick- Type:
function - Default:
() => {} - Description: Callback function triggered when the icon is clicked.
- Type:
-
title- Type:
string - Default:
'' - Description: Tooltip text displayed when hovering over the icon.
- Type:
Usage Example
import { ProtrakFontAwesomeIcon } from './ProtrakFontAwesomeIcon';
function Example(pageContext) {
const { protrakComponents } = React.useContext(customWidgetContext);
const { ProtrakFontAwesomeIcon } = protrakComponents;
return(
<ProtrakFontAwesomeIcon
className="custom-icon"
fontAwesomeIconName="faCoffee"
style={{ color: 'blue', fontSize: '24px' }}
onClick={() => console.log('Icon clicked!')}
title="Coffee Icon"
/>
);
}
- This renders a blue coffee icon with a tooltip "Coffee Icon" and logs a message when clicked.