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

SVG height and width #269

Open
LincMitch opened this issue Feb 20, 2018 · 6 comments
Open

SVG height and width #269

LincMitch opened this issue Feb 20, 2018 · 6 comments

Comments

@LincMitch
Copy link

I'm using react-primitives-svg to render the same SVG code to both web and sketch:

switch (Platform.OS) {
  case "sketch":
    SvgLib = require("react-primitives-svg/lib/core.sketch");
    break;
  case "web":
    SvgLib = require("react-primitives-svg/lib/core.web");
    break;
  default: // React Native should be able to pick up `core.ios.js` or `core.android.js` according to the platform
    // SvgLib = require("react-primitives-svg");
}

Now the SVG height and width seem to be interpreted differently for Sketch and web.
<Svg viewBox="0 0 200 200" width="200" height="200"> is more like 20/20 on web, but OK in Sketch.
but...
<Svg viewBox="0 0 200 200"> renders 95.61px /.47px in Sketch, but OK on web.

So I can't use the same code.

@alampros suggests it maybe a yoga layout issue as he had a similar problem #204

@VinSpee
Copy link

VinSpee commented Apr 27, 2018

I think I'm banging into this same issue:

Code:

const Bg = ({ type }: { type: string }) => (
  <Svg
    id="grad"
    style={{
      position: 'absolute',
      ...StyleSheet.absoluteFillObject,
      width: '100%',
      height: '100%',
    }}
  >
    <Defs>
      <LinearGradient
        id={`button-sheen-${type}`}
        x1="0"
        x2="0"
        y1="0"
        y2="1"
      >
        <Stop
          offset="0%"
          stopColor={THEME[type.toUpperCase()].BG_COLOR_START}
        />
        <Stop
          offset="100%"
          stopColor={THEME[type.toUpperCase()].BG_COLOR_END}
        />
      </LinearGradient>
    </Defs>
    <Rect
      fill={`url(#button-sheen-${type})`}
      style={{
        position: 'absolute',
        ...StyleSheet.absoluteFillObject,
        width: '100%',
        height: '100%',
      }}
      x="0"
      y="0"
    />
  </Svg>
);

Web screencap (yay!):
screen shot 2018-04-27 at 2 18 27 pm

Sketch screencap (no gradient?):
screen shot 2018-04-27 at 2 18 11 pm

Sketch gradient detail (ahh, there's a gradient it's just TINY?):
screen shot 2018-04-27 at 2 19 12 pm

@isiaapp
Copy link

isiaapp commented Jul 25, 2018

@VinSpee have you solved this problem?

@VinSpee
Copy link

VinSpee commented Jul 25, 2018

@isiaap no I have not 😢

@isiaapp
Copy link

isiaapp commented Jul 25, 2018

@VinSpee does it mean you have abandoned using gradients? Or some workaround has been found?

@VinSpee
Copy link

VinSpee commented Jul 25, 2018

@isiaapp yes, not using gradients for now. certainly not ideal or acceptable, but such is life.

@VinSpee
Copy link

VinSpee commented Nov 13, 2018

Hi! It's been quite some time and a couple of large version bumps - is there any intent to fix this issue? I'm just curious if it's even on the roadmap. "No" is a completely acceptable and sane answer.

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

3 participants