These scripts were primarily created for downloading figma svgs and turning them into React components. You just need to put svgs in the folder under ./svgReact/icons/${FOLDER_NAME}
and adjust the config file in svgReact/config/path.ts
.
Main script is index.ts
located at svgReact/icons
. This script will optimize the svgs folder, generate svg components and IconIndex.ts
(export all icons) from provided svgs.
Currently, there are 3 type of icon sources:
- Figma:
- Description: Figma icons set (icons set download from Figma - source of truth of all designs).
- Location: Component's location is under
src/icons
folder.
- Custom:
- Description: Svgs that are not downloaded from Figma icon set
- Location: Component's location is under
src/icons/custom
folder.
-
Select all and download all icons set from Figma
-
Export as svg format
-
Put downloaded svgs or folder of svgs at
svgReact/icons/${FOLDER_NAME}
NOTE:
-
Under
${FOLDER_NAME}
, if there is a folder with svgs, the component will be named after the folder name and svgs under that folder will be concatenated with folder name. Ex: FolderArrow Down
and the svg file inside isSolid.svg
=> This will generate a component with nameArrowDownIcon.tsx
-
Under
${FOLDER_NAME}
, all components will be generated with the svg name. Ex: svg with nameArrow Down.svg
will generate a component with nameArrowDownIcon.tsx
.
-
-
Update configuration to variable
svgProcessPaths
in config filepath.ts
atsvgReact/icons/config
to initialize svg folder location, source folder, destination folder, ...- Config explanation:
-
"titleComment"
: Short text comment that describes and separates icon source set inIconIndex.ts
. -
"svgFolder"
: folder name that downloaded svg will be put at (just file name is needed). Ex: If all figma svg icons are downloaded and put undersvgReact/icons/svgs
. ThensvgFolder
will besvgs
. -
"inputFolderPath"
: Temporary distribution folder after generating new svg components. Path needs to start withsvgReact/icons/dist
. If you want to have separate folder namecustom
for your svgs, put it undersvgReact/icons/dist/custom
and this field will besvgReact/icons/dist/custom
-
"destFolder"
: Destination for generated svg components. Path needs to start withsrc/icons
.
-
- Example:
{ titleComment: 'Common', svgFolder: 'svgs', inputFolderPath: 'svgReact/icons/dist', destFolder: 'src/icons', }
- Config explanation:
-
Run
pnpm svgs:react:icons
to optimize and generate icon components for you. -
Run
pnpm build:ci
to build theall.ts
file with latest file names.