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

renderGrid gifs positions are not set properly in lit #322

Open
2 tasks done
zizhouW opened this issue Nov 3, 2022 · 2 comments
Open
2 tasks done

renderGrid gifs positions are not set properly in lit #322

zizhouW opened this issue Nov 3, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@zizhouW
Copy link

zizhouW commented Nov 3, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I am trying to use the renderGrid component inside a lit project.
It seems like all gifs are rendered with

position: absolute;
top: 0px;
left: 0px;

and stacked together as a result. Could it be because of shadow DOM?

Expected behavior 🤔

renderGrid should form a grid to display all gifs fetched

Steps to reproduce 🕹

https://codesandbox.io/s/litelement-typescript-forked-i8nz57

Screenshots or Videos 📹

image

Platform 🌍

  • macOS, Windows, Android
  • Chrome, Firefox, Safari

GIPHY-JS SDK version

@giphy/js-components 5.8.2

TypeScript version

v4.7.4

Additional context 🔦

No response

@zizhouW zizhouW added the bug Something isn't working label Nov 3, 2022
@giannif
Copy link
Collaborator

giannif commented Nov 3, 2022

@zizhouW I do feel it has something to do with lit, although I am not familiar enough with the framework or shadow doms to diagnose. I also see a runtime error on hover. This may take awhile to evaluate

In a non-lit environment, everything is still working with the package versions you're using: https://codesandbox.io/s/giphy-js-components-1wq52x1w44?file=/src/grid.ts

You may need a new approach if you're working with the shadow dom. Maybe you can use the fetch api and render your own grid in the meantime

@zizhouW
Copy link
Author

zizhouW commented Nov 3, 2022

Thank you @giannif! Looks like both the odd positioning as well as the on hover errors are because of renderGrid being wrapped in shadow DOM. I have updated the codesandbox to show a comparison between being wrapped in shadow DOM vs NOT wrapped in shadow DOM. I see that renderGrid is using bricks.js for the "render logic" 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants