Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear gradiant in svgxml show a plain color #1110

Closed
Jaco97 opened this issue Sep 19, 2019 · 4 comments
Closed

Linear gradiant in svgxml show a plain color #1110

Jaco97 opened this issue Sep 19, 2019 · 4 comments

Comments

@Jaco97
Copy link

Jaco97 commented Sep 19, 2019

Bug

I've added an svg with linear gradient using svgxml tag but it doesn't show the gradient, only a plain color, both on ios and android, devices and simulators

Environment info

React native info output:

System:
    OS: macOS 10.14.4
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 44.77 MB / 8.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.3.0 - /usr/local/bin/node
    npm: 6.10.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.4 => 0.60.4 
  npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
    react-native-svg: 6.3.1

Library version: 2.5.5

Steps To Reproduce

Import an svg with gradial and render it:

import { SvgXml } from 'react-native-svg';
import FacebookIc from '../../assets/ic_facebook_small.svg';

...

render() {
    return (<SvgXml width="30" height="30" xml={FacebookIc} />);
}

Describe what you expected to happen:

The svg should be showed with the gradient

My svg file contains

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="30" height="30" viewBox="0 0 30 30">
  <defs>
    <linearGradient id="linear-gradient" x1="0.5" x2="0.5" y2="1" gradientUnits="objectBoundingBox">
      <stop offset="0" stop-color="#f8ec46"/>
      <stop offset="1" stop-color="#f2c52d"/>
    </linearGradient>
  </defs>
  <path id="ic_facebook" d="M15,30A15,15,0,0,1,9.161,1.179,15,15,0,0,1,20.839,28.821,14.907,14.907,0,0,1,15,30ZM11.484,12.5V14.76H12.95v7.558h2.9V14.76h2.2l.169-2.256H15.845V10.868a.769.769,0,0,1,.361-.706,1.532,1.532,0,0,1,.8-.177,4.716,4.716,0,0,1,1.2.188l.308-2.219a9.744,9.744,0,0,0-2.278-.271c-.132,0-.264,0-.393.009a2.821,2.821,0,0,0-2.572,1.366,2.716,2.716,0,0,0-.323,1.265V12.5Z" transform="translate(0)" fill="url(#linear-gradient)"/>
</svg>
@msand
Copy link
Collaborator

msand commented Sep 27, 2019

Seems gradientUnits="objectBoundingBox" is not working, this seems to work for now:

  <linearGradient id="linear-gradient" x1="50%" x2="50%" y2="100%">
    <stop offset="0" stop-color="#f8ec46"/>
    <stop offset="1" stop-color="#f2c52d"/>
  </linearGradient>

@msand msand closed this as completed in 70c54e6 Sep 27, 2019
@msand
Copy link
Collaborator

msand commented Sep 27, 2019

Can you try with the latest commit from the master branch?

msand pushed a commit that referenced this issue Sep 28, 2019
## [9.9.7](v9.9.6...v9.9.7) (2019-09-28)

### Bug Fixes

* add gradientTransform to d.ts ([3f08c46](3f08c46)), closes [#1069](#1069)
* handling of gradients without stops ([18828c0](18828c0)), closes [#1099](#1099)
* handling of rounded rect ([c12d66e](c12d66e)), closes [#1112](#1112)
* units in linear and radial gradients ([70c54e6](70c54e6)), closes [#1110](#1110) [#1118](#1118)
@msand
Copy link
Collaborator

msand commented Sep 28, 2019

🎉 This issue has been resolved in version 9.9.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@msand msand added the released label Sep 28, 2019
@Jaco97
Copy link
Author

Jaco97 commented Sep 30, 2019

The problem seams to be solved! Thank you!

JackWillie added a commit to JackWillie/react-native-svg that referenced this issue Nov 27, 2022
## [9.9.7](software-mansion/react-native-svg@v9.9.6...v9.9.7) (2019-09-28)

### Bug Fixes

* add gradientTransform to d.ts ([3f08c46](software-mansion/react-native-svg@3f08c46)), closes [#1069](software-mansion/react-native-svg#1069)
* handling of gradients without stops ([18828c0](software-mansion/react-native-svg@18828c0)), closes [#1099](software-mansion/react-native-svg#1099)
* handling of rounded rect ([c12d66e](software-mansion/react-native-svg@c12d66e)), closes [#1112](software-mansion/react-native-svg#1112)
* units in linear and radial gradients ([70c54e6](software-mansion/react-native-svg@70c54e6)), closes [#1110](software-mansion/react-native-svg#1110) [#1118](software-mansion/react-native-svg#1118)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants