Skip to content

Commit a29d3a8

Browse files
authored
Merge branch 'master' into onLoad
2 parents 7d2a9d2 + dbd6f52 commit a29d3a8

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ react-native link react-native-svg # not react-native-svg-uri !!!
2727
| `source` | `ImageSource` | | Same kind of `source` prop that `<Image />` component has
2828
| `svgXmlData` | `String` | | You can pass the SVG as String directly
2929
| `fill` | `Color` | | Overrides all fill attributes of the svg file
30+
| `fillAll` | `Boolean` | Adds the fill color to the entire svg object
3031

3132
## Known Bugs
3233

index.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ interface SvgUriProps {
3939
* Invoked when load completes successfully.
4040
*/
4141
onLoad?: Function
42+
43+
/**
44+
* Fill the entire svg element with same color
45+
*/
46+
fillAll?: boolean
4247
}
4348

4449
export default class SvgUri extends Component<SvgUriProps, {}> { }

index.js

+6
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ class SvgUri extends Component{
226226

227227
obtainComponentAtts({attributes}, enabledAttributes) {
228228
const styleAtts = {};
229+
230+
if (this.state.fill && this.props.fillAll) {
231+
styleAtts.fill = this.state.fill;
232+
}
233+
229234
Array.from(attributes).forEach(({nodeName, nodeValue}) => {
230235
Object.assign(styleAtts, utils.transformStyle({
231236
nodeName,
@@ -310,6 +315,7 @@ SvgUri.propTypes = {
310315
source: PropTypes.any,
311316
fill: PropTypes.string,
312317
onLoad: PropTypes.func,
318+
fillAll: PropTypes.bool
313319
}
314320

315321
module.exports = SvgUri;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-svg-uri",
3-
"version": "1.2.1",
3+
"version": "1.2.3",
44
"description": "Render an SVG Image from an URL",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)