-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use svg sprite for icons #480
base: main
Are you sure you want to change the base?
Conversation
Thank you for following the naming conventions for pull request titles! 🙏 |
import { $ } from "execa"; | ||
import glob from "fast-glob"; | ||
import fsExtra from "fs-extra"; | ||
import { parse } from "node-html-parser"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
script to generate sprite sheet
@@ -18,6 +18,7 @@ | |||
"db:seed": "NODE_ENV='test' tsx prisma/seeds/index.ts", | |||
"dev": "next dev", | |||
"build": "next build", | |||
"build:icons": "tsx scripts/build-icons.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
command to rebuild the sprite sheet when new icons are added to the list
@@ -0,0 +1,103 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- This file is generated by npm run build:icons --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated sprite sheet
export const iconList = new Set([ | ||
"account-circle-fill", | ||
"account-circle-line", | ||
"add-circle-line", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list of icons we are using through out the app
import type { IconName } from "./icon-names"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
icon component
Rendering icons as JSX components is expensive and significantly increases the size of your bundle. This PR aims to address that by replacing them with SVG sprite icons, which are cacheable and faster than the JS based solution.
here's a explanation why we shouldn't import SVG icons as JSX https://twitter.com/_developit/status/1382838799420514317?lang=en
advantages using sprite sheet icons