chrisvxd / story2sketch

Convert Storybook into Sketch symbols 💎
Other
402 stars 32 forks source link

Background images rendered outside of symbol when using background position #62

Closed acrossell-hedgehog closed 5 years ago

acrossell-hedgehog commented 5 years ago

If an element has a background image position set, the background image is rendered outside of the symbols bounds when imported into Sketch. Is there a known workaround for this?

chrisvxd commented 5 years ago

Hi @acrossell-hedgehog, this sort of functionality is generally handled by the core dependency html-sketchapp. I'm due to upgrade to the latest version, which may address this issue, but I haven't had a chance to investigate yet. Will let you know :)

acrossell-hedgehog commented 5 years ago

That's great news, Chris!

I'm looking to bring this into the center of our design flow. This issue and the sketch resizing are the only issues that might get sticky with the design team so I'm really excited to see this drop in.

Many thanks!

chrisvxd commented 5 years ago

Hey @acrossell-hedgehog - I'm currently investigating this and I'm unable to reproduce the scenario you're describing. I have:

      <div
        className="my-div"
        style={{
          backgroundImage: "url(https://picsum.photos/200/300/?random)",
          backgroundRepeat: "no-repeat",
          backgroundPositionX: 50,
          backgroundPositionY: 50,
          border: "2px solid hotpink",
          display: "inline-block",
          padding: 50
        }}
      >
        Hello, world!
      </div>

In storybook:

Screenshot 2019-04-02 10 52 30

In sketch (ignore changing image):

Screenshot 2019-04-02 10 53 08

Are you able to share your styles?

acrossell-hedgehog commented 5 years ago

Hi @chrisvxd,

I believe the issue arises when background size is set to cover or contain

chrisvxd commented 5 years ago

@acrossell-hedgehog I've noticed some issues with background-size: contain, but I'm unable to reproduce exactly what you're talking about, or any issues with cover. I can't really diagnose further without a concrete CSS example with screenshots describing what you're encountering.

Having said that, this is more than likely an issue with html-sketchapp (the thing that handles the actual HTML -> Sketch conversion for story2sketch), so it might be worth us opening a ticket there and cross referencing here.

acrossell-hedgehog commented 5 years ago

The problem seems to be with background-position: center