Skip to content

Commit dbd6f52

Browse files
authored
Merge pull request vault-development#105 from uphold/enhancement/custom-fill
Add ability to customize fill color
2 parents 1e8b8d8 + c6f3e87 commit dbd6f52

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
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
@@ -34,6 +34,11 @@ interface SvgUriProps {
3434
* Fill color for the svg object
3535
*/
3636
fill?: string
37+
38+
/**
39+
* Fill the entire svg element with same color
40+
*/
41+
fillAll?: boolean
3742
}
3843

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

index.js

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

221221
obtainComponentAtts({attributes}, enabledAttributes) {
222222
const styleAtts = {};
223+
224+
if (this.state.fill && this.props.fillAll) {
225+
styleAtts.fill = this.state.fill;
226+
}
227+
223228
Array.from(attributes).forEach(({nodeName, nodeValue}) => {
224229
Object.assign(styleAtts, utils.transformStyle({
225230
nodeName,
@@ -303,6 +308,7 @@ SvgUri.propTypes = {
303308
svgXmlData: PropTypes.string,
304309
source: PropTypes.any,
305310
fill: PropTypes.string,
311+
fillAll: PropTypes.bool
306312
}
307313

308314
module.exports = SvgUri;

0 commit comments

Comments
 (0)