svgr
svgo
Our great sponsors
svgr | svgo | |
---|---|---|
26 | 24 | |
9,327 | 18,813 | |
- | 0.6% | |
8.3 | 8.3 | |
29 days ago | 7 days ago | |
TypeScript | JavaScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
svgr
-
One way of building an SVG icon library for your project
Really interesting framework agnostic approach, but I think SVGR is a better option for my React homies. It imports an SVG file as a React component. Shouts also to react-icons if Font Awesome, Material Icons and friends are more your bag.
-
Alternative libs to migrate from React to Vue (or Vue to React)
SVGR
-
Power up SVGs with React and CSS
There is another way to import an SVG in Create React App, though. We can import the SVG as a ReactComponent. This is because CRA leverages SVGR to process SVGs.
-
Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ React-ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ ΠΈΠΊΠΎΠ½ΠΎΠΊ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Figma API ΠΈ SVGR. Π§Π°ΡΡΡ 2.
const { types } = require('@babel/core'); module.exports = { ... template: function svgrCustomTemplate( { imports, interfaces, componentName, props, jsx, exports }, { tpl } ) { // ΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΊΠΎΡΠ½Π΅Π²ΠΎΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ Π½Π° SvgIcon jsx.openingElement.name.name = 'SvgIcon'; jsx.closingElement.name.name = 'SvgIcon'; // https://github.com/gregberge/svgr/issues/530 // ΠΏΡΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΈ ΠΊΠΎΡΠ½Π΅Π²ΠΎΠ³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° ΠΏΡΠΎΠΏΠ°Π΄Π°Π΅Ρ ΡΠΏΡΠ΅Π΄ ΠΏΡΠΎΠΏΡΠΎΠ² // ΠΏΠΎΡΡΠΎΠΌΡ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ Π΄ΠΎΠ±Π°Π²ΠΈΡΡ ΡΠΏΡΠ΅Π΄ ΠΏΡΠΎΠΏΡΠΎΠ² ΡΠ°ΠΌΠΎΡΡΠΎΡΡΠ΅Π»ΡΠ½ΠΎ jsx.openingElement.attributes.push( types.jSXSpreadAttribute(types.identifier('props')) ); return tpl` ${imports}; import { SvgIcon } from '../SvgIcon'; ${interfaces}; const ${componentName} = (${props}) => ( ${jsx} ); ${exports}; ` } }
-
Using SVGs in Common Lisp web apps with Djula
To solve these problems and have a better development workflow, I have created a package called cl-djula-svg which automates all the above steps for you. The inspiration for this package came from svgr which exactly does the same thing in React applications. It takes a SVG file, process some override logic, optimize it and create React wrapper components based on the SVG content.
-
Some svg icons wont show with react native svg
I normally use SVGR but every time a designer sends me an svg iβll pass it in svgOmg that deletes all the unnecessary attributes and propietary code from figma, illustrator &co.
- External SVGs that you can style
-
How to debug from this error statement
https://github.com/gregberge/svgr/issues/362 this may help as well.
-
Repeating variable names for imports, types and switch. Got to be a better way!
If you're using Webpack, CRA, or Next.js, you should be using SVGR.
-
How to use SVGs in React
SVGR is the library that powers this ability. Setting it up could be a little hairy, thankfully many popular frameworks (Create React App, Gatsby) support this feature out of the box.
svgo
-
Ask HN: FOSS Projects Worth Donating To?
Look at software you use and identify underlying libraries.
SVGO https://github.com/svg/svgo is used by many graphics software but hasn't seen donations commensurate with usage https://opencollective.com/svgo
- Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ React-ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ ΠΈΠΊΠΎΠ½ΠΎΠΊ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Figma API ΠΈ SVGR. Π§Π°ΡΡΡ 2.
- Used an online SVG editor, this code got added to my file. I've already opened the file. How fucked am I?
-
Using SVGs in Common Lisp web apps with Djula
There are still a lot of things cl-djula-svg is capable of doing. For the immediate future, I am looking at adding optimization capabilities something like what svgo is doing for svgr. If you know anything else needs to be done to improve the package, please open an issue in the repository.
-
Is Rust a good first language to master?
Writing/patching JS/TS-based CLI tools like Prettier or SVGO
-
Are there any lesser-known tools you use a lot in your work?
svgomg is just a web frontend for svgo. You can run it locally on the command line.
-
SVG Passthrough Precision
Often, you can considerably reduce the file size of an SVG text file without a noticeable reduction in perceptual quality just by reducing the precision of the coordinates.
The awesome SVG Optimizer [1] has a filter (cleanupNumericValues) to process SVG files to a fixed precision.
The equally awesome SVG Optimizer Missing Gui (SVGOMG) [2] provides a web-based GUI [3] to interactively adjust precision and see the resulting render (and file-size).
-
How to Optimize SVG Animations to Improve Your Page Speed Insights Score
There is a great tool that can optimize an SVG, and it's open-source. It's called SVGO. It also has an interface where you can upload your SVG, toggle some buttons, and check the results in real time. However, beware that some options might change the SVG and lead to undesired changes.
-
Frontend Tips 1βββOnline tools to compress images and SVGs
There are a hundred of tools bases in the SVGO Project but for me this website has the best compression is really simple and useful to compress SVGs in seconds. The problem is that does not allow compressing multiple SVGs at the same time and is not going to happen in the future.
-
From Figma to React Native using Specify
For SVG's, we can use the svgo parser, which optimizes the SVG code and outputs a minified result. The default svgo settings are pretty good, but we add removeDimensions to make them responsive and replace the hard coded colors with "currentColor" such that we can color them with React Native styles.
What are some alternatives?
svgomg - Web GUI for SVGO
svg-sprite-loader - Webpack loader for creating SVG sprites.
vite-plugin-svgr - Vite plugin to transform SVGs into React components
esbuild - An extremely fast bundler for the web
raw-loader - A loader for webpack that allows importing files as a String
svg-to-react - Tool to convert SVG files to React components
rollup-plugin-visualizer - πβοΈ Visuallize your bundle
blog-series-nextjs-nx - Source code for the Next.js + Nx blog series
vite-plugin-svg-icons - Vite Plugin for fast creating SVG sprites.
Konva - Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
workerize-loader - ποΈ Automatically move a module into a Web Worker (Webpack loader)
framer/motion - Open source, production-ready animation and gesture library for React