// React Native SVG Component // https://github.com/react-native-community/react-native-svg // // Process // 1. Clean up SVG in graphics app (Illustrator/Sketch/etc) to set consistent width, height, and make sure the viewBox is "0, 0, W, H" // 2. Open SVG in text editor to remove width, height, and any undesired/unnecessary styles // 3. Open in https://jakearchibald.github.io/svgomg/ and optimize. // 4. Integrate info app by converting SVG tags to component-based SVG tags used in https://github.com/react-native-community/react-native-svg and updating with JS variables such that I can controls dimensions, colors, etc. // 5. Use in other components. // // For a set of icons, place converted SVGs in a single component and pass a "name" property to return the desired SVG. See below. // // Usage: // import SVG from '../Components/SVG' // import React from 'react' import _ from 'lodash' import Svg, { Circle, G, Path } from 'react-native-svg' const SVG = ({ name, fill, width, height, ...otherProps }) => { const graphics = { logo: { width: 70, height: 68, content: }, location: { width: 512, height: 512, content: } } const viewBoxWidth = graphics[name].width const viewBoxHeight = graphics[name].height const viewBoxRatio = viewBoxWidth / viewBoxHeight return ( {graphics[name].content} ) } SVG.propTypes = { name: React.PropTypes.string.isRequired, fill: React.PropTypes.string, width: React.PropTypes.number, height: React.PropTypes.number } SVG.defaultProps = { name: 'logo', fill: 'black' } export default SVG