React

Migrating Icons

Easily migrate from old icons to new icons.

Upgrade Methods

There are 2 methods you can apply depending on how you are currently using icons.

Codemod Script

If you are using any of the 3 icon packages below, you can easily upgrade to the renewed icon packages using the provided codemod script.

Icons used in the 3 packages are replaced with icons from @karrotmarket/react-monochrome-icon.

Manual Upgrade

You need to manually upgrade in the following cases:

Workflow

Before you start

Since many changes will occur, it's good to check that there are no uncommitted changes before starting.

Codemod Script

Install Renewed Icon Packages

npm install @karrotmarket/react-monochrome-icon @karrotmarket/react-multicolor-icon
Package Description

Install only the packages you need from the 2 options.

  • @karrotmarket/react-monochrome-icon
    • Monochrome icon package. Includes general icons, category icons, and service icons.
    • Service icons provided by this package can only be used in black.
    • When running codemod, all icons from existing packages are replaced with icons from this package.
  • @karrotmarket/react-multicolor-icon
    • Multicolor icon package. Includes category icons and service icons.
    • Category and service icons provided by this package can only be used in the colors provided by the package.
    • Multicolor icons previously used as SVG can be directly replaced with this package. You can install it only if needed.

Run Codemod Script

Run the replace-react-icon transform.

npx @seed-design/codemod@latest replace-react-icon <target_path>

replace-react-icon

Learn more about this transform.

Verify Results

If all transformations complete without issues, you'll see results like this:

All done.
Results:
0 errors // [!code highlight]
439 unmodified
1 skipped
27 ok
Time elapsed: 43.376seconds
Understanding Results
  • errors: Number of files where icon references could not be verified due to parsing errors.
    • If a file with an error has no code referencing old icons, you can ignore the error for that file.
    • If a file has code referencing old icons, fix the problematic parts and re-run the script, or manually migrate the icons in that file.
  • unmodified: Number of files with no icon references, so no transformations were made.
  • skipped: Number of files that are not targets for transformation, such as empty files.
  • ok: Number of files where transformations were made.
Parsing Error
ERR /Users/seed/foo/bar.js Transformation error (Unexpected reserved word 'package'. (3:3))

Parsing errors can occur when running the codemod script. Parsing errors occur for reasons like:

  • Using deprecated syntax like import assertion with assert
  • Using reserved words like package as variable names

Format Code

Format the code using the formatter your project uses.

Remove Previous Packages

Verify that all old icons have been replaced, then remove the previous packages.

npm uninstall @seed-design/icon @seed-design/react-icon @karrotmarket/karrot-ui-icon

Check for Side Effects

  • Check if side effects occurred and verify that changes were made as intended.
  • During the design QA process, it may have been decided to use new icons instead of automatically changed icons. In such cases, refer to the Figma design file and apply it to the code.
  • For places where multicolor icons need to be used, use the multicolor icon package.

Possible Side Effects

No Exactly Matching Renewed Icon

  • Among the previous icons, the following 5 icons (15 variants total) do not have visually exact matches in the renewed icon package.
  • When running the codemod script, they are converted to the recommended icon, but verification is required after changes as there are significant visual differences.
Previous Icon NameRenewed Icon Name
IconBoldThin
IconBoldRegular
IconBoldFill
IconCobuyingThin
IconCobuyingRegular
IconCobuyingFill
IconDeliveryThin
IconDeliveryRegular
IconDeliveryFill
IconSuggestThin
IconSuggestRegular
IconSuggestFill
IconWriteStoryThin
IconWriteStoryRegular
IconWriteStoryFill
How to Check Usage
  • When using the codemod script, if 5 icons (15 variants total) are used, a message is printed to the terminal.
REP Changed ... to ..., but you need to verify if the changed icon is appropriate
  • When using the codemod script with the --log flag, usage is recorded in migrate-icons-warnings.log.
  • You can search the code directly using the following:
(IconBold|IconCobuying|IconDelivery|IconSuggest|IconWriteStory)(Thin|Regular|Fill)|(IconTUppercaseSerif|IconShoppingbag2Stacked|IconTruck|IconLightbulbDot5|IconHorizline2VerticalChatbubbleRight)(Line|Fill)

Multiple Previous Icons Replaced with One Renewed Icon

Previous icons and renewed icons correspond in an n:1 manner. Therefore, multiple different icons that were displayed on the same page may be replaced with the same renewed icon. Verify that the icons display as intended.

  • Of the 3 variants of one previous icon, both the Thin variant and Regular variant are replaced with the Line variant in the renewed icon.
    • For example, both IconForwardThin and IconForwardRegular are replaced with IconArrowRightLine.
    • The Fill variant of the previous icon is also replaced with the Fill variant in the renewed icon.
  • There are also cases where multiple previous icons are replaced with one renewed icon.
    • For example, IconHeadphoneRegular, IconHelpcenterRegular, and IconHelperRegular are all replaced with IconHeadsetLine.

Table of contents