ProductIcon Component
ProductIcon component is a React component to display plan or product icon in SVG format.
Please note that this component uses asset imports for generating icon images URLs.
Most build environments handle the asset imports gracefully out of the box (e.g. create-react-app, calypso-build).
If you're using a custom Webpack environment, make sure that you have the asset imports set up correctly.
Usage
import { ProductIcon } from '@automattic/components';
export default function MyComponent() {
return (
<div className="my-component">
<ProductIcon slug="plan_free" />
<ProductIcon slug="jetpack_business" />
<ProductIcon slug="jetpack_backup_daily_monthly" />
</div>
);
}
Props
slug
Plan or product slug. Can be one of the following:
free_planblogger-bundleblogger-bundle-2ypersonal-bundlepersonal-bundle-2ypersonal-bundle-monthlyvalue_bundlevalue_bundle-2yvalue_bundle-monthlyecommerce-bundleecommerce-bundle-2yecommerce-bundle-monthlybusiness-bundlebusiness-bundle-2ybusiness-bundle-monthlypro-planstarter-planjetpack_freejetpack_personaljetpack_personal_monthlyjetpack_premiumjetpack_premium_monthlyjetpack_businessjetpack_business_monthlyjetpack_completejetpack_complete_monthlyjetpack_complete_v2jetpack_complete_monthly_v2jetpack_crmjetpack_crm_monthlyjetpack_backup_dailyjetpack_backup_daily_monthlyjetpack_backup_realtimejetpack_backup_realtime_monthlyjetpack_backup_v2jetpack_backup_daily_v2jetpack_backup_daily_monthly_v2jetpack_backup_realtime_v2jetpack_backup_realtime_monthly_v2jetpack_backup_t1_yearlyjetpack_backup_t1_monthlyjetpack_backup_t2_yearlyjetpack_backup_t2_monthlyjetpack_boostjetpack_boost_monthlyjetpack_growthjetpack_scanjetpack_scan_monthlyjetpack_scan_v2jetpack_scan_monthly_v2jetpack_scan_daily_v2jetpack_scan_daily_monthly_v2jetpack_scan_realtime_v2jetpack_scan_realtime_monthly_v2jetpack_searchjetpack_search_monthlyjetpack_socialjetpack_social_monthlywpcom_searchwpcom_search_monthlyjetpack_search_v2jetpack_search_monthly_v2jetpack_anti_spamjetpack_anti_spam_monthlyjetpack_anti_spam_v2jetpack_anti_spam_monthly_v2jetpack_security_v2jetpack_security_monthly_v2jetpack_security_daily_v2jetpack_security_daily_monthly_v2jetpack_security_realtime_v2jetpack_security_realtime_monthly_v2jetpack_security_dailyjetpack_security_daily_monthlyjetpack_security_realtimejetpack_security_realtime_monthlyjetpack_security_t1_yearlyjetpack_security_t1_monthlyjetpack_security_t2_yearlyjetpack_security_t2_monthlyjetpack_videopressjetpack_videopress_monthly
className
Additional class name to be added to the icon element.
How to Add New Icon
In order to add a new icon to the component, do the following:
- Add a new icon image to the
imagesfolder. - Import the image in the
config.jsfile. This way an image URL will be generated by a bundler for further reuse. - Add the image path to the
pathsobject in theconfig.jsfile. - Add a new entry in the
iconToProductSlugMapobject in theconfig.jsfile:- key should match the image slug that just have been added,
- value should be an array of product slugs the image should be displayed for.
- Document the new icon as an available option for the
slugprop in this README. - Optionally, update the
docs/example.jsxfile to include the new icon.