Our great sponsors
-
parsers
Specify helps you unify your brand identity by collecting, storing and distributing design tokens and assets — automatically.
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
react-native-svg-transformer
Import SVG files in your React Native project the same way that you would in a Web application.
For each rule we can use a different filter, such that the rule only applies to certain types of design tokens. Next to filters, we can also use parsers, which will manipulate the raw design tokens (which are in JSON format) and output a format that suits the programming language and platform more. Parsers behave like a pipeline, where each parser receives the input of the previous one. There are a lot of parsers to choose from, some perform very low level transformations such as round-number and camelcasify, but also full-blown parsers to a single technology such as to-tailwind and to-react-native.
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.
All vector assets in theme.js are imported directly. If you are not using Expo, you will need to install and configure react-native-svg-transformer to resolve the import statements.
The to-react-native parser transforms gradients into a format which is easy to use with react-native-linear-gradient. Example usage:
Related posts
- Is it possible to save multiple files as optimized SVGs at once?
- F360 going crazy over a client supplies SVG. Anything to clean it up?
- What is the benefit of stripping viewBox?
- Why are SVG so hard to import now ?
- Used an online SVG editor, this code got added to my file. I've already opened the file. How fucked am I?